Ejemplo n.º 1
0
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])
Ejemplo n.º 2
0
def TestUpgrade():
    """Test gnt-cluster upgrade.

  This tests the 'gnt-cluster upgrade' command by flipping
  between the current and a different version of Ganeti.
  To also recover subtile points in the configuration up/down
  grades, instances are left over both upgrades.

  """
    this_version = qa_config.get("dir-version")
    other_version = qa_config.get("other-dir-version")
    if this_version is None or other_version is None:
        print qa_utils.FormatInfo("Test not run, as versions not specified")
        return

    inst_creates = []
    upgrade_instances = qa_config.get("upgrade-instances", [])
    live_instances = []
    for (test_name, templ, cf, n) in qa_instance.available_instance_tests:
        if (qa_config.TestEnabled(test_name)
                and qa_config.IsTemplateSupported(templ)
                and templ in upgrade_instances):
            inst_creates.append((cf, n))

    for (cf, n) in inst_creates:
        nodes = qa_config.AcquireManyNodes(n)
        live_instances.append(cf(nodes))

    AssertCommand(["gnt-cluster", "upgrade", "--to", other_version])
    AssertCommand(["gnt-cluster", "verify"])

    for instance in live_instances:
        qa_instance.TestInstanceRemove(instance)
        instance.Release()
    live_instances = []
    for (cf, n) in inst_creates:
        nodes = qa_config.AcquireManyNodes(n)
        live_instances.append(cf(nodes))

    AssertCommand(["gnt-cluster", "upgrade", "--to", this_version])
    AssertCommand(["gnt-cluster", "verify"])

    for instance in live_instances:
        qa_instance.TestInstanceRemove(instance)
        instance.Release()
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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"])
Ejemplo n.º 5
0
def _TestEvac(filepath, filecontent, inst_move_type):
    _SetUp(os.path.basename(filepath))
    node1, node2 = qa_config.AcquireManyNodes(
        2, exclude=qa_config.GetMasterNode())
    inst = CreateInstanceDrbd8([node1, node2])
    _AssertInstanceRunning(inst)
    UploadData(node1.primary, filecontent, 0755, filepath)

    _AssertNodeDrained(node1)
    _AssertInstanceMove(inst, inst_move_type)
    tag = _AssertRepairTagAddition(node1)

    RemoveInstance(inst)
    inst.Release()
    node1.Release()
    node2.Release()
    _TearDown(node1, tag, [filepath])
Ejemplo n.º 6
0
def TestClusterModifyDiskTemplates():
    """gnt-cluster modify --enabled-disk-templates=..."""
    enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
    default_disk_template = qa_config.GetDefaultDiskTemplate()

    _TestClusterModifyDiskTemplatesArguments(default_disk_template)
    _TestClusterModifyDiskTemplatesDrbdHelper(enabled_disk_templates)
    _TestClusterModifyDiskTemplatesVgName(enabled_disk_templates)

    _RestoreEnabledDiskTemplates()
    nodes = qa_config.AcquireManyNodes(2)

    instance_template = enabled_disk_templates[0]
    instance = qa_instance.CreateInstanceByDiskTemplate(
        nodes, instance_template)

    _TestClusterModifyUsedDiskTemplate(instance_template,
                                       enabled_disk_templates)

    qa_instance.TestInstanceRemove(instance)
    _RestoreEnabledDiskTemplates()
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
def TestInstanceCreationRestrictedByDiskTemplates():
    """Test adding instances for disabled disk templates."""
    if qa_config.TestEnabled("cluster-exclusive-storage"):
        # These tests are valid only for non-exclusive storage
        return

    enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
    nodes = qa_config.AcquireManyNodes(2)

    # Setup the cluster with the enabled_disk_templates
    AssertCommand([
        "gnt-cluster", "modify",
        "--enabled-disk-templates=%s" % ",".join(enabled_disk_templates),
        "--ipolicy-disk-templates=%s" % ",".join(enabled_disk_templates)
    ],
                  fail=False)

    # Test instance creation for enabled disk templates
    for disk_template in enabled_disk_templates:
        instance = CreateInstanceByDiskTemplate(nodes,
                                                disk_template,
                                                fail=False)
        TestInstanceRemove(instance)
        instance.Release()

    # Test that instance creation fails for disabled disk templates
    disabled_disk_templates = list(constants.DISK_TEMPLATES -
                                   set(enabled_disk_templates))
    for disk_template in disabled_disk_templates:
        instance = CreateInstanceByDiskTemplate(nodes,
                                                disk_template,
                                                fail=True)

    # Test instance creation for after disabling enabled disk templates
    if (len(enabled_disk_templates) > 1):
        # Partition the disk templates, enable them separately and check if the
        # disabled ones cannot be used by instances.
        middle = len(enabled_disk_templates) / 2
        templates1 = enabled_disk_templates[:middle]
        templates2 = enabled_disk_templates[middle:]

        for (enabled, disabled) in [(templates1, templates2),
                                    (templates2, templates1)]:
            AssertCommand([
                "gnt-cluster", "modify",
                "--enabled-disk-templates=%s" % ",".join(enabled),
                "--ipolicy-disk-templates=%s" % ",".join(enabled)
            ],
                          fail=False)
            for disk_template in disabled:
                CreateInstanceByDiskTemplate(nodes, disk_template, fail=True)
    elif (len(enabled_disk_templates) == 1):
        # If only one disk template is enabled in the QA config, we have to enable
        # some other templates in order to test if the disabling the only enabled
        # disk template prohibits creating instances of that template.
        other_disk_templates = list(
            set([constants.DT_DISKLESS, constants.DT_BLOCK]) -
            set(enabled_disk_templates))
        AssertCommand([
            "gnt-cluster", "modify",
            "--enabled-disk-templates=%s" % ",".join(other_disk_templates),
            "--ipolicy-disk-templates=%s" % ",".join(other_disk_templates)
        ],
                      fail=False)
        CreateInstanceByDiskTemplate(nodes,
                                     enabled_disk_templates[0],
                                     fail=True)
    else:
        raise qa_error.Error("Please enable at least one disk template"
                             " in your QA setup.")

    # Restore initially enabled disk templates
    AssertCommand([
        "gnt-cluster", "modify",
        "--enabled-disk-templates=%s" % ",".join(enabled_disk_templates),
        "--ipolicy-disk-templates=%s" % ",".join(enabled_disk_templates)
    ],
                  fail=False)