+ """
+ automatic_restart = \
+ qa_config.TestEnabled('instance-automatic-restart')
+ consecutive_failures = \
+ qa_config.TestEnabled('instance-consecutive-failures')
+
+ if automatic_restart or consecutive_failures:
+ qa_daemon.PrintCronWarning()
+
+ if automatic_restart:
+ RunTest(qa_daemon.TestInstanceAutomaticRestart, pnode, instance)
+
+ if consecutive_failures:
+ RunTest(qa_daemon.TestInstanceConsecutiveFailures, pnode, instance)
+
+
+def RunHardwareFailureTests(instance, pnode, snode):
+ """Test cluster internal hardware failure recovery.
+
+ """
+ if qa_config.TestEnabled('instance-failover'):
+ RunTest(qa_instance.TestInstanceFailover, instance)
+
+ if qa_config.TestEnabled('instance-replace-disks'):
+ othernode = qa_config.AcquireNode(exclude=[pnode, snode])
+ try:
+ RunTest(qa_instance.TestReplaceDisks,
+ instance, pnode, snode, othernode)
+ finally:
+ qa_config.ReleaseNode(othernode)
+
+ if qa_config.TestEnabled('node-evacuate'):
+ RunTest(qa_node.TestNodeEvacuate, pnode, snode)
+
+ if qa_config.TestEnabled('node-failover'):
+ RunTest(qa_node.TestNodeFailover, pnode, snode)
+
+ if qa_config.TestEnabled('instance-disk-failure'):
+ RunTest(qa_instance.TestInstanceMasterDiskFailure,
+ instance, pnode, snode)
+ RunTest(qa_instance.TestInstanceSecondaryDiskFailure,
+ instance, pnode, snode)
+
+
+def main():
+ """Main program.
+
+ """
+ parser = optparse.OptionParser(usage="%prog [options] <config-file>")
+ parser.add_option('--yes-do-it', dest='yes_do_it',
+ action="store_true",
+ help="Really execute the tests")
+ (qa_config.options, args) = parser.parse_args()
+
+ if len(args) == 1:
+ (config_file, ) = args
+ else:
+ parser.error("Wrong number of arguments.")
+
+ if not qa_config.options.yes_do_it:
+ print ("Executing this script irreversibly destroys any Ganeti\n"
+ "configuration on all nodes involved. If you really want\n"
+ "to start testing, supply the --yes-do-it option.")
+ sys.exit(1)
+
+ qa_config.Load(config_file)
+
+ RunEnvTests()
+ SetupCluster()
+ RunClusterTests()
+ RunOsTests()
+
+ if qa_config.TestEnabled('tags'):
+ RunTest(qa_tags.TestClusterTags)
+
+ if qa_config.TestEnabled('node-readd'):
+ master = qa_config.GetMasterNode()
+ pnode = qa_config.AcquireNode(exclude=master)
+ try:
+ RunTest(qa_node.TestNodeReadd, pnode)
+ finally:
+ qa_config.ReleaseNode(pnode)
+
+ pnode = qa_config.AcquireNode()
+ try:
+ if qa_config.TestEnabled('tags'):
+ RunTest(qa_tags.TestNodeTags, pnode)
+
+ if qa_rapi.Enabled():
+ RunTest(qa_rapi.TestNode, pnode)
+
+ if qa_config.TestEnabled('instance-add-plain-disk'):
+ instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
+ RunCommonInstanceTests(instance)
+ RunExportImportTests(instance, pnode)
+ RunDaemonTests(instance, pnode)
+ RunTest(qa_instance.TestInstanceRemove, instance)
+ del instance