Пример #1
0
def TestInstanceConsecutiveFailures(instance):
    """Test five consecutive instance failures.

  """
    inst_name = qa_utils.ResolveInstanceName(instance.name)
    inst_was_running = bool(_InstanceRunning(inst_name))

    _ResetWatcherDaemon()

    for should_start in ([True] * 5) + [False]:
        _ShutdownInstance(inst_name)
        RunWatcherDaemon()
        time.sleep(5)

        if bool(_InstanceRunning(inst_name)) != should_start:
            if should_start:
                msg = "Instance not started when it should"
            else:
                msg = "Instance started when it shouldn't"
            raise qa_error.Error(msg)

    AssertCommand(["gnt-instance", "info", inst_name])

    if inst_was_running:
        _StartInstance(inst_name)
Пример #2
0
def CheckSsconfInstanceList(instance):
    """Checks if a certain instance is in the ssconf instance list.

  @type instance: string
  @param instance: Instance name

  """
    AssertIn(qa_utils.ResolveInstanceName(instance), _ReadSsconfInstanceList())
Пример #3
0
def TestInstanceExport(instance, node):
    """gnt-backup export -n ..."""
    name = instance.name
    # Export does not work for file-based templates, thus we skip the test
    if instance.disk_template in [constants.DT_FILE, constants.DT_SHARED_FILE]:
        return
    AssertCommand(["gnt-backup", "export", "-n", node.primary, name])
    return qa_utils.ResolveInstanceName(name)
Пример #4
0
def TestInstanceAutomaticRestart(instance):
    """Test automatic restart of instance by ganeti-watcher.

  """
    inst_name = qa_utils.ResolveInstanceName(instance.name)

    _ResetWatcherDaemon()
    _ShutdownInstance(inst_name)

    RunWatcherDaemon()
    time.sleep(5)

    if not _InstanceRunning(inst_name):
        raise qa_error.Error("Daemon didn't restart instance")

    AssertCommand(["gnt-instance", "info", inst_name])
Пример #5
0
def CheckSsconfInstanceList(instance):
    """Checks if a certain instance is in the ssconf instance list.

  Because ssconf is updated in an asynchronous manner, this function will retry
  reading the ssconf instance list until it either contains the desired
  instance, or a timeout is reached.

  @type instance: string
  @param instance: Instance name

  """

    instance_name = qa_utils.ResolveInstanceName(instance)

    def _CheckSsconfInstanceList():
        if instance_name not in _ReadSsconfInstanceList():
            raise retry.RetryAgain()

    retry.Retry(_CheckSsconfInstanceList, 1, 5)
Пример #6
0
def TestRapiInstanceConsole(instance):
    """Test getting instance console information via RAPI"""
    result = _rapi_client.GetInstanceConsole(instance.name)
    console = objects.InstanceConsole.FromDict(result)
    AssertEqual(console.Validate(), None)
    AssertEqual(console.instance, qa_utils.ResolveInstanceName(instance.name))