def RunHardwareFailureTests(instance, inodes): """Test cluster internal hardware failure recovery. """ RunTestIf("instance-failover", qa_instance.TestInstanceFailover, instance) RunTestIf(["instance-failover", qa_rapi.Enabled], qa_rapi.TestRapiInstanceFailover, instance) RunTestIf("instance-migrate", qa_instance.TestInstanceMigrate, instance) RunTestIf(["instance-migrate", qa_rapi.Enabled], qa_rapi.TestRapiInstanceMigrate, instance) if qa_config.TestEnabled("instance-replace-disks"): # We just need alternative secondary nodes, hence "- 1" othernodes = qa_config.AcquireManyNodes(len(inodes) - 1, exclude=inodes) try: RunTestIf(qa_rapi.Enabled, qa_rapi.TestRapiInstanceReplaceDisks, instance) RunTest(qa_instance.TestReplaceDisks, instance, inodes, othernodes) finally: qa_config.ReleaseManyNodes(othernodes) del othernodes if qa_config.TestEnabled("instance-recreate-disks"): try: acquirednodes = qa_config.AcquireManyNodes(len(inodes), exclude=inodes) othernodes = acquirednodes except qa_error.OutOfNodesError: if len(inodes) > 1: # If the cluster is not big enough, let's reuse some of the nodes, but # with different roles. In this way, we can test a DRBD instance even on # a 3-node cluster. acquirednodes = [qa_config.AcquireNode(exclude=inodes)] othernodes = acquirednodes + inodes[:-1] else: raise try: RunTest(qa_instance.TestRecreateDisks, instance, inodes, othernodes) finally: qa_config.ReleaseManyNodes(acquirednodes) if len(inodes) >= 2: RunTestIf("node-evacuate", qa_node.TestNodeEvacuate, inodes[0], inodes[1]) RunTestIf("node-failover", qa_node.TestNodeFailover, inodes[0], inodes[1]) RunTestIf("node-migrate", qa_node.TestNodeMigrate, inodes[0], inodes[1])
def TestParallelNodeCountInstanceCreationPerformance(): """PERFORMANCE: Parallel instance creation (instance count = node count). """ nodes = list(_AcquireAllNodes()) _TestParallelInstanceCreationAndRemoval(max_instances=len(nodes)) qa_config.ReleaseManyNodes(nodes)
def TestParallelPlainInstanceCreationPerformance(): """PERFORMANCE: Parallel plain backed instance creation. """ assert qa_config.IsTemplateSupported(constants.DT_PLAIN) nodes = list(_AcquireAllNodes()) _TestParallelInstanceCreationAndRemoval(max_instances=len(nodes) * 2, disk_template=constants.DT_PLAIN) qa_config.ReleaseManyNodes(nodes)
def TestParallelPlainInstanceCreationPerformance(): """PERFORMANCE: Parallel plain backed instance creation. """ if not qa_config.IsTemplateSupported(constants.DT_PLAIN): print( qa_logging.FormatInfo( "Plain disk template not supported, skipping")) nodes = list(_AcquireAllNodes()) _TestParallelInstanceCreationAndRemoval(max_instances=len(nodes) * 2, disk_template=constants.DT_PLAIN) qa_config.ReleaseManyNodes(nodes)
def RunPerformanceTests(): if not qa_config.TestEnabled("performance"): ReportTestSkip("performance related tests", "performance") return if qa_config.TestEnabled("jobqueue-performance"): RunTest(qa_performance.TestParallelMaxInstanceCreationPerformance) RunTest( qa_performance.TestParallelNodeCountInstanceCreationPerformance) instances = qa_performance.CreateAllInstances() RunTest(qa_performance.TestParallelModify, instances) RunTest(qa_performance.TestParallelInstanceOSOperations, instances) RunTest(qa_performance.TestParallelInstanceQueries, instances) qa_performance.RemoveAllInstances(instances) RunTest(qa_performance.TestJobQueueSubmissionPerformance) if qa_config.TestEnabled("parallel-performance"): if qa_config.IsTemplateSupported(constants.DT_DRBD8): RunTest(qa_performance.TestParallelDRBDInstanceCreationPerformance) if qa_config.IsTemplateSupported(constants.DT_PLAIN): RunTest( qa_performance.TestParallelPlainInstanceCreationPerformance) if qa_config.IsTemplateSupported(constants.DT_DRBD8): inodes = qa_config.AcquireManyNodes(2) try: instance = qa_instance.TestInstanceAddWithDrbdDisk(inodes) try: RunTest(qa_performance.TestParallelInstanceFailover, instance) RunTest(qa_performance.TestParallelInstanceMigration, instance) RunTest(qa_performance.TestParallelInstanceReplaceDisks, instance) RunTest(qa_performance.TestParallelInstanceReboot, instance) RunTest(qa_performance.TestParallelInstanceReinstall, instance) RunTest(qa_performance.TestParallelInstanceRename, instance) finally: qa_instance.TestInstanceRemove(instance) instance.Release() finally: qa_config.ReleaseManyNodes(inodes)
def RunPerformanceTests(): if not qa_config.TestEnabled("performance"): ReportTestSkip("performance related tests", "performance") return # For reproducable performance, run performance tests with the watcher # paused. qa_utils.AssertCommand(["gnt-cluster", "watcher", "pause", "4h"]) if qa_config.TestEnabled("jobqueue-performance"): RunTest(qa_performance.TestParallelMaxInstanceCreationPerformance) RunTest( qa_performance.TestParallelNodeCountInstanceCreationPerformance) instances = qa_performance.CreateAllInstances() RunTest(qa_performance.TestParallelModify, instances) RunTest(qa_performance.TestParallelInstanceOSOperations, instances) RunTest(qa_performance.TestParallelInstanceQueries, instances) qa_performance.RemoveAllInstances(instances) RunTest(qa_performance.TestJobQueueSubmissionPerformance) if qa_config.TestEnabled("parallel-performance"): if qa_config.IsTemplateSupported(constants.DT_DRBD8): RunTest(qa_performance.TestParallelDRBDInstanceCreationPerformance) if qa_config.IsTemplateSupported(constants.DT_PLAIN): RunTest( qa_performance.TestParallelPlainInstanceCreationPerformance) # Preparations need to be made only if some of these tests are enabled if qa_config.IsTemplateSupported(constants.DT_DRBD8) and \ qa_config.TestEnabled(qa_config.Either(PARALLEL_TEST_DICT.keys())): inodes = qa_config.AcquireManyNodes(2) try: instance = qa_instance.TestInstanceAddWithDrbdDisk(inodes) try: for (test_name, test_fn) in PARALLEL_TEST_DICT.items(): RunTestIf(test_name, test_fn, instance) finally: instance.Release() qa_instance.TestInstanceRemove(instance) finally: qa_config.ReleaseManyNodes(inodes) qa_utils.AssertCommand(["gnt-cluster", "watcher", "continue"])
def RunInstanceTests(): """Create and exercise instances.""" requested_conversions = qa_config.get("convert-disk-templates", []) supported_conversions = \ set(requested_conversions).difference(constants.DTS_NOT_CONVERTIBLE_TO) for (test_name, templ, create_fun, num_nodes) in \ qa_instance.available_instance_tests: if (qa_config.TestEnabled(test_name) and qa_config.IsTemplateSupported(templ)): inodes = qa_config.AcquireManyNodes(num_nodes) try: instance = RunTest(create_fun, inodes) try: RunTestIf("instance-user-down", qa_instance.TestInstanceUserDown, instance) RunTestIf("instance-communication", qa_instance.TestInstanceCommunication, instance, qa_config.GetMasterNode()) RunTestIf("cluster-epo", qa_cluster.TestClusterEpo) RunDaemonTests(instance) for node in inodes: RunTestIf("haskell-confd", qa_node.TestNodeListDrbd, node, templ == constants.DT_DRBD8) if len(inodes) > 1: RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit, constants.INITIAL_NODE_GROUP_NAME, inodes[0].primary, inodes[1].primary) # This test will run once but it will cover all the supported # user-provided disk template conversions if qa_config.TestEnabled("instance-convert-disk"): if (len(supported_conversions) > 1 and instance.disk_template in supported_conversions): RunTest(qa_instance.TestInstanceShutdown, instance) RunTest( qa_instance.TestInstanceConvertDiskTemplate, instance, supported_conversions) RunTest(qa_instance.TestInstanceStartup, instance) # At this point we clear the set because the requested conversions # has been tested supported_conversions.clear() else: test_desc = "Converting instance of template %s" % templ ReportTestSkip(test_desc, "conversion feature") RunTestIf("instance-modify-disks", qa_instance.TestInstanceModifyDisks, instance) RunCommonInstanceTests(instance, inodes) if qa_config.TestEnabled("instance-modify-primary"): othernode = qa_config.AcquireNode() RunTest(qa_instance.TestInstanceModifyPrimaryAndBack, instance, inodes[0], othernode) othernode.Release() RunGroupListTests() RunExportImportTests(instance, inodes) RunHardwareFailureTests(instance, inodes) RunRepairDiskSizes() RunTestIf(["rapi", "instance-data-censorship"], qa_rapi.TestInstanceDataCensorship, instance, inodes) RunTest(qa_instance.TestInstanceRemove, instance) finally: instance.Release() del instance finally: qa_config.ReleaseManyNodes(inodes) qa_cluster.AssertClusterVerify() else: test_desc = "Creating instances of template %s" % templ if not qa_config.TestEnabled(test_name): ReportTestSkip(test_desc, test_name) else: ReportTestSkip(test_desc, "disk template %s" % templ)
def Workload(client): """ The actual RAPI workload used for tests. @type client: C{GanetiRapiClientWrapper} @param client: A wrapped RAPI client. """ # First just the simple information retrievals TestGetters(client) # Then the only remaining function which is parameter-free Finish(client, client.RedistributeConfig) # Try changing the cluster parameters TestClusterParameterModification(client) TestTags(client, client.GetClusterTags, client.AddClusterTags, client.DeleteClusterTags) # Generously assume the master is present node = qa_config.AcquireNode() TestTags(client, client.GetNodeTags, client.AddNodeTags, client.DeleteNodeTags, node.primary) node.Release() # Instance tests # First remove all instances the QA might have created RemoveAllInstances(client) nodes = qa_config.AcquireManyNodes(2) instances = qa_config.AcquireManyInstances(2) TestSingleInstance(client, instances[0].name, instances[1].name, nodes[0].primary, nodes[1].primary) qa_config.ReleaseManyInstances(instances) qa_config.ReleaseManyNodes(nodes) # Test all the queries which involve resources that do not have functions # of their own TestQueries(client, "lock") TestQueries(client, "job") TestQueries(client, "export") node = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) TestNodeOperations(client, node.primary) TestQueryFiltering(client, node.primary) node.Release() nodes = qa_config.AcquireManyNodes(2) TestGroupOperations(client, nodes[0].primary, nodes[1].primary) qa_config.ReleaseManyNodes(nodes) TestNetworks(client) nodes = qa_config.AcquireManyNodes(3) instance = qa_config.AcquireInstance() TestInstanceMigrations(client, nodes[0].primary, nodes[1].primary, nodes[2].primary, instance.name) instance.Release() qa_config.ReleaseManyNodes(nodes) nodes = qa_config.AcquireManyNodes(2) instances = qa_config.AcquireManyInstances(2) TestInstanceMoves(client, nodes[0], nodes[1], instances[0], instances[1]) TestJobCancellation(client, nodes[0].primary, nodes[1].primary, instances[0].name, instances[1].name) qa_config.ReleaseManyInstances(instances) qa_config.ReleaseManyNodes(nodes)