Revision 24c530df qa/qa_instance.py
b/qa/qa_instance.py | ||
---|---|---|
1094 | 1094 |
",".join(enabled_disk_templates)], |
1095 | 1095 |
fail=False) |
1096 | 1096 |
|
1097 |
|
|
1098 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) |
|
1099 |
def _TestInstanceUserDown(instance, master, hv_shutdown_fn): |
|
1100 |
# Shutdown instance in Xen and bring instance status to 'USER_down' |
|
1101 |
hv_shutdown_fn() |
|
1102 |
|
|
1103 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1104 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1105 |
utils.ShellQuoteArgs(cmd)) |
|
1106 |
AssertEqual(result_output.strip(), constants.INSTST_USERDOWN) |
|
1107 |
|
|
1108 |
# Fail to bring instance status to 'running' |
|
1109 |
AssertCommand(["gnt-instance", "start", instance.name], fail=True) |
|
1110 |
|
|
1111 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1112 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1113 |
utils.ShellQuoteArgs(cmd)) |
|
1114 |
AssertEqual(result_output.strip(), constants.INSTST_USERDOWN) |
|
1115 |
|
|
1116 |
# Bring instance status to 'ADMIN_down' |
|
1117 |
AssertCommand(["gnt-instance", "shutdown", instance.name]) |
|
1118 |
|
|
1119 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1120 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1121 |
utils.ShellQuoteArgs(cmd)) |
|
1122 |
AssertEqual(result_output.strip(), constants.INSTST_ADMINDOWN) |
|
1123 |
|
|
1124 |
# Bring instance status to 'running' |
|
1125 |
AssertCommand(["gnt-instance", "start", instance.name]) |
|
1126 |
|
|
1127 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1128 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1129 |
utils.ShellQuoteArgs(cmd)) |
|
1130 |
AssertEqual(result_output.strip(), constants.INSTST_RUNNING) |
|
1131 |
|
|
1132 |
# Bring instance status to 'ADMIN_down' forcibly |
|
1133 |
AssertCommand(["gnt-instance", "shutdown", "-f", instance.name]) |
|
1134 |
|
|
1135 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1136 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1137 |
utils.ShellQuoteArgs(cmd)) |
|
1138 |
AssertEqual(result_output.strip(), constants.INSTST_ADMINDOWN) |
|
1139 |
|
|
1140 |
# Bring instance status to 'running' |
|
1141 |
AssertCommand(["gnt-instance", "start", instance.name]) |
|
1142 |
|
|
1143 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name] |
|
1144 |
result_output = qa_utils.GetCommandOutput(master.primary, |
|
1145 |
utils.ShellQuoteArgs(cmd)) |
|
1146 |
AssertEqual(result_output.strip(), constants.INSTST_RUNNING) |
|
1147 |
|
|
1148 |
|
|
1149 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) |
|
1150 |
def _TestInstanceUserDownXen(instance, master): |
|
1151 |
primary = _GetInstanceField(instance.name, "pnode") |
|
1152 |
fn = lambda: AssertCommand(["xm", "shutdown", "-w", instance.name], |
|
1153 |
fail=False, node=primary) |
|
1154 |
_TestInstanceUserDown(instance, master, fn) |
|
1155 |
|
|
1156 |
|
|
1157 |
# FIXME: User shutdown is not implemented for KVM yet |
|
1158 |
# |
|
1159 |
# @InstanceCheck(INST_UP, INST_UP, FIRST_ARG) |
|
1160 |
# def _TestInstanceUserDownKvm(instance, master): |
|
1161 |
# fn = lambda: hv_kvm.KVMHypervisor._StopInstance(None, True, instance.name) |
|
1162 |
# _TestInstanceUserDown(instance, master, fn) |
|
1163 |
# |
|
1164 |
def _TestInstanceUserDownKvm(_1, _2): |
|
1165 |
pass |
|
1166 |
|
|
1167 |
|
|
1168 |
def TestInstanceUserDown(instance, master): |
|
1169 |
"""Tests user shutdown""" |
|
1170 |
enabled_hypervisors = qa_config.GetEnabledHypervisors() |
|
1171 |
|
|
1172 |
for (hv, fn) in [(constants.HT_XEN_PVM, _TestInstanceUserDownXen), |
|
1173 |
(constants.HT_XEN_HVM, _TestInstanceUserDownXen), |
|
1174 |
(constants.HT_KVM, _TestInstanceUserDownKvm)]: |
|
1175 |
if hv in enabled_hypervisors: |
|
1176 |
fn(instance, master) |
|
1177 |
else: |
|
1178 |
print "%s hypervisor is not enabled, skipping test for this hypervisor" \ |
|
1179 |
% hv |
|
1180 |
|
|
1181 |
|
|
1097 | 1182 |
available_instance_tests = [ |
1098 | 1183 |
("instance-add-plain-disk", constants.DT_PLAIN, |
1099 | 1184 |
TestInstanceAddWithPlainDisk, 1), |
Also available in: Unified diff