root / qa / ganeti-qa.py @ efd58d99
History | View | Annotate | Download (20.7 kB)
1 |
#!/usr/bin/python -u
|
---|---|
2 |
#
|
3 |
|
4 |
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
|
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU General Public License as published by
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
9 |
# (at your option) any later version.
|
10 |
#
|
11 |
# This program is distributed in the hope that it will be useful, but
|
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
# General Public License for more details.
|
15 |
#
|
16 |
# You should have received a copy of the GNU General Public License
|
17 |
# along with this program; if not, write to the Free Software
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
# 02110-1301, USA.
|
20 |
|
21 |
|
22 |
"""Script for doing QA on Ganeti.
|
23 |
|
24 |
"""
|
25 |
|
26 |
# pylint: disable=C0103
|
27 |
# due to invalid name
|
28 |
|
29 |
import sys |
30 |
import datetime |
31 |
import optparse |
32 |
|
33 |
import qa_cluster |
34 |
import qa_config |
35 |
import qa_daemon |
36 |
import qa_env |
37 |
import qa_error |
38 |
import qa_group |
39 |
import qa_instance |
40 |
import qa_node |
41 |
import qa_os |
42 |
import qa_job |
43 |
import qa_rapi |
44 |
import qa_tags |
45 |
import qa_utils |
46 |
|
47 |
from ganeti import utils |
48 |
from ganeti import rapi # pylint: disable=W0611 |
49 |
from ganeti import constants |
50 |
|
51 |
import ganeti.rapi.client # pylint: disable=W0611 |
52 |
from ganeti.rapi.client import UsesRapiClient |
53 |
|
54 |
|
55 |
def _FormatHeader(line, end=72): |
56 |
"""Fill a line up to the end column.
|
57 |
|
58 |
"""
|
59 |
line = "---- " + line + " " |
60 |
line += "-" * (end - len(line)) |
61 |
line = line.rstrip() |
62 |
return line
|
63 |
|
64 |
|
65 |
def _DescriptionOf(fn): |
66 |
"""Computes the description of an item.
|
67 |
|
68 |
"""
|
69 |
if fn.__doc__:
|
70 |
desc = fn.__doc__.splitlines()[0].strip()
|
71 |
else:
|
72 |
desc = "%r" % fn
|
73 |
|
74 |
return desc.rstrip(".") |
75 |
|
76 |
|
77 |
def RunTest(fn, *args, **kwargs): |
78 |
"""Runs a test after printing a header.
|
79 |
|
80 |
"""
|
81 |
|
82 |
tstart = datetime.datetime.now() |
83 |
|
84 |
desc = _DescriptionOf(fn) |
85 |
|
86 |
print
|
87 |
print _FormatHeader("%s start %s" % (tstart, desc)) |
88 |
|
89 |
try:
|
90 |
retval = fn(*args, **kwargs) |
91 |
return retval
|
92 |
finally:
|
93 |
tstop = datetime.datetime.now() |
94 |
tdelta = tstop - tstart |
95 |
print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc)) |
96 |
|
97 |
|
98 |
def RunTestIf(testnames, fn, *args, **kwargs): |
99 |
"""Runs a test conditionally.
|
100 |
|
101 |
@param testnames: either a single test name in the configuration
|
102 |
file, or a list of testnames (which will be AND-ed together)
|
103 |
|
104 |
"""
|
105 |
if qa_config.TestEnabled(testnames):
|
106 |
RunTest(fn, *args, **kwargs) |
107 |
else:
|
108 |
tstart = datetime.datetime.now() |
109 |
desc = _DescriptionOf(fn) |
110 |
print _FormatHeader("%s skipping %s, test(s) %s disabled" % |
111 |
(tstart, desc, testnames)) |
112 |
|
113 |
|
114 |
def RunEnvTests(): |
115 |
"""Run several environment tests.
|
116 |
|
117 |
"""
|
118 |
RunTestIf("env", qa_env.TestSshConnection)
|
119 |
RunTestIf("env", qa_env.TestIcmpPing)
|
120 |
RunTestIf("env", qa_env.TestGanetiCommands)
|
121 |
|
122 |
|
123 |
def SetupCluster(rapi_user, rapi_secret): |
124 |
"""Initializes the cluster.
|
125 |
|
126 |
@param rapi_user: Login user for RAPI
|
127 |
@param rapi_secret: Login secret for RAPI
|
128 |
|
129 |
"""
|
130 |
RunTestIf("create-cluster", qa_cluster.TestClusterInit,
|
131 |
rapi_user, rapi_secret) |
132 |
|
133 |
# Test on empty cluster
|
134 |
RunTestIf("node-list", qa_node.TestNodeList)
|
135 |
RunTestIf("instance-list", qa_instance.TestInstanceList)
|
136 |
RunTestIf("job-list", qa_job.TestJobList)
|
137 |
|
138 |
RunTestIf("create-cluster", qa_node.TestNodeAddAll)
|
139 |
if not qa_config.TestEnabled("create-cluster"): |
140 |
# consider the nodes are already there
|
141 |
qa_node.MarkNodeAddedAll() |
142 |
|
143 |
RunTestIf("test-jobqueue", qa_cluster.TestJobqueue)
|
144 |
|
145 |
# enable the watcher (unconditionally)
|
146 |
RunTest(qa_daemon.TestResumeWatcher) |
147 |
|
148 |
RunTestIf("node-list", qa_node.TestNodeList)
|
149 |
|
150 |
# Test listing fields
|
151 |
RunTestIf("node-list", qa_node.TestNodeListFields)
|
152 |
RunTestIf("instance-list", qa_instance.TestInstanceListFields)
|
153 |
RunTestIf("job-list", qa_job.TestJobListFields)
|
154 |
RunTestIf("instance-export", qa_instance.TestBackupListFields)
|
155 |
|
156 |
RunTestIf("node-info", qa_node.TestNodeInfo)
|
157 |
|
158 |
|
159 |
def RunClusterTests(): |
160 |
"""Runs tests related to gnt-cluster.
|
161 |
|
162 |
"""
|
163 |
for test, fn in [ |
164 |
("create-cluster", qa_cluster.TestClusterInitDisk),
|
165 |
("cluster-renew-crypto", qa_cluster.TestClusterRenewCrypto),
|
166 |
("cluster-verify", qa_cluster.TestClusterVerify),
|
167 |
("cluster-reserved-lvs", qa_cluster.TestClusterReservedLvs),
|
168 |
# TODO: add more cluster modify tests
|
169 |
("cluster-modify", qa_cluster.TestClusterModifyEmpty),
|
170 |
("cluster-modify", qa_cluster.TestClusterModifyBe),
|
171 |
("cluster-modify", qa_cluster.TestClusterModifyDisk),
|
172 |
("cluster-rename", qa_cluster.TestClusterRename),
|
173 |
("cluster-info", qa_cluster.TestClusterVersion),
|
174 |
("cluster-info", qa_cluster.TestClusterInfo),
|
175 |
("cluster-info", qa_cluster.TestClusterGetmaster),
|
176 |
("cluster-redist-conf", qa_cluster.TestClusterRedistConf),
|
177 |
("cluster-copyfile", qa_cluster.TestClusterCopyfile),
|
178 |
("cluster-command", qa_cluster.TestClusterCommand),
|
179 |
("cluster-burnin", qa_cluster.TestClusterBurnin),
|
180 |
("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
|
181 |
("cluster-master-failover",
|
182 |
qa_cluster.TestClusterMasterFailoverWithDrainedQueue), |
183 |
("cluster-oob", qa_cluster.TestClusterOob),
|
184 |
("rapi", qa_rapi.TestVersion),
|
185 |
("rapi", qa_rapi.TestEmptyCluster),
|
186 |
("rapi", qa_rapi.TestRapiQuery),
|
187 |
]: |
188 |
RunTestIf(test, fn) |
189 |
|
190 |
|
191 |
def RunRepairDiskSizes(): |
192 |
"""Run the repair disk-sizes test.
|
193 |
|
194 |
"""
|
195 |
RunTestIf("cluster-repair-disk-sizes", qa_cluster.TestClusterRepairDiskSizes)
|
196 |
|
197 |
|
198 |
def RunOsTests(): |
199 |
"""Runs all tests related to gnt-os.
|
200 |
|
201 |
"""
|
202 |
if qa_config.TestEnabled("rapi"): |
203 |
rapi_getos = qa_rapi.GetOperatingSystems |
204 |
else:
|
205 |
rapi_getos = None
|
206 |
|
207 |
for fn in [ |
208 |
qa_os.TestOsList, |
209 |
qa_os.TestOsDiagnose, |
210 |
]: |
211 |
RunTestIf("os", fn)
|
212 |
|
213 |
for fn in [ |
214 |
qa_os.TestOsValid, |
215 |
qa_os.TestOsInvalid, |
216 |
qa_os.TestOsPartiallyValid, |
217 |
]: |
218 |
RunTestIf("os", fn, rapi_getos)
|
219 |
|
220 |
for fn in [ |
221 |
qa_os.TestOsModifyValid, |
222 |
qa_os.TestOsModifyInvalid, |
223 |
qa_os.TestOsStatesNonExisting, |
224 |
]: |
225 |
RunTestIf("os", fn)
|
226 |
|
227 |
|
228 |
def RunCommonInstanceTests(instance): |
229 |
"""Runs a few tests that are common to all disk types.
|
230 |
|
231 |
"""
|
232 |
RunTestIf("instance-shutdown", qa_instance.TestInstanceShutdown, instance)
|
233 |
RunTestIf(["instance-shutdown", "instance-console", "rapi"], |
234 |
qa_rapi.TestRapiStoppedInstanceConsole, instance) |
235 |
RunTestIf(["instance-shutdown", "instance-modify"], |
236 |
qa_instance.TestInstanceStoppedModify, instance) |
237 |
RunTestIf("instance-shutdown", qa_instance.TestInstanceStartup, instance)
|
238 |
|
239 |
# Test shutdown/start via RAPI
|
240 |
RunTestIf(["instance-shutdown", "rapi"], |
241 |
qa_rapi.TestRapiInstanceShutdown, instance) |
242 |
RunTestIf(["instance-shutdown", "rapi"], |
243 |
qa_rapi.TestRapiInstanceStartup, instance) |
244 |
|
245 |
RunTestIf("instance-list", qa_instance.TestInstanceList)
|
246 |
|
247 |
RunTestIf("instance-info", qa_instance.TestInstanceInfo, instance)
|
248 |
|
249 |
RunTestIf("instance-modify", qa_instance.TestInstanceModify, instance)
|
250 |
RunTestIf(["instance-modify", "rapi"], |
251 |
qa_rapi.TestRapiInstanceModify, instance) |
252 |
|
253 |
RunTestIf("instance-console", qa_instance.TestInstanceConsole, instance)
|
254 |
RunTestIf(["instance-console", "rapi"], |
255 |
qa_rapi.TestRapiInstanceConsole, instance) |
256 |
|
257 |
DOWN_TESTS = qa_config.Either([ |
258 |
"instance-reinstall",
|
259 |
"instance-rename",
|
260 |
"instance-grow-disk",
|
261 |
]) |
262 |
|
263 |
# shutdown instance for any 'down' tests
|
264 |
RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance) |
265 |
|
266 |
# now run the 'down' state tests
|
267 |
RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
|
268 |
RunTestIf(["instance-reinstall", "rapi"], |
269 |
qa_rapi.TestRapiInstanceReinstall, instance) |
270 |
|
271 |
if qa_config.TestEnabled("instance-rename"): |
272 |
tgt_instance = qa_config.AcquireInstance() |
273 |
try:
|
274 |
rename_source = instance["name"]
|
275 |
rename_target = tgt_instance["name"]
|
276 |
# perform instance rename to the same name
|
277 |
RunTest(qa_instance.TestInstanceRenameAndBack, |
278 |
rename_source, rename_source) |
279 |
RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
280 |
rename_source, rename_source) |
281 |
if rename_target is not None: |
282 |
# perform instance rename to a different name, if we have one configured
|
283 |
RunTest(qa_instance.TestInstanceRenameAndBack, |
284 |
rename_source, rename_target) |
285 |
RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
|
286 |
rename_source, rename_target) |
287 |
finally:
|
288 |
qa_config.ReleaseInstance(tgt_instance) |
289 |
|
290 |
RunTestIf(["instance-grow-disk"], qa_instance.TestInstanceGrowDisk, instance)
|
291 |
|
292 |
# and now start the instance again
|
293 |
RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance) |
294 |
|
295 |
RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
|
296 |
|
297 |
RunTestIf("tags", qa_tags.TestInstanceTags, instance)
|
298 |
|
299 |
RunTestIf("cluster-verify", qa_cluster.TestClusterVerify)
|
300 |
|
301 |
RunTestIf("rapi", qa_rapi.TestInstance, instance)
|
302 |
|
303 |
# Lists instances, too
|
304 |
RunTestIf("node-list", qa_node.TestNodeList)
|
305 |
|
306 |
# Some jobs have been run, let's test listing them
|
307 |
RunTestIf("job-list", qa_job.TestJobList)
|
308 |
|
309 |
|
310 |
def RunCommonNodeTests(): |
311 |
"""Run a few common node tests.
|
312 |
|
313 |
"""
|
314 |
RunTestIf("node-volumes", qa_node.TestNodeVolumes)
|
315 |
RunTestIf("node-storage", qa_node.TestNodeStorage)
|
316 |
RunTestIf("node-oob", qa_node.TestOutOfBand)
|
317 |
|
318 |
|
319 |
def RunGroupListTests(): |
320 |
"""Run tests for listing node groups.
|
321 |
|
322 |
"""
|
323 |
RunTestIf("group-list", qa_group.TestGroupList)
|
324 |
RunTestIf("group-list", qa_group.TestGroupListFields)
|
325 |
|
326 |
|
327 |
def RunGroupRwTests(): |
328 |
"""Run tests for adding/removing/renaming groups.
|
329 |
|
330 |
"""
|
331 |
RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
|
332 |
RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
|
333 |
RunTestIf("group-rwops", qa_group.TestGroupModify)
|
334 |
RunTestIf(["group-rwops", "rapi"], qa_rapi.TestRapiNodeGroups) |
335 |
RunTestIf(["group-rwops", "tags"], qa_tags.TestGroupTags, |
336 |
qa_group.GetDefaultGroup()) |
337 |
|
338 |
|
339 |
def RunExportImportTests(instance, pnode, snode): |
340 |
"""Tries to export and import the instance.
|
341 |
|
342 |
@param pnode: current primary node of the instance
|
343 |
@param snode: current secondary node of the instance, if any,
|
344 |
otherwise None
|
345 |
|
346 |
"""
|
347 |
if qa_config.TestEnabled("instance-export"): |
348 |
RunTest(qa_instance.TestInstanceExportNoTarget, instance) |
349 |
|
350 |
expnode = qa_config.AcquireNode(exclude=pnode) |
351 |
try:
|
352 |
name = RunTest(qa_instance.TestInstanceExport, instance, expnode) |
353 |
|
354 |
RunTest(qa_instance.TestBackupList, expnode) |
355 |
|
356 |
if qa_config.TestEnabled("instance-import"): |
357 |
newinst = qa_config.AcquireInstance() |
358 |
try:
|
359 |
RunTest(qa_instance.TestInstanceImport, newinst, pnode, |
360 |
expnode, name) |
361 |
# Check if starting the instance works
|
362 |
RunTest(qa_instance.TestInstanceStartup, newinst) |
363 |
RunTest(qa_instance.TestInstanceRemove, newinst) |
364 |
finally:
|
365 |
qa_config.ReleaseInstance(newinst) |
366 |
finally:
|
367 |
qa_config.ReleaseNode(expnode) |
368 |
|
369 |
if qa_config.TestEnabled(["rapi", "inter-cluster-instance-move"]): |
370 |
newinst = qa_config.AcquireInstance() |
371 |
try:
|
372 |
if snode is None: |
373 |
excl = [pnode] |
374 |
else:
|
375 |
excl = [pnode, snode] |
376 |
tnode = qa_config.AcquireNode(exclude=excl) |
377 |
try:
|
378 |
RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst, |
379 |
pnode, snode, tnode) |
380 |
finally:
|
381 |
qa_config.ReleaseNode(tnode) |
382 |
finally:
|
383 |
qa_config.ReleaseInstance(newinst) |
384 |
|
385 |
|
386 |
def RunDaemonTests(instance): |
387 |
"""Test the ganeti-watcher script.
|
388 |
|
389 |
"""
|
390 |
RunTest(qa_daemon.TestPauseWatcher) |
391 |
|
392 |
RunTestIf("instance-automatic-restart",
|
393 |
qa_daemon.TestInstanceAutomaticRestart, instance) |
394 |
RunTestIf("instance-consecutive-failures",
|
395 |
qa_daemon.TestInstanceConsecutiveFailures, instance) |
396 |
|
397 |
RunTest(qa_daemon.TestResumeWatcher) |
398 |
|
399 |
|
400 |
def RunSingleHomedHardwareFailureTests(instance, pnode): |
401 |
"""Test hardware failure recovery for single-homed instances.
|
402 |
|
403 |
"""
|
404 |
if qa_config.TestEnabled("instance-recreate-disks"): |
405 |
othernode = qa_config.AcquireNode(exclude=[pnode]) |
406 |
try:
|
407 |
RunTest(qa_instance.TestRecreateDisks, |
408 |
instance, pnode, None, [othernode])
|
409 |
finally:
|
410 |
qa_config.ReleaseNode(othernode) |
411 |
|
412 |
|
413 |
def RunHardwareFailureTests(instance, pnode, snode): |
414 |
"""Test cluster internal hardware failure recovery.
|
415 |
|
416 |
"""
|
417 |
RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance)
|
418 |
RunTestIf(["instance-failover", "rapi"], |
419 |
qa_rapi.TestRapiInstanceFailover, instance) |
420 |
|
421 |
RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance)
|
422 |
RunTestIf(["instance-migrate", "rapi"], |
423 |
qa_rapi.TestRapiInstanceMigrate, instance) |
424 |
|
425 |
if qa_config.TestEnabled("instance-replace-disks"): |
426 |
othernode = qa_config.AcquireNode(exclude=[pnode, snode]) |
427 |
try:
|
428 |
RunTestIf("rapi", qa_rapi.TestRapiInstanceReplaceDisks, instance)
|
429 |
RunTest(qa_instance.TestReplaceDisks, |
430 |
instance, pnode, snode, othernode) |
431 |
finally:
|
432 |
qa_config.ReleaseNode(othernode) |
433 |
|
434 |
if qa_config.TestEnabled("instance-recreate-disks"): |
435 |
othernode1 = qa_config.AcquireNode(exclude=[pnode, snode]) |
436 |
try:
|
437 |
othernode2 = qa_config.AcquireNode(exclude=[pnode, snode, othernode1]) |
438 |
except qa_error.OutOfNodesError:
|
439 |
# Let's reuse one of the nodes if the cluster is not big enough
|
440 |
othernode2 = pnode |
441 |
try:
|
442 |
RunTest(qa_instance.TestRecreateDisks, |
443 |
instance, pnode, snode, [othernode1, othernode2]) |
444 |
finally:
|
445 |
qa_config.ReleaseNode(othernode1) |
446 |
if othernode2 != pnode:
|
447 |
qa_config.ReleaseNode(othernode2) |
448 |
|
449 |
RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, pnode, snode)
|
450 |
|
451 |
RunTestIf("node-failover", qa_node.TestNodeFailover, pnode, snode)
|
452 |
|
453 |
RunTestIf("instance-disk-failure", qa_instance.TestInstanceMasterDiskFailure,
|
454 |
instance, pnode, snode) |
455 |
RunTestIf("instance-disk-failure",
|
456 |
qa_instance.TestInstanceSecondaryDiskFailure, instance, |
457 |
pnode, snode) |
458 |
|
459 |
|
460 |
def RunExclusiveStorageTests(): |
461 |
"""Test exclusive storage."""
|
462 |
if not qa_config.TestEnabled("cluster-exclusive-storage"): |
463 |
return
|
464 |
|
465 |
node = qa_config.AcquireNode() |
466 |
try:
|
467 |
old_es = qa_cluster.TestSetExclStorCluster(False)
|
468 |
qa_cluster.TestExclStorSingleNode(node) |
469 |
|
470 |
qa_cluster.TestSetExclStorCluster(True)
|
471 |
if qa_config.TestEnabled("instance-add-plain-disk"): |
472 |
# Make sure that the cluster doesn't have any pre-existing problem
|
473 |
qa_cluster.AssertClusterVerify() |
474 |
instance1 = qa_instance.TestInstanceAddWithPlainDisk(node) |
475 |
instance2 = qa_instance.TestInstanceAddWithPlainDisk(node) |
476 |
# cluster-verify checks that disks are allocated correctly
|
477 |
qa_cluster.AssertClusterVerify() |
478 |
qa_instance.TestInstanceRemove(instance1) |
479 |
qa_instance.TestInstanceRemove(instance2) |
480 |
if qa_config.TestEnabled("instance-add-drbd-disk"): |
481 |
snode = qa_config.AcquireNode() |
482 |
try:
|
483 |
qa_cluster.TestSetExclStorCluster(False)
|
484 |
instance = qa_instance.TestInstanceAddWithDrbdDisk(node, snode) |
485 |
qa_cluster.TestSetExclStorCluster(True)
|
486 |
exp_err = [constants.CV_EINSTANCEUNSUITABLENODE] |
487 |
qa_cluster.AssertClusterVerify(fail=True, errors=exp_err)
|
488 |
qa_instance.TestInstanceRemove(instance) |
489 |
finally:
|
490 |
qa_config.ReleaseNode(snode) |
491 |
qa_cluster.TestSetExclStorCluster(old_es) |
492 |
finally:
|
493 |
qa_config.ReleaseNode(node) |
494 |
|
495 |
|
496 |
def RunQa(): |
497 |
"""Main QA body.
|
498 |
|
499 |
"""
|
500 |
rapi_user = "ganeti-qa"
|
501 |
rapi_secret = utils.GenerateSecret() |
502 |
|
503 |
RunEnvTests() |
504 |
SetupCluster(rapi_user, rapi_secret) |
505 |
|
506 |
# Load RAPI certificate
|
507 |
qa_rapi.Setup(rapi_user, rapi_secret) |
508 |
|
509 |
RunClusterTests() |
510 |
RunOsTests() |
511 |
|
512 |
RunTestIf("tags", qa_tags.TestClusterTags)
|
513 |
|
514 |
RunCommonNodeTests() |
515 |
RunGroupListTests() |
516 |
RunGroupRwTests() |
517 |
|
518 |
# The master shouldn't be readded or put offline; "delay" needs a non-master
|
519 |
# node to test
|
520 |
pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
521 |
try:
|
522 |
RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
|
523 |
RunTestIf("node-modify", qa_node.TestNodeModify, pnode)
|
524 |
RunTestIf("delay", qa_cluster.TestDelay, pnode)
|
525 |
finally:
|
526 |
qa_config.ReleaseNode(pnode) |
527 |
|
528 |
pnode = qa_config.AcquireNode() |
529 |
try:
|
530 |
RunTestIf("tags", qa_tags.TestNodeTags, pnode)
|
531 |
|
532 |
if qa_rapi.Enabled():
|
533 |
RunTest(qa_rapi.TestNode, pnode) |
534 |
|
535 |
if qa_config.TestEnabled("instance-add-plain-disk"): |
536 |
for use_client in [True, False]: |
537 |
rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode, |
538 |
use_client) |
539 |
if qa_config.TestEnabled("instance-plain-rapi-common-tests"): |
540 |
RunCommonInstanceTests(rapi_instance) |
541 |
RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client) |
542 |
del rapi_instance
|
543 |
|
544 |
if qa_config.TestEnabled("instance-add-plain-disk"): |
545 |
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode) |
546 |
RunCommonInstanceTests(instance) |
547 |
RunGroupListTests() |
548 |
RunTestIf("cluster-epo", qa_cluster.TestClusterEpo)
|
549 |
RunExportImportTests(instance, pnode, None)
|
550 |
RunDaemonTests(instance) |
551 |
RunRepairDiskSizes() |
552 |
RunSingleHomedHardwareFailureTests(instance, pnode) |
553 |
RunTest(qa_instance.TestInstanceRemove, instance) |
554 |
del instance
|
555 |
|
556 |
multinode_tests = [ |
557 |
("instance-add-drbd-disk",
|
558 |
qa_instance.TestInstanceAddWithDrbdDisk), |
559 |
] |
560 |
|
561 |
for name, func in multinode_tests: |
562 |
if qa_config.TestEnabled(name):
|
563 |
snode = qa_config.AcquireNode(exclude=pnode) |
564 |
try:
|
565 |
instance = RunTest(func, pnode, snode) |
566 |
RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, pnode)
|
567 |
RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, snode)
|
568 |
RunCommonInstanceTests(instance) |
569 |
RunGroupListTests() |
570 |
RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
|
571 |
constants.INITIAL_NODE_GROUP_NAME, |
572 |
pnode["primary"], snode["primary"]) |
573 |
if qa_config.TestEnabled("instance-convert-disk"): |
574 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
575 |
RunTest(qa_instance.TestInstanceConvertDisk, instance, snode) |
576 |
RunTest(qa_instance.TestInstanceStartup, instance) |
577 |
RunExportImportTests(instance, pnode, snode) |
578 |
RunHardwareFailureTests(instance, pnode, snode) |
579 |
RunRepairDiskSizes() |
580 |
RunTest(qa_instance.TestInstanceRemove, instance) |
581 |
del instance
|
582 |
finally:
|
583 |
qa_config.ReleaseNode(snode) |
584 |
|
585 |
finally:
|
586 |
qa_config.ReleaseNode(pnode) |
587 |
|
588 |
# Test removing instance with offline drbd secondary
|
589 |
if qa_config.TestEnabled("instance-remove-drbd-offline"): |
590 |
# Make sure the master is not put offline
|
591 |
snode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
592 |
try:
|
593 |
pnode = qa_config.AcquireNode(exclude=snode) |
594 |
try:
|
595 |
instance = qa_instance.TestInstanceAddWithDrbdDisk(pnode, snode) |
596 |
qa_node.MakeNodeOffline(snode, "yes")
|
597 |
try:
|
598 |
RunTest(qa_instance.TestInstanceRemove, instance) |
599 |
finally:
|
600 |
qa_node.MakeNodeOffline(snode, "no")
|
601 |
finally:
|
602 |
qa_config.ReleaseNode(pnode) |
603 |
finally:
|
604 |
qa_config.ReleaseNode(snode) |
605 |
|
606 |
pnode = qa_config.AcquireNode() |
607 |
try:
|
608 |
if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]): |
609 |
for shutdown in [False, True]: |
610 |
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode) |
611 |
expnode = qa_config.AcquireNode(exclude=pnode) |
612 |
try:
|
613 |
if shutdown:
|
614 |
# Stop instance before exporting and removing it
|
615 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
616 |
RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode) |
617 |
RunTest(qa_instance.TestBackupList, expnode) |
618 |
finally:
|
619 |
qa_config.ReleaseNode(expnode) |
620 |
del expnode
|
621 |
del instance
|
622 |
|
623 |
finally:
|
624 |
qa_config.ReleaseNode(pnode) |
625 |
|
626 |
RunExclusiveStorageTests() |
627 |
|
628 |
RunTestIf("create-cluster", qa_node.TestNodeRemoveAll)
|
629 |
|
630 |
RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
|
631 |
|
632 |
|
633 |
@UsesRapiClient
|
634 |
def main(): |
635 |
"""Main program.
|
636 |
|
637 |
"""
|
638 |
parser = optparse.OptionParser(usage="%prog [options] <config-file>")
|
639 |
parser.add_option("--yes-do-it", dest="yes_do_it", |
640 |
action="store_true",
|
641 |
help="Really execute the tests")
|
642 |
(qa_config.options, args) = parser.parse_args() |
643 |
|
644 |
if len(args) == 1: |
645 |
(config_file, ) = args |
646 |
else:
|
647 |
parser.error("Wrong number of arguments.")
|
648 |
|
649 |
if not qa_config.options.yes_do_it: |
650 |
print ("Executing this script irreversibly destroys any Ganeti\n" |
651 |
"configuration on all nodes involved. If you really want\n"
|
652 |
"to start testing, supply the --yes-do-it option.")
|
653 |
sys.exit(1)
|
654 |
|
655 |
qa_config.Load(config_file) |
656 |
|
657 |
primary = qa_config.GetMasterNode()["primary"]
|
658 |
qa_utils.StartMultiplexer(primary) |
659 |
print ("SSH command for primary node: %s" % |
660 |
utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, "")))
|
661 |
print ("SSH command for other nodes: %s" % |
662 |
utils.ShellQuoteArgs(qa_utils.GetSSHCommand("NODE", ""))) |
663 |
try:
|
664 |
RunQa() |
665 |
finally:
|
666 |
qa_utils.CloseMultiplexers() |
667 |
|
668 |
if __name__ == "__main__": |
669 |
main() |