Revision 5d831182
b/qa/ganeti-qa.py | ||
---|---|---|
208 | 208 |
finally: |
209 | 209 |
qa_config.ReleaseNode(expnode) |
210 | 210 |
|
211 |
if (qa_rapi.Enabled() and |
|
212 |
qa_config.TestEnabled("inter-cluster-instance-move")): |
|
213 |
newinst = qa_config.AcquireInstance() |
|
214 |
try: |
|
215 |
pnode2 = qa_config.AcquireNode(exclude=pnode) |
|
216 |
try: |
|
217 |
RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst, |
|
218 |
pnode2, pnode) |
|
219 |
finally: |
|
220 |
qa_config.ReleaseNode(pnode2) |
|
221 |
finally: |
|
222 |
qa_config.ReleaseInstance(newinst) |
|
223 |
|
|
211 | 224 |
|
212 | 225 |
def RunDaemonTests(instance, pnode): |
213 | 226 |
"""Test the ganeti-watcher script. |
b/qa/qa-sample.json | ||
---|---|---|
87 | 87 |
"# Disabled by default because it takes rather long": null, |
88 | 88 |
"instance-replace-disks": false, |
89 | 89 |
|
90 |
"# Whether to test the tools/move-instance utility": null, |
|
91 |
"inter-cluster-instance-move": false, |
|
92 |
|
|
90 | 93 |
"# Make sure not to include the disk(s) required for Dom0 to be": null, |
91 | 94 |
"# included in the volume group used for instances. Otherwise": null, |
92 | 95 |
"# whole system may stop working until restarted.": null, |
b/qa/qa_rapi.py | ||
---|---|---|
39 | 39 |
import qa_error |
40 | 40 |
|
41 | 41 |
from qa_utils import (AssertEqual, AssertNotEqual, AssertIn, AssertMatch, |
42 |
StartSSH)
|
|
42 |
StartLocalCommand)
|
|
43 | 43 |
|
44 | 44 |
|
45 | 45 |
_rapi_ca = None |
46 | 46 |
_rapi_client = None |
47 |
_rapi_username = None |
|
48 |
_rapi_password = None |
|
47 | 49 |
|
48 | 50 |
|
49 | 51 |
def Setup(username, password): |
... | ... | |
52 | 54 |
""" |
53 | 55 |
global _rapi_ca |
54 | 56 |
global _rapi_client |
57 |
global _rapi_username |
|
58 |
global _rapi_password |
|
59 |
|
|
60 |
_rapi_username = username |
|
61 |
_rapi_password = password |
|
55 | 62 |
|
56 | 63 |
master = qa_config.GetMasterNode() |
57 | 64 |
|
... | ... | |
332 | 339 |
_WaitForRapiJob(job_id) |
333 | 340 |
|
334 | 341 |
qa_config.ReleaseInstance(instance) |
342 |
|
|
343 |
|
|
344 |
def TestInterClusterInstanceMove(src_instance, dest_instance, pnode, snode): |
|
345 |
"""Test tools/move-instance""" |
|
346 |
master = qa_config.GetMasterNode() |
|
347 |
|
|
348 |
rapi_pw_file = tempfile.NamedTemporaryFile() |
|
349 |
rapi_pw_file.write(_rapi_password) |
|
350 |
rapi_pw_file.flush() |
|
351 |
|
|
352 |
# TODO: Run some instance tests before moving back |
|
353 |
for srcname, destname in [(src_instance["name"], dest_instance["name"]), |
|
354 |
(dest_instance["name"], src_instance["name"])]: |
|
355 |
cmd = [ |
|
356 |
"../tools/move-instance", |
|
357 |
"--verbose", |
|
358 |
"--src-ca-file=%s" % _rapi_ca.name, |
|
359 |
"--src-username=%s" % _rapi_username, |
|
360 |
"--src-password-file=%s" % rapi_pw_file.name, |
|
361 |
"--dest-instance-name=%s" % destname, |
|
362 |
"--dest-primary-node=%s" % pnode["primary"], |
|
363 |
"--dest-secondary-node=%s" % snode["primary"], |
|
364 |
|
|
365 |
master["primary"], |
|
366 |
master["primary"], |
|
367 |
srcname, |
|
368 |
] |
|
369 |
|
|
370 |
AssertEqual(StartLocalCommand(cmd).wait(), 0) |
b/qa/qa_utils.py | ||
---|---|---|
122 | 122 |
args.append(node) |
123 | 123 |
args.append(cmd) |
124 | 124 |
|
125 |
print 'SSH:', utils.ShellQuoteArgs(args) |
|
126 |
|
|
127 | 125 |
return args |
128 | 126 |
|
129 | 127 |
|
128 |
def StartLocalCommand(cmd, **kwargs): |
|
129 |
"""Starts a local command. |
|
130 |
|
|
131 |
""" |
|
132 |
print "Command: %s" % utils.ShellQuoteArgs(cmd) |
|
133 |
return subprocess.Popen(cmd, shell=False, **kwargs) |
|
134 |
|
|
135 |
|
|
130 | 136 |
def StartSSH(node, cmd, strict=True): |
131 | 137 |
"""Starts SSH. |
132 | 138 |
|
133 | 139 |
""" |
134 |
return subprocess.Popen(GetSSHCommand(node, cmd, strict=strict), |
|
135 |
shell=False) |
|
140 |
return StartLocalCommand(GetSSHCommand(node, cmd, strict=strict)) |
|
136 | 141 |
|
137 | 142 |
|
138 | 143 |
def GetCommandOutput(node, cmd): |
139 | 144 |
"""Returns the output of a command executed on the given node. |
140 | 145 |
|
141 | 146 |
""" |
142 |
p = subprocess.Popen(GetSSHCommand(node, cmd), |
|
143 |
shell=False, stdout=subprocess.PIPE) |
|
147 |
p = StartLocalCommand(GetSSHCommand(node, cmd), stdout=subprocess.PIPE) |
|
144 | 148 |
AssertEqual(p.wait(), 0) |
145 | 149 |
return p.stdout.read() |
146 | 150 |
|
Also available in: Unified diff