Skip to content
Snippets Groups Projects
Commit d55408b0 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

QA for instance migration made more compact


Also, the value of always_failover is not hard-coded any more, and it's
possible to disable changing the always_failover parameter, if needed.

Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent b5f0b5cc
No related branches found
No related tags found
No related merge requests found
...@@ -121,6 +121,28 @@ def _DestroyInstanceVolumes(instance): ...@@ -121,6 +121,28 @@ def _DestroyInstanceVolumes(instance):
AssertCommand(["lvremove", "-f"] + vols, node=node) AssertCommand(["lvremove", "-f"] + vols, node=node)
def _GetBoolInstanceField(instance, field):
"""Get the Boolean value of a field of an instance.
@type instance: string
@param instance: Instance name
@type field: string
@param field: Name of the field
"""
master = qa_config.GetMasterNode()
infocmd = utils.ShellQuoteArgs(["gnt-instance", "list", "--no-headers",
"-o", field, instance])
info_out = qa_utils.GetCommandOutput(master["primary"], infocmd).strip()
if info_out == "Y":
return True
elif info_out == "N":
return False
else:
raise qa_error.Error("Field %s of instance %s has a non-Boolean value:"
" %s" % (field, instance, info_out))
@InstanceCheck(None, INST_UP, RETURN_VALUE) @InstanceCheck(None, INST_UP, RETURN_VALUE)
def TestInstanceAddWithPlainDisk(node): def TestInstanceAddWithPlainDisk(node):
"""gnt-instance add -t plain""" """gnt-instance add -t plain"""
...@@ -249,16 +271,29 @@ def TestInstanceFailover(instance): ...@@ -249,16 +271,29 @@ def TestInstanceFailover(instance):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestInstanceMigrate(instance): def TestInstanceMigrate(instance, toggle_always_failover=True):
"""gnt-instance migrate""" """gnt-instance migrate"""
cmd = ["gnt-instance", "migrate", "--force", instance["name"]] cmd = ["gnt-instance", "migrate", "--force", instance["name"]]
af_par = constants.BE_ALWAYS_FAILOVER
af_field = "be/" + constants.BE_ALWAYS_FAILOVER
af_init_val = _GetBoolInstanceField(instance["name"], af_field)
# migrate ... # migrate ...
AssertCommand(cmd) AssertCommand(cmd)
# TODO: Verify the choice between failover and migration
qa_utils.RunInstanceCheck(instance, True) qa_utils.RunInstanceCheck(instance, True)
# ... and back # ... and back (possibly with always_failover toggled)
if toggle_always_failover:
AssertCommand(["gnt-instance", "modify", "-B",
("%s=%s" % (af_par, not af_init_val)),
instance["name"]])
AssertCommand(cmd) AssertCommand(cmd)
# TODO: Verify the choice between failover and migration
qa_utils.RunInstanceCheck(instance, True)
if toggle_always_failover:
AssertCommand(["gnt-instance", "modify", "-B",
("%s=%s" % (af_par, af_init_val)), instance["name"]])
# TODO: Split into multiple tests # TODO: Split into multiple tests
AssertCommand(["gnt-instance", "shutdown", instance["name"]]) AssertCommand(["gnt-instance", "shutdown", instance["name"]])
...@@ -268,25 +303,7 @@ def TestInstanceMigrate(instance): ...@@ -268,25 +303,7 @@ def TestInstanceMigrate(instance):
instance["name"]]) instance["name"]])
AssertCommand(["gnt-instance", "start", instance["name"]]) AssertCommand(["gnt-instance", "start", instance["name"]])
AssertCommand(cmd) AssertCommand(cmd)
qa_utils.RunInstanceCheck(instance, True) # @InstanceCheck enforces the check that the instance is running
AssertCommand(["gnt-instance", "modify", "-B",
("%s=%s" %
(constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)),
instance["name"]])
AssertCommand(cmd)
qa_utils.RunInstanceCheck(instance, True)
# TODO: Verify that a failover has been done instead of a migration
# TODO: Verify whether the default value is restored here (not hardcoded)
AssertCommand(["gnt-instance", "modify", "-B",
("%s=%s" %
(constants.BE_ALWAYS_FAILOVER, constants.VALUE_FALSE)),
instance["name"]])
AssertCommand(cmd)
qa_utils.RunInstanceCheck(instance, True)
def TestInstanceInfo(instance): def TestInstanceInfo(instance):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment