35 |
35 |
import qa_error
|
36 |
36 |
|
37 |
37 |
from qa_utils import AssertIn, AssertCommand, AssertEqual
|
|
38 |
from qa_utils import InstanceCheck, INST_DOWN, INST_UP, FIRST_ARG, RETURN_VALUE
|
38 |
39 |
|
39 |
40 |
|
40 |
41 |
def _GetDiskStatePath(disk):
|
... | ... | |
72 |
73 |
raise
|
73 |
74 |
|
74 |
75 |
|
|
76 |
@InstanceCheck(None, INST_UP, RETURN_VALUE)
|
75 |
77 |
def TestInstanceAddWithPlainDisk(node):
|
76 |
78 |
"""gnt-instance add -t plain"""
|
77 |
79 |
return _DiskTest(node["primary"], "plain")
|
78 |
80 |
|
79 |
81 |
|
|
82 |
@InstanceCheck(None, INST_UP, RETURN_VALUE)
|
80 |
83 |
def TestInstanceAddWithDrbdDisk(node, node2):
|
81 |
84 |
"""gnt-instance add -t drbd"""
|
82 |
85 |
return _DiskTest("%s:%s" % (node["primary"], node2["primary"]),
|
83 |
86 |
"drbd")
|
84 |
87 |
|
85 |
88 |
|
|
89 |
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
|
86 |
90 |
def TestInstanceRemove(instance):
|
87 |
91 |
"""gnt-instance remove"""
|
88 |
92 |
AssertCommand(["gnt-instance", "remove", "-f", instance["name"]])
|
... | ... | |
90 |
94 |
qa_config.ReleaseInstance(instance)
|
91 |
95 |
|
92 |
96 |
|
|
97 |
@InstanceCheck(INST_DOWN, INST_UP, FIRST_ARG)
|
93 |
98 |
def TestInstanceStartup(instance):
|
94 |
99 |
"""gnt-instance startup"""
|
95 |
100 |
AssertCommand(["gnt-instance", "startup", instance["name"]])
|
96 |
101 |
|
97 |
102 |
|
|
103 |
@InstanceCheck(INST_UP, INST_DOWN, FIRST_ARG)
|
98 |
104 |
def TestInstanceShutdown(instance):
|
99 |
105 |
"""gnt-instance shutdown"""
|
100 |
106 |
AssertCommand(["gnt-instance", "shutdown", instance["name"]])
|
101 |
107 |
|
102 |
108 |
|
|
109 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
103 |
110 |
def TestInstanceReboot(instance):
|
104 |
111 |
"""gnt-instance reboot"""
|
105 |
112 |
options = qa_config.get("options", {})
|
... | ... | |
109 |
116 |
AssertCommand(["gnt-instance", "reboot", "--type=%s" % rtype, name])
|
110 |
117 |
|
111 |
118 |
AssertCommand(["gnt-instance", "shutdown", name])
|
|
119 |
qa_utils.RunInstanceCheck(instance, False)
|
112 |
120 |
AssertCommand(["gnt-instance", "reboot", name])
|
113 |
121 |
|
114 |
122 |
master = qa_config.GetMasterNode()
|
... | ... | |
118 |
126 |
AssertEqual(result_output.strip(), constants.INSTST_RUNNING)
|
119 |
127 |
|
120 |
128 |
|
|
129 |
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
|
121 |
130 |
def TestInstanceReinstall(instance):
|
122 |
131 |
"""gnt-instance reinstall"""
|
123 |
132 |
AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
|
... | ... | |
147 |
156 |
_ReadSsconfInstanceList())
|
148 |
157 |
|
149 |
158 |
|
|
159 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
150 |
160 |
def TestInstanceRenameAndBack(rename_source, rename_target):
|
151 |
161 |
"""gnt-instance rename
|
152 |
162 |
|
... | ... | |
155 |
165 |
|
156 |
166 |
"""
|
157 |
167 |
_CheckSsconfInstanceList(rename_source)
|
|
168 |
|
158 |
169 |
# first do a rename to a different actual name, expecting it to fail
|
159 |
170 |
qa_utils.AddToEtcHosts(["meeeeh-not-exists", rename_target])
|
160 |
171 |
try:
|
... | ... | |
163 |
174 |
_CheckSsconfInstanceList(rename_source)
|
164 |
175 |
finally:
|
165 |
176 |
qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
|
|
177 |
|
166 |
178 |
# and now rename instance to rename_target...
|
167 |
179 |
AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
|
168 |
180 |
_CheckSsconfInstanceList(rename_target)
|
|
181 |
qa_utils.RunInstanceCheck(rename_source, False)
|
|
182 |
qa_utils.RunInstanceCheck(rename_target, True)
|
|
183 |
|
169 |
184 |
# and back
|
170 |
185 |
AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
|
171 |
186 |
_CheckSsconfInstanceList(rename_source)
|
|
187 |
qa_utils.RunInstanceCheck(rename_target, False)
|
172 |
188 |
|
173 |
189 |
|
|
190 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
174 |
191 |
def TestInstanceFailover(instance):
|
175 |
192 |
"""gnt-instance failover"""
|
176 |
193 |
cmd = ["gnt-instance", "failover", "--force", instance["name"]]
|
|
194 |
|
177 |
195 |
# failover ...
|
178 |
196 |
AssertCommand(cmd)
|
|
197 |
qa_utils.RunInstanceCheck(instance, True)
|
|
198 |
|
179 |
199 |
# ... and back
|
180 |
200 |
AssertCommand(cmd)
|
181 |
201 |
|
182 |
202 |
|
|
203 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
183 |
204 |
def TestInstanceMigrate(instance):
|
184 |
205 |
"""gnt-instance migrate"""
|
185 |
206 |
cmd = ["gnt-instance", "migrate", "--force", instance["name"]]
|
|
207 |
|
186 |
208 |
# migrate ...
|
187 |
209 |
AssertCommand(cmd)
|
|
210 |
qa_utils.RunInstanceCheck(instance, True)
|
|
211 |
|
188 |
212 |
# ... and back
|
189 |
213 |
AssertCommand(cmd)
|
|
214 |
|
|
215 |
# TODO: Split into multiple tests
|
190 |
216 |
AssertCommand(["gnt-instance", "shutdown", instance["name"]])
|
|
217 |
qa_utils.RunInstanceCheck(instance, False)
|
191 |
218 |
AssertCommand(cmd, fail=True)
|
192 |
219 |
AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
|
193 |
220 |
instance["name"]])
|
194 |
221 |
AssertCommand(["gnt-instance", "start", instance["name"]])
|
195 |
222 |
AssertCommand(cmd)
|
|
223 |
qa_utils.RunInstanceCheck(instance, True)
|
|
224 |
|
196 |
225 |
AssertCommand(["gnt-instance", "modify", "-B",
|
197 |
226 |
("%s=%s" %
|
198 |
227 |
(constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)),
|
199 |
228 |
instance["name"]])
|
|
229 |
|
200 |
230 |
AssertCommand(cmd, fail=True)
|
|
231 |
qa_utils.RunInstanceCheck(instance, True)
|
201 |
232 |
AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
|
202 |
233 |
instance["name"]])
|
|
234 |
|
|
235 |
# TODO: Verify whether the default value is restored here (not hardcoded)
|
203 |
236 |
AssertCommand(["gnt-instance", "modify", "-B",
|
204 |
237 |
("%s=%s" %
|
205 |
238 |
(constants.BE_ALWAYS_FAILOVER, constants.VALUE_FALSE)),
|
206 |
239 |
instance["name"]])
|
|
240 |
|
207 |
241 |
AssertCommand(cmd)
|
|
242 |
qa_utils.RunInstanceCheck(instance, True)
|
208 |
243 |
|
209 |
244 |
|
210 |
245 |
def TestInstanceInfo(instance):
|
... | ... | |
212 |
247 |
AssertCommand(["gnt-instance", "info", instance["name"]])
|
213 |
248 |
|
214 |
249 |
|
|
250 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
215 |
251 |
def TestInstanceModify(instance):
|
216 |
252 |
"""gnt-instance modify"""
|
217 |
253 |
# Assume /sbin/init exists on all systems
|
... | ... | |
257 |
293 |
AssertCommand(["gnt-instance", "modify", arg, instance["name"]], fail=True)
|
258 |
294 |
|
259 |
295 |
|
|
296 |
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
|
260 |
297 |
def TestInstanceStoppedModify(instance):
|
261 |
298 |
"""gnt-instance modify (stopped instance)"""
|
262 |
299 |
name = instance["name"]
|
... | ... | |
271 |
308 |
AssertCommand(["gnt-instance", "modify", "--online", name])
|
272 |
309 |
|
273 |
310 |
|
|
311 |
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
|
274 |
312 |
def TestInstanceConvertDisk(instance, snode):
|
275 |
313 |
"""gnt-instance modify -t"""
|
276 |
314 |
name = instance["name"]
|
... | ... | |
279 |
317 |
"-n", snode["primary"], name])
|
280 |
318 |
|
281 |
319 |
|
|
320 |
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
|
282 |
321 |
def TestInstanceGrowDisk(instance):
|
283 |
322 |
"""gnt-instance grow-disk"""
|
284 |
323 |
name = instance["name"]
|
... | ... | |
311 |
350 |
qa_utils.GenericQueryFieldsTest("gnt-instance", query.INSTANCE_FIELDS.keys())
|
312 |
351 |
|
313 |
352 |
|
|
353 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
314 |
354 |
def TestInstanceConsole(instance):
|
315 |
355 |
"""gnt-instance console"""
|
316 |
356 |
AssertCommand(["gnt-instance", "console", "--show-cmd", instance["name"]])
|
317 |
357 |
|
318 |
358 |
|
|
359 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
319 |
360 |
def TestReplaceDisks(instance, pnode, snode, othernode):
|
320 |
361 |
"""gnt-instance replace-disks"""
|
321 |
362 |
# pylint: disable=W0613
|
... | ... | |
344 |
385 |
AssertCommand(["gnt-instance", "start", instance["name"]])
|
345 |
386 |
|
346 |
387 |
|
|
388 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
347 |
389 |
def TestInstanceExport(instance, node):
|
348 |
390 |
"""gnt-backup export -n ..."""
|
349 |
391 |
name = instance["name"]
|
... | ... | |
351 |
393 |
return qa_utils.ResolveInstanceName(name)
|
352 |
394 |
|
353 |
395 |
|
|
396 |
@InstanceCheck(INST_UP, None, FIRST_ARG)
|
354 |
397 |
def TestInstanceExportWithRemove(instance, node):
|
355 |
398 |
"""gnt-backup export --remove-instance"""
|
356 |
399 |
AssertCommand(["gnt-backup", "export", "-n", node["primary"],
|
357 |
400 |
"--remove-instance", instance["name"]])
|
358 |
401 |
|
359 |
402 |
|
|
403 |
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
|
360 |
404 |
def TestInstanceExportNoTarget(instance):
|
361 |
405 |
"""gnt-backup export (without target node, should fail)"""
|
362 |
406 |
AssertCommand(["gnt-backup", "export", instance["name"]], fail=True)
|
363 |
407 |
|
364 |
408 |
|
365 |
|
def TestInstanceImport(node, newinst, expnode, name):
|
|
409 |
@InstanceCheck(None, INST_UP, FIRST_ARG)
|
|
410 |
def TestInstanceImport(newinst, node, expnode, name):
|
366 |
411 |
"""gnt-backup import"""
|
367 |
412 |
cmd = (["gnt-backup", "import",
|
368 |
413 |
"--disk-template=plain",
|