Revision dd2bc9b6 qa/rapi-workload.py
b/qa/rapi-workload.py | ||
---|---|---|
935 | 935 |
#pylint: enable=W0142 |
936 | 936 |
|
937 | 937 |
|
938 |
def TestJobCancellation(client, node_one, node_two, instance_one, instance_two): |
|
939 |
""" Test if jobs can be cancelled. |
|
940 |
|
|
941 |
@type node_one string |
|
942 |
@param node_one The name of a node in the cluster. |
|
943 |
@type node_two string |
|
944 |
@param node_two The name of a node in the cluster. |
|
945 |
@type instance_one string |
|
946 |
@param instance_one An available instance name. |
|
947 |
@type instance_two string |
|
948 |
@param instance_two An available instance name. |
|
949 |
|
|
950 |
""" |
|
951 |
|
|
952 |
# Just in case, remove all previously present instances |
|
953 |
RemoveAllInstances(client) |
|
954 |
|
|
955 |
# Let us issue a job that is sure to both succeed and last for a while |
|
956 |
running_job = client.CreateInstance("create", instance_one, "drbd", |
|
957 |
[{"size": "5000"}], [{}], |
|
958 |
os="debian-image", pnode=node_one, |
|
959 |
snode=node_two) |
|
960 |
|
|
961 |
# And immediately afterwards, another very similar one |
|
962 |
job_to_cancel = client.CreateInstance("create", instance_two, "drbd", |
|
963 |
[{"size": "5000"}], [{}], |
|
964 |
os="debian-image", pnode=node_one, |
|
965 |
snode=node_two) |
|
966 |
|
|
967 |
# Try to cancel, which should fail as the job is already running |
|
968 |
success, msg = client.CancelJob(running_job) |
|
969 |
if success: |
|
970 |
print "Job succeeded: this should not have happened as it is running!" |
|
971 |
print "Message: %s" % msg |
|
972 |
|
|
973 |
success, msg = client.CancelJob(job_to_cancel) |
|
974 |
if not success: |
|
975 |
print "Job failed: this was unexpected as it was not a dry run" |
|
976 |
print "Message: %s" % msg |
|
977 |
|
|
978 |
# And wait for the proper job |
|
979 |
client.WaitForJobCompletion(running_job) |
|
980 |
|
|
981 |
# Remove all the leftover instances, success or no success |
|
982 |
RemoveAllInstances(client) |
|
983 |
|
|
984 |
|
|
938 | 985 |
def Workload(client): |
939 | 986 |
""" The actual RAPI workload used for tests. |
940 | 987 |
|
... | ... | |
1000 | 1047 |
nodes = qa_config.AcquireManyNodes(2) |
1001 | 1048 |
instances = qa_config.AcquireManyInstances(2) |
1002 | 1049 |
TestInstanceMoves(client, nodes[0], nodes[1], instances[0], instances[1]) |
1050 |
TestJobCancellation(client, nodes[0].primary, nodes[1].primary, |
|
1051 |
instances[0].name, instances[1].name) |
|
1003 | 1052 |
qa_config.ReleaseManyInstances(instances) |
1004 | 1053 |
qa_config.ReleaseManyNodes(nodes) |
1005 | 1054 |
|
Also available in: Unified diff