4 # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
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.
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.
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
22 """Script for doing QA on Ganeti.
26 # pylint: disable=C0103
48 from ganeti import utils
49 from ganeti import rapi # pylint: disable=W0611
50 from ganeti import constants
52 import ganeti.rapi.client # pylint: disable=W0611
53 from ganeti.rapi.client import UsesRapiClient
56 def _FormatHeader(line, end=72):
57 """Fill a line up to the end column.
60 line = "---- " + line + " "
61 line += "-" * (end - len(line))
66 def _DescriptionOf(fn):
67 """Computes the description of an item.
71 desc = fn.__doc__.splitlines()[0].strip()
75 return desc.rstrip(".")
78 def RunTest(fn, *args, **kwargs):
79 """Runs a test after printing a header.
83 tstart = datetime.datetime.now()
85 desc = _DescriptionOf(fn)
88 print _FormatHeader("%s start %s" % (tstart, desc))
91 retval = fn(*args, **kwargs)
94 tstop = datetime.datetime.now()
95 tdelta = tstop - tstart
96 print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc))
99 def RunTestIf(testnames, fn, *args, **kwargs):
100 """Runs a test conditionally.
102 @param testnames: either a single test name in the configuration
103 file, or a list of testnames (which will be AND-ed together)
106 if qa_config.TestEnabled(testnames):
107 RunTest(fn, *args, **kwargs)
109 tstart = datetime.datetime.now()
110 desc = _DescriptionOf(fn)
111 # TODO: Formatting test names when non-string names are involved
112 print _FormatHeader("%s skipping %s, test(s) %s disabled" %
113 (tstart, desc, testnames))
117 """Run several environment tests.
120 RunTestIf("env", qa_env.TestSshConnection)
121 RunTestIf("env", qa_env.TestIcmpPing)
122 RunTestIf("env", qa_env.TestGanetiCommands)
125 def SetupCluster(rapi_user, rapi_secret):
126 """Initializes the cluster.
128 @param rapi_user: Login user for RAPI
129 @param rapi_secret: Login secret for RAPI
132 RunTestIf("create-cluster", qa_cluster.TestClusterInit,
133 rapi_user, rapi_secret)
134 if not qa_config.TestEnabled("create-cluster"):
135 # If the cluster is already in place, we assume that exclusive-storage is
136 # already set according to the configuration
137 qa_config.SetExclusiveStorage(qa_config.get("exclusive-storage", False))
139 # Test on empty cluster
140 RunTestIf("node-list", qa_node.TestNodeList)
141 RunTestIf("instance-list", qa_instance.TestInstanceList)
142 RunTestIf("job-list", qa_job.TestJobList)
144 RunTestIf("create-cluster", qa_node.TestNodeAddAll)
145 if not qa_config.TestEnabled("create-cluster"):
146 # consider the nodes are already there
147 qa_node.MarkNodeAddedAll()
149 RunTestIf("test-jobqueue", qa_cluster.TestJobqueue)
151 # enable the watcher (unconditionally)
152 RunTest(qa_daemon.TestResumeWatcher)
154 RunTestIf("node-list", qa_node.TestNodeList)
156 # Test listing fields
157 RunTestIf("node-list", qa_node.TestNodeListFields)
158 RunTestIf("instance-list", qa_instance.TestInstanceListFields)
159 RunTestIf("job-list", qa_job.TestJobListFields)
160 RunTestIf("instance-export", qa_instance.TestBackupListFields)
162 RunTestIf("node-info", qa_node.TestNodeInfo)
165 def RunClusterTests():
166 """Runs tests related to gnt-cluster.
170 ("create-cluster", qa_cluster.TestClusterInitDisk),
171 ("cluster-renew-crypto", qa_cluster.TestClusterRenewCrypto),
172 ("cluster-verify", qa_cluster.TestClusterVerify),
173 ("cluster-reserved-lvs", qa_cluster.TestClusterReservedLvs),
174 # TODO: add more cluster modify tests
175 ("cluster-modify", qa_cluster.TestClusterModifyEmpty),
176 ("cluster-modify", qa_cluster.TestClusterModifyIPolicy),
177 ("cluster-modify", qa_cluster.TestClusterModifyISpecs),
178 ("cluster-modify", qa_cluster.TestClusterModifyBe),
179 ("cluster-modify", qa_cluster.TestClusterModifyDisk),
180 ("cluster-modify", qa_cluster.TestClusterModifyDiskTemplates),
181 ("cluster-rename", qa_cluster.TestClusterRename),
182 ("cluster-info", qa_cluster.TestClusterVersion),
183 ("cluster-info", qa_cluster.TestClusterInfo),
184 ("cluster-info", qa_cluster.TestClusterGetmaster),
185 ("cluster-redist-conf", qa_cluster.TestClusterRedistConf),
186 (["cluster-copyfile", qa_config.NoVirtualCluster],
187 qa_cluster.TestClusterCopyfile),
188 ("cluster-command", qa_cluster.TestClusterCommand),
189 ("cluster-burnin", qa_cluster.TestClusterBurnin),
190 ("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
191 ("cluster-master-failover",
192 qa_cluster.TestClusterMasterFailoverWithDrainedQueue),
193 (["cluster-oob", qa_config.NoVirtualCluster],
194 qa_cluster.TestClusterOob),
195 (qa_rapi.Enabled, qa_rapi.TestVersion),
196 (qa_rapi.Enabled, qa_rapi.TestEmptyCluster),
197 (qa_rapi.Enabled, qa_rapi.TestRapiQuery),
202 def RunRepairDiskSizes():
203 """Run the repair disk-sizes test.
206 RunTestIf("cluster-repair-disk-sizes", qa_cluster.TestClusterRepairDiskSizes)
210 """Runs all tests related to gnt-os.
213 os_enabled = ["os", qa_config.NoVirtualCluster]
215 if qa_config.TestEnabled(qa_rapi.Enabled):
216 rapi_getos = qa_rapi.GetOperatingSystems
222 qa_os.TestOsDiagnose,
224 RunTestIf(os_enabled, fn)
229 qa_os.TestOsPartiallyValid,
231 RunTestIf(os_enabled, fn, rapi_getos)
234 qa_os.TestOsModifyValid,
235 qa_os.TestOsModifyInvalid,
236 qa_os.TestOsStatesNonExisting,
238 RunTestIf(os_enabled, fn)
241 def RunCommonInstanceTests(instance):
242 """Runs a few tests that are common to all disk types.
245 RunTestIf("instance-shutdown", qa_instance.TestInstanceShutdown, instance)
246 RunTestIf(["instance-shutdown", "instance-console", qa_rapi.Enabled],
247 qa_rapi.TestRapiStoppedInstanceConsole, instance)
248 RunTestIf(["instance-shutdown", "instance-modify"],
249 qa_instance.TestInstanceStoppedModify, instance)
250 RunTestIf("instance-shutdown", qa_instance.TestInstanceStartup, instance)
252 # Test shutdown/start via RAPI
253 RunTestIf(["instance-shutdown", qa_rapi.Enabled],
254 qa_rapi.TestRapiInstanceShutdown, instance)
255 RunTestIf(["instance-shutdown", qa_rapi.Enabled],
256 qa_rapi.TestRapiInstanceStartup, instance)
258 RunTestIf("instance-list", qa_instance.TestInstanceList)
260 RunTestIf("instance-info", qa_instance.TestInstanceInfo, instance)
262 RunTestIf("instance-modify", qa_instance.TestInstanceModify, instance)
263 RunTestIf(["instance-modify", qa_rapi.Enabled],
264 qa_rapi.TestRapiInstanceModify, instance)
266 RunTestIf("instance-console", qa_instance.TestInstanceConsole, instance)
267 RunTestIf(["instance-console", qa_rapi.Enabled],
268 qa_rapi.TestRapiInstanceConsole, instance)
270 DOWN_TESTS = qa_config.Either([
271 "instance-reinstall",
273 "instance-grow-disk",
276 # shutdown instance for any 'down' tests
277 RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance)
279 # now run the 'down' state tests
280 RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
281 RunTestIf(["instance-reinstall", qa_rapi.Enabled],
282 qa_rapi.TestRapiInstanceReinstall, instance)
284 if qa_config.TestEnabled("instance-rename"):
285 tgt_instance = qa_config.AcquireInstance()
287 rename_source = instance.name
288 rename_target = tgt_instance.name
289 # perform instance rename to the same name
290 RunTest(qa_instance.TestInstanceRenameAndBack,
291 rename_source, rename_source)
292 RunTestIf(qa_rapi.Enabled, qa_rapi.TestRapiInstanceRenameAndBack,
293 rename_source, rename_source)
294 if rename_target is not None:
295 # perform instance rename to a different name, if we have one configured
296 RunTest(qa_instance.TestInstanceRenameAndBack,
297 rename_source, rename_target)
298 RunTestIf(qa_rapi.Enabled, qa_rapi.TestRapiInstanceRenameAndBack,
299 rename_source, rename_target)
301 tgt_instance.Release()
303 RunTestIf(["instance-grow-disk"], qa_instance.TestInstanceGrowDisk, instance)
305 # and now start the instance again
306 RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance)
308 RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
310 RunTestIf("tags", qa_tags.TestInstanceTags, instance)
312 RunTestIf("cluster-verify", qa_cluster.TestClusterVerify)
314 RunTestIf(qa_rapi.Enabled, qa_rapi.TestInstance, instance)
316 # Lists instances, too
317 RunTestIf("node-list", qa_node.TestNodeList)
319 # Some jobs have been run, let's test listing them
320 RunTestIf("job-list", qa_job.TestJobList)
323 def RunCommonNodeTests():
324 """Run a few common node tests.
327 RunTestIf("node-volumes", qa_node.TestNodeVolumes)
328 RunTestIf("node-storage", qa_node.TestNodeStorage)
329 RunTestIf(["node-oob", qa_config.NoVirtualCluster], qa_node.TestOutOfBand)
332 def RunGroupListTests():
333 """Run tests for listing node groups.
336 RunTestIf("group-list", qa_group.TestGroupList)
337 RunTestIf("group-list", qa_group.TestGroupListFields)
340 def RunNetworkTests():
341 """Run tests for network management.
344 RunTestIf("network", qa_network.TestNetworkAddRemove)
345 RunTestIf("network", qa_network.TestNetworkConnect)
348 def RunGroupRwTests():
349 """Run tests for adding/removing/renaming groups.
352 RunTestIf("group-rwops", qa_group.TestGroupAddRemoveRename)
353 RunTestIf("group-rwops", qa_group.TestGroupAddWithOptions)
354 RunTestIf("group-rwops", qa_group.TestGroupModify)
355 RunTestIf(["group-rwops", qa_rapi.Enabled], qa_rapi.TestRapiNodeGroups)
356 RunTestIf(["group-rwops", "tags"], qa_tags.TestGroupTags,
357 qa_group.GetDefaultGroup())
360 def RunExportImportTests(instance, inodes):
361 """Tries to export and import the instance.
363 @type inodes: list of nodes
364 @param inodes: current nodes of the instance
367 # FIXME: export explicitly bails out on file based storage. other non-lvm
368 # based storage types are untested, though. Also note that import could still
369 # work, but is deeply embedded into the "export" case.
370 if (qa_config.TestEnabled("instance-export") and
371 instance.disk_template != constants.DT_FILE):
372 RunTest(qa_instance.TestInstanceExportNoTarget, instance)
375 expnode = qa_config.AcquireNode(exclude=pnode)
377 name = RunTest(qa_instance.TestInstanceExport, instance, expnode)
379 RunTest(qa_instance.TestBackupList, expnode)
381 if qa_config.TestEnabled("instance-import"):
382 newinst = qa_config.AcquireInstance()
384 RunTest(qa_instance.TestInstanceImport, newinst, pnode,
386 # Check if starting the instance works
387 RunTest(qa_instance.TestInstanceStartup, newinst)
388 RunTest(qa_instance.TestInstanceRemove, newinst)
394 # FIXME: inter-cluster-instance-move crashes on file based instances :/
396 if (qa_config.TestEnabled([qa_rapi.Enabled, "inter-cluster-instance-move"])
397 and instance.disk_template != constants.DT_FILE):
398 newinst = qa_config.AcquireInstance()
400 tnode = qa_config.AcquireNode(exclude=inodes)
402 RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst,
410 def RunDaemonTests(instance):
411 """Test the ganeti-watcher script.
414 RunTest(qa_daemon.TestPauseWatcher)
416 RunTestIf("instance-automatic-restart",
417 qa_daemon.TestInstanceAutomaticRestart, instance)
418 RunTestIf("instance-consecutive-failures",
419 qa_daemon.TestInstanceConsecutiveFailures, instance)
421 RunTest(qa_daemon.TestResumeWatcher)
424 def RunHardwareFailureTests(instance, inodes):
425 """Test cluster internal hardware failure recovery.
428 RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance)
429 RunTestIf(["instance-failover", qa_rapi.Enabled],
430 qa_rapi.TestRapiInstanceFailover, instance)
432 RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance)
433 RunTestIf(["instance-migrate", qa_rapi.Enabled],
434 qa_rapi.TestRapiInstanceMigrate, instance)
436 if qa_config.TestEnabled("instance-replace-disks"):
437 # We just need alternative secondary nodes, hence "- 1"
438 othernodes = qa_config.AcquireManyNodes(len(inodes) - 1, exclude=inodes)
440 RunTestIf(qa_rapi.Enabled, qa_rapi.TestRapiInstanceReplaceDisks, instance)
441 RunTest(qa_instance.TestReplaceDisks,
442 instance, inodes, othernodes)
444 qa_config.ReleaseManyNodes(othernodes)
447 if qa_config.TestEnabled("instance-recreate-disks"):
449 acquirednodes = qa_config.AcquireManyNodes(len(inodes), exclude=inodes)
450 othernodes = acquirednodes
451 except qa_error.OutOfNodesError:
453 # If the cluster is not big enough, let's reuse some of the nodes, but
454 # with different roles. In this way, we can test a DRBD instance even on
456 acquirednodes = [qa_config.AcquireNode(exclude=inodes)]
457 othernodes = acquirednodes + inodes[:-1]
461 RunTest(qa_instance.TestRecreateDisks,
462 instance, inodes, othernodes)
464 qa_config.ReleaseManyNodes(acquirednodes)
467 RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, inodes[0], inodes[1])
468 RunTestIf("node-failover", qa_node.TestNodeFailover, inodes[0], inodes[1])
471 def RunExclusiveStorageTests():
472 """Test exclusive storage."""
473 if not qa_config.TestEnabled("cluster-exclusive-storage"):
476 node = qa_config.AcquireNode()
478 old_es = qa_cluster.TestSetExclStorCluster(False)
479 qa_node.TestExclStorSingleNode(node)
481 qa_cluster.TestSetExclStorCluster(True)
482 qa_cluster.TestExclStorSharedPv(node)
484 if qa_config.TestEnabled("instance-add-plain-disk"):
485 # Make sure that the cluster doesn't have any pre-existing problem
486 qa_cluster.AssertClusterVerify()
488 # Create and allocate instances
489 instance1 = qa_instance.TestInstanceAddWithPlainDisk([node])
491 instance2 = qa_instance.TestInstanceAddWithPlainDisk([node])
493 # cluster-verify checks that disks are allocated correctly
494 qa_cluster.AssertClusterVerify()
497 qa_instance.TestInstanceRemove(instance2)
498 qa_instance.TestInstanceRemove(instance1)
504 if qa_config.TestEnabled("instance-add-drbd-disk"):
505 snode = qa_config.AcquireNode()
507 qa_cluster.TestSetExclStorCluster(False)
508 instance = qa_instance.TestInstanceAddWithDrbdDisk([node, snode])
510 qa_cluster.TestSetExclStorCluster(True)
511 exp_err = [constants.CV_EINSTANCEUNSUITABLENODE]
512 qa_cluster.AssertClusterVerify(fail=True, errors=exp_err)
513 qa_instance.TestInstanceRemove(instance)
518 qa_cluster.TestSetExclStorCluster(old_es)
523 def _BuildSpecDict(par, mn, st, mx):
524 return {par: {"min": mn, "std": st, "max": mx}}
527 def TestIPolicyPlainInstance():
528 """Test instance policy interaction with instances"""
529 params = ["mem-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
530 if not qa_config.IsTemplateSupported(constants.DT_PLAIN):
531 print "Template %s not supported" % constants.DT_PLAIN
534 # This test assumes that the group policy is empty
535 (_, old_specs) = qa_cluster.TestClusterSetISpecs({})
536 node = qa_config.AcquireNode()
538 # Log of policy changes, list of tuples: (change, policy_violated)
540 instance = qa_instance.TestInstanceAddWithPlainDisk([node])
542 policyerror = [constants.CV_EINSTANCEPOLICY]
544 qa_cluster.AssertClusterVerify()
545 (iminval, imaxval) = qa_instance.GetInstanceSpec(instance.name, par)
546 # Some specs must be multiple of 4
547 new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4, imaxval + 4)
548 history.append((new_spec, True))
549 qa_cluster.TestClusterSetISpecs(new_spec)
550 qa_cluster.AssertClusterVerify(warnings=policyerror)
552 # Some specs must be multiple of 4
557 new_spec = _BuildSpecDict(par, 0, upper, upper)
558 history.append((new_spec, True))
559 qa_cluster.TestClusterSetISpecs(new_spec)
560 qa_cluster.AssertClusterVerify(warnings=policyerror)
561 qa_cluster.TestClusterSetISpecs(old_specs)
562 history.append((old_specs, False))
563 qa_instance.TestInstanceRemove(instance)
567 # Now we replay the same policy changes, and we expect that the instance
568 # cannot be created for the cases where we had a policy violation above
569 for (change, failed) in history:
570 qa_cluster.TestClusterSetISpecs(change)
572 qa_instance.TestInstanceAddWithPlainDisk([node], fail=True)
573 # Instance creation with no policy violation has been tested already
578 def RunInstanceTests():
579 """Create and exercise instances."""
581 enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
582 # FIXME: Refactor this to make the code more elegant wrt to disk templates.
583 if constants.DT_PLAIN in enabled_disk_templates:
584 instance_tests.append(("instance-add-plain-disk", constants.DT_PLAIN,
585 qa_instance.TestInstanceAddWithPlainDisk, 1))
586 if constants.DT_DRBD8 in enabled_disk_templates:
587 instance_tests.append(("instance-add-drbd-disk", constants.DT_DRBD8,
588 qa_instance.TestInstanceAddWithDrbdDisk, 2))
589 if constants.DT_DISKLESS in enabled_disk_templates:
590 instance_tests.append(("instance-add-diskless", constants.DT_DISKLESS,
591 qa_instance.TestInstanceAddDiskless, 1))
592 if constants.DT_FILE in enabled_disk_templates:
593 instance_tests.append(("instance-add-file", constants.DT_FILE,
594 qa_instance.TestInstanceAddFile, 1))
596 for (test_name, templ, create_fun, num_nodes) in instance_tests:
597 if (qa_config.TestEnabled(test_name) and
598 qa_config.IsTemplateSupported(templ)):
599 inodes = qa_config.AcquireManyNodes(num_nodes)
601 instance = RunTest(create_fun, inodes)
603 RunTestIf("cluster-epo", qa_cluster.TestClusterEpo)
604 RunDaemonTests(instance)
606 RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, node)
608 RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
609 constants.INITIAL_NODE_GROUP_NAME,
610 inodes[0].primary, inodes[1].primary)
611 if qa_config.TestEnabled("instance-convert-disk"):
612 RunTest(qa_instance.TestInstanceShutdown, instance)
613 RunTest(qa_instance.TestInstanceConvertDiskToPlain,
615 RunTest(qa_instance.TestInstanceStartup, instance)
616 RunCommonInstanceTests(instance)
617 if qa_config.TestEnabled("instance-modify-primary"):
618 othernode = qa_config.AcquireNode()
619 RunTest(qa_instance.TestInstanceModifyPrimaryAndBack,
620 instance, inodes[0], othernode)
623 RunExportImportTests(instance, inodes)
624 RunHardwareFailureTests(instance, inodes)
626 RunTest(qa_instance.TestInstanceRemove, instance)
631 qa_config.ReleaseManyNodes(inodes)
632 qa_cluster.AssertClusterVerify()
635 "instance-add-restricted-by-disktemplates",
636 qa_instance.TestInstanceCreationRestrictedByDiskTemplates)
643 rapi_user = "ganeti-qa"
644 rapi_secret = utils.GenerateSecret()
647 SetupCluster(rapi_user, rapi_secret)
649 # Load RAPI certificate
650 qa_rapi.Setup(rapi_user, rapi_secret)
655 RunTestIf("tags", qa_tags.TestClusterTags)
662 # The master shouldn't be readded or put offline; "delay" needs a non-master
664 pnode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode())
666 RunTestIf("node-readd", qa_node.TestNodeReadd, pnode)
667 RunTestIf("node-modify", qa_node.TestNodeModify, pnode)
668 RunTestIf("delay", qa_cluster.TestDelay, pnode)
672 # Make sure the cluster is clean before running instance tests
673 qa_cluster.AssertClusterVerify()
675 pnode = qa_config.AcquireNode()
677 RunTestIf("tags", qa_tags.TestNodeTags, pnode)
679 if qa_rapi.Enabled():
680 RunTest(qa_rapi.TestNode, pnode)
682 if qa_config.TestEnabled("instance-add-plain-disk"):
683 for use_client in [True, False]:
684 rapi_instance = RunTest(qa_rapi.TestRapiInstanceAdd, pnode,
687 if qa_config.TestEnabled("instance-plain-rapi-common-tests"):
688 RunCommonInstanceTests(rapi_instance)
689 RunTest(qa_rapi.TestRapiInstanceRemove, rapi_instance, use_client)
691 rapi_instance.Release()
698 ("default-instance-tests", lambda: None, lambda _: None),
699 ("exclusive-storage-instance-tests",
700 lambda: qa_cluster.TestSetExclStorCluster(True),
701 qa_cluster.TestSetExclStorCluster),
703 for (conf_name, setup_conf_f, restore_conf_f) in config_list:
704 if qa_config.TestEnabled(conf_name):
705 oldconf = setup_conf_f()
707 restore_conf_f(oldconf)
709 pnode = qa_config.AcquireNode()
711 if qa_config.TestEnabled(["instance-add-plain-disk", "instance-export"]):
712 for shutdown in [False, True]:
713 instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, [pnode])
715 expnode = qa_config.AcquireNode(exclude=pnode)
718 # Stop instance before exporting and removing it
719 RunTest(qa_instance.TestInstanceShutdown, instance)
720 RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode)
721 RunTest(qa_instance.TestBackupList, expnode)
728 qa_cluster.AssertClusterVerify()
733 RunExclusiveStorageTests()
734 RunTestIf(["cluster-instance-policy", "instance-add-plain-disk"],
735 TestIPolicyPlainInstance)
737 # Test removing instance with offline drbd secondary
738 if qa_config.TestEnabled(["instance-remove-drbd-offline",
739 "instance-add-drbd-disk"]):
740 # Make sure the master is not put offline
741 snode = qa_config.AcquireNode(exclude=qa_config.GetMasterNode())
743 pnode = qa_config.AcquireNode(exclude=snode)
745 instance = qa_instance.TestInstanceAddWithDrbdDisk([pnode, snode])
746 set_offline = lambda node: qa_node.MakeNodeOffline(node, "yes")
747 set_online = lambda node: qa_node.MakeNodeOffline(node, "no")
748 RunTest(qa_instance.TestRemoveInstanceOfflineNode, instance, snode,
749 set_offline, set_online)
754 qa_cluster.AssertClusterVerify()
756 RunTestIf("create-cluster", qa_node.TestNodeRemoveAll)
758 RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy)
766 parser = optparse.OptionParser(usage="%prog [options] <config-file>")
767 parser.add_option("--yes-do-it", dest="yes_do_it",
769 help="Really execute the tests")
770 (opts, args) = parser.parse_args()
773 (config_file, ) = args
775 parser.error("Wrong number of arguments.")
777 if not opts.yes_do_it:
778 print ("Executing this script irreversibly destroys any Ganeti\n"
779 "configuration on all nodes involved. If you really want\n"
780 "to start testing, supply the --yes-do-it option.")
783 qa_config.Load(config_file)
785 primary = qa_config.GetMasterNode().primary
786 qa_utils.StartMultiplexer(primary)
787 print ("SSH command for primary node: %s" %
788 utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, "")))
789 print ("SSH command for other nodes: %s" %
790 utils.ShellQuoteArgs(qa_utils.GetSSHCommand("NODE", "")))
794 qa_utils.CloseMultiplexers()
796 if __name__ == "__main__":