コード例 #1
0
def RunCustomSshPortTests():
    """Test accessing nodes with custom SSH ports.

  This requires removing nodes, adding them to a new group, and then undoing
  the change.
  """
    if not qa_config.TestEnabled("group-custom-ssh-port"):
        return

    std_port = netutils.GetDaemonPort(constants.SSH)
    port = 211
    master = qa_config.GetMasterNode()
    with qa_config.AcquireManyNodesCtx(1, exclude=master) as nodes:
        # Checks if the node(s) could be contacted through IPv6.
        # If yes, better skip the whole test.

        for node in nodes:
            if qa_utils.UsesIPv6Connection(node.primary, std_port):
                print(
                    "Node %s is likely to be reached using IPv6,"
                    "skipping the test" % (node.primary, ))
                return

        for node in nodes:
            qa_node.NodeRemove(node)
        with qa_iptables.RulesContext() as r:
            with qa_group.NewGroupCtx() as group:
                qa_group.ModifyGroupSshPort(r, group, nodes, port)

                for node in nodes:
                    qa_node.NodeAdd(node, group=group)

                # Make sure that the cluster doesn't have any pre-existing problem
                qa_cluster.AssertClusterVerify()

                # Create and allocate instances
                instance1 = qa_instance.TestInstanceAddWithPlainDisk(nodes)
                try:
                    instance2 = qa_instance.TestInstanceAddWithPlainDisk(nodes)
                    try:
                        # cluster-verify checks that disks are allocated correctly
                        qa_cluster.AssertClusterVerify()

                        # Remove instances
                        qa_instance.TestInstanceRemove(instance2)
                        qa_instance.TestInstanceRemove(instance1)
                    finally:
                        instance2.Release()
                finally:
                    instance1.Release()

                for node in nodes:
                    qa_node.NodeRemove(node)

        for node in nodes:
            qa_node.NodeAdd(node)

        qa_cluster.AssertClusterVerify()
コード例 #2
0
def RunExclusiveStorageTests():
    """Test exclusive storage."""
    if not qa_config.TestEnabled("cluster-exclusive-storage"):
        return

    node = qa_config.AcquireNode()
    try:
        old_es = qa_cluster.TestSetExclStorCluster(False)
        qa_node.TestExclStorSingleNode(node)

        qa_cluster.TestSetExclStorCluster(True)
        qa_cluster.TestExclStorSharedPv(node)

        if qa_config.TestEnabled("instance-add-plain-disk"):
            # Make sure that the cluster doesn't have any pre-existing problem
            qa_cluster.AssertClusterVerify()

            # Create and allocate instances
            instance1 = qa_instance.TestInstanceAddWithPlainDisk([node])
            try:
                instance2 = qa_instance.TestInstanceAddWithPlainDisk([node])
                try:
                    # cluster-verify checks that disks are allocated correctly
                    qa_cluster.AssertClusterVerify()

                    # Remove instances
                    qa_instance.TestInstanceRemove(instance2)
                    qa_instance.TestInstanceRemove(instance1)
                finally:
                    instance2.Release()
            finally:
                instance1.Release()

        if qa_config.TestEnabled("instance-add-drbd-disk"):
            snode = qa_config.AcquireNode()
            try:
                qa_cluster.TestSetExclStorCluster(False)
                instance = qa_instance.TestInstanceAddWithDrbdDisk(
                    [node, snode])
                try:
                    qa_cluster.TestSetExclStorCluster(True)
                    exp_err = [constants.CV_EINSTANCEUNSUITABLENODE]
                    qa_cluster.AssertClusterVerify(fail=True, errors=exp_err)
                    qa_instance.TestInstanceRemove(instance)
                finally:
                    instance.Release()
            finally:
                snode.Release()
        qa_cluster.TestSetExclStorCluster(old_es)
    finally:
        node.Release()
コード例 #3
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()
コード例 #4
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)
コード例 #5
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"])
コード例 #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()
コード例 #7
0
def TestIPolicyPlainInstance():
    """Test instance policy interaction with instances"""
    params = [
        "memory-size", "cpu-count", "disk-count", "disk-size", "nic-count"
    ]
    if not qa_config.IsTemplateSupported(constants.DT_PLAIN):
        print "Template %s not supported" % constants.DT_PLAIN
        return

    # This test assumes that the group policy is empty
    (_, old_specs) = qa_cluster.TestClusterSetISpecs()
    # We also assume to have only one min/max bound
    assert len(old_specs[constants.ISPECS_MINMAX]) == 1
    node = qa_config.AcquireNode()
    try:
        # Log of policy changes, list of tuples:
        # (full_change, incremental_change, policy_violated)
        history = []
        instance = qa_instance.TestInstanceAddWithPlainDisk([node])
        try:
            policyerror = [constants.CV_EINSTANCEPOLICY]
            for par in params:
                (iminval,
                 imaxval) = qa_instance.GetInstanceSpec(instance.name, par)
                # Some specs must be multiple of 4
                new_spec = _BuildSpecDict(par, imaxval + 4, imaxval + 4,
                                          imaxval + 4)
                history.append((None, new_spec, True))
                if iminval > 0:
                    # Some specs must be multiple of 4
                    if iminval >= 4:
                        upper = iminval - 4
                    else:
                        upper = iminval - 1
                    new_spec = _BuildSpecDict(par, 0, upper, upper)
                    history.append((None, new_spec, True))
                history.append((old_specs, None, False))

            # Test with two instance specs
            double_specs = copy.deepcopy(old_specs)
            double_specs[constants.ISPECS_MINMAX] = \
                double_specs[constants.ISPECS_MINMAX] * 2
            (par1, par2) = params[0:2]
            (_, imaxval1) = qa_instance.GetInstanceSpec(instance.name, par1)
            (_, imaxval2) = qa_instance.GetInstanceSpec(instance.name, par2)
            old_minmax = old_specs[constants.ISPECS_MINMAX][0]
            history.extend([
                (double_specs, None, False),
                # The first min/max limit is being violated
                (None,
                 _BuildDoubleSpecDict(0, par1, imaxval1 + 4, imaxval1 + 4,
                                      imaxval1 + 4), False),
                # Both min/max limits are being violated
                (None,
                 _BuildDoubleSpecDict(1, par2, imaxval2 + 4, None,
                                      imaxval2 + 4), True),
                # The second min/max limit is being violated
                (None,
                 _BuildDoubleSpecDict(0, par1,
                                      old_minmax[constants.ISPECS_MIN][par1],
                                      old_specs[constants.ISPECS_STD][par1],
                                      old_minmax[constants.ISPECS_MAX][par1]),
                 False),
                (old_specs, None, False),
            ])

            # Apply the changes, and check policy violations after each change
            qa_cluster.AssertClusterVerify()
            for (new_specs, diff_specs, failed) in history:
                qa_cluster.TestClusterSetISpecs(new_specs=new_specs,
                                                diff_specs=diff_specs)
                if failed:
                    qa_cluster.AssertClusterVerify(warnings=policyerror)
                else:
                    qa_cluster.AssertClusterVerify()

            qa_instance.TestInstanceRemove(instance)
        finally:
            instance.Release()

        # Now we replay the same policy changes, and we expect that the instance
        # cannot be created for the cases where we had a policy violation above
        for (new_specs, diff_specs, failed) in history:
            qa_cluster.TestClusterSetISpecs(new_specs=new_specs,
                                            diff_specs=diff_specs)
            if failed:
                qa_instance.TestInstanceAddWithPlainDisk([node], fail=True)
            # Instance creation with no policy violation has been tested already
    finally:
        node.Release()