Revision 9578de1c qa/rapi-workload.py
b/qa/rapi-workload.py | ||
---|---|---|
690 | 690 |
Finish(client, client.DeleteInstance, instance_name) |
691 | 691 |
|
692 | 692 |
|
693 |
def TestJobCancellation(client, node_one, node_two, instance_one, instance_two): |
|
694 |
""" Test if jobs can be cancelled. |
|
695 |
|
|
696 |
@type node_one string |
|
697 |
@param node_one The name of a node in the cluster. |
|
698 |
@type node_two string |
|
699 |
@param node_two The name of a node in the cluster. |
|
700 |
@type instance_one string |
|
701 |
@param instance_one An available instance name. |
|
702 |
@type instance_two string |
|
703 |
@param instance_two An available instance name. |
|
704 |
|
|
705 |
""" |
|
706 |
|
|
707 |
# Just in case, remove all previously present instances |
|
708 |
RemoveAllInstances(client) |
|
709 |
|
|
710 |
# Let us issue a job that is sure to both succeed and last for a while |
|
711 |
running_job = client.CreateInstance("create", instance_one, "drbd", |
|
712 |
[{"size": "5000"}], [{}], |
|
713 |
os="debian-image", pnode=node_one, |
|
714 |
snode=node_two) |
|
715 |
|
|
716 |
# And immediately afterwards, another very similar one |
|
717 |
job_to_cancel = client.CreateInstance("create", instance_two, "drbd", |
|
718 |
[{"size": "5000"}], [{}], |
|
719 |
os="debian-image", pnode=node_one, |
|
720 |
snode=node_two) |
|
721 |
|
|
722 |
# Try to cancel, which should fail as the job is already running |
|
723 |
success, msg = client.CancelJob(running_job) |
|
724 |
if success: |
|
725 |
print "Job succeeded: this should not have happened as it is running!" |
|
726 |
print "Message: %s" % msg |
|
727 |
|
|
728 |
success, msg = client.CancelJob(job_to_cancel) |
|
729 |
if not success: |
|
730 |
print "Job failed: this was unexpected as it was not a dry run" |
|
731 |
print "Message: %s" % msg |
|
732 |
|
|
733 |
# And wait for the proper job |
|
734 |
client.WaitForJobCompletion(running_job) |
|
735 |
|
|
736 |
# Remove all the leftover instances, success or no success |
|
737 |
RemoveAllInstances(client) |
|
738 |
|
|
739 |
|
|
740 |
def TestInstanceMoves(client, node_one, node_two, instance_to_create, |
|
741 |
new_instance): |
|
742 |
""" Reuses a part of the QA to test instance moves. |
|
743 |
|
|
744 |
@type node_one C{_QaNode} |
|
745 |
@param node_one A node configuration object. |
|
746 |
@type node_two C{_QaNode} |
|
747 |
@param node_two A node configuration object. |
|
748 |
@type instance_to_create C{_QaInstance} |
|
749 |
@param instance_to_create An instance configuration object. |
|
750 |
@type new_instance C{_QaInstance} |
|
751 |
@param new_instance An instance configuration object. |
|
752 |
|
|
753 |
""" |
|
754 |
|
|
755 |
# First create the instance to move |
|
756 |
Finish(client, client.CreateInstance, |
|
757 |
"create", instance_to_create.name, "plain", [{"size": "2000"}], [{}], |
|
758 |
os="debian-image", pnode=node_one.primary) |
|
759 |
|
|
760 |
Finish(client, client.ShutdownInstance, |
|
761 |
instance_to_create.name, dry_run=False, no_remember=False) |
|
762 |
|
|
763 |
instance_to_create.SetDiskTemplate("plain") |
|
764 |
|
|
765 |
qa_rapi.TestInterClusterInstanceMove(instance_to_create, new_instance, |
|
766 |
[node_one], node_two, |
|
767 |
perform_checks=False) |
|
768 |
|
|
769 |
# Finally, cleanup |
|
770 |
RemoveAllInstances(client) |
|
771 |
|
|
772 |
|
|
693 | 773 |
def Workload(client): |
694 | 774 |
""" The actual RAPI workload used for tests. |
695 | 775 |
|
... | ... | |
749 | 829 |
instance.Release() |
750 | 830 |
qa_config.ReleaseManyNodes(nodes) |
751 | 831 |
|
832 |
nodes = qa_config.AcquireManyNodes(2) |
|
833 |
instances = qa_config.AcquireManyInstances(2) |
|
834 |
TestInstanceMoves(client, nodes[0], nodes[1], instances[0], instances[1]) |
|
835 |
qa_config.ReleaseManyInstances(instances) |
|
836 |
qa_config.ReleaseManyNodes(nodes) |
|
837 |
|
|
752 | 838 |
|
753 | 839 |
def Usage(): |
754 | 840 |
sys.stderr.write("Usage:\n\trapi-workload.py qa-config-file") |
Also available in: Unified diff