Commit 5de31440 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno

QA: Instance tests check the configuration before running

Instance test functions check the current configuration, and they will run
the actual tests only if the configuration supports them.  This will be
used for refactoring in following patches.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 7d4f1b45
...@@ -161,6 +161,21 @@ def _GetBoolInstanceField(instance, field): ...@@ -161,6 +161,21 @@ def _GetBoolInstanceField(instance, field):
" %s" % (field, instance, info_out)) " %s" % (field, instance, info_out))
def IsFailoverSupported(instance):
templ = qa_config.GetInstanceTemplate(instance)
return templ in constants.DTS_MIRRORED
def IsMigrationSupported(instance):
templ = qa_config.GetInstanceTemplate(instance)
return templ in constants.DTS_MIRRORED
def IsDiskReplacingSupported(instance):
templ = qa_config.GetInstanceTemplate(instance)
return templ == constants.DT_DRBD8
@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"""
...@@ -302,6 +317,11 @@ def TestInstanceRenameAndBack(rename_source, rename_target): ...@@ -302,6 +317,11 @@ def TestInstanceRenameAndBack(rename_source, rename_target):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestInstanceFailover(instance): def TestInstanceFailover(instance):
"""gnt-instance failover""" """gnt-instance failover"""
if not IsFailoverSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support failover, skipping"
" test")
return
cmd = ["gnt-instance", "failover", "--force", instance["name"]] cmd = ["gnt-instance", "failover", "--force", instance["name"]]
# failover ... # failover ...
...@@ -315,6 +335,11 @@ def TestInstanceFailover(instance): ...@@ -315,6 +335,11 @@ def TestInstanceFailover(instance):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestInstanceMigrate(instance, toggle_always_failover=True): def TestInstanceMigrate(instance, toggle_always_failover=True):
"""gnt-instance migrate""" """gnt-instance migrate"""
if not IsMigrationSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support migration, skipping"
" test")
return
cmd = ["gnt-instance", "migrate", "--force", instance["name"]] cmd = ["gnt-instance", "migrate", "--force", instance["name"]]
af_par = constants.BE_ALWAYS_FAILOVER af_par = constants.BE_ALWAYS_FAILOVER
af_field = "be/" + constants.BE_ALWAYS_FAILOVER af_field = "be/" + constants.BE_ALWAYS_FAILOVER
...@@ -459,6 +484,11 @@ def TestInstanceStoppedModify(instance): ...@@ -459,6 +484,11 @@ def TestInstanceStoppedModify(instance):
def TestInstanceConvertDisk(instance, snode): def TestInstanceConvertDisk(instance, snode):
"""gnt-instance modify -t""" """gnt-instance modify -t"""
name = instance["name"] name = instance["name"]
template = qa_config.GetInstanceTemplate(instance)
if template != "drbd":
print qa_utils.FormatInfo("Unsupported template %s, skipping conversion"
" test" % template)
return
AssertCommand(["gnt-instance", "modify", "-t", "plain", name]) AssertCommand(["gnt-instance", "modify", "-t", "plain", name])
AssertCommand(["gnt-instance", "modify", "-t", "drbd", AssertCommand(["gnt-instance", "modify", "-t", "drbd",
"-n", snode["primary"], name]) "-n", snode["primary"], name])
...@@ -467,6 +497,9 @@ def TestInstanceConvertDisk(instance, snode): ...@@ -467,6 +497,9 @@ def TestInstanceConvertDisk(instance, snode):
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG) @InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
def TestInstanceGrowDisk(instance): def TestInstanceGrowDisk(instance):
"""gnt-instance grow-disk""" """gnt-instance grow-disk"""
if qa_config.GetExclusiveStorage():
print qa_utils.FormatInfo("Test not supported with exclusive_storage")
return
name = instance["name"] name = instance["name"]
all_size = qa_config.get("disk") all_size = qa_config.get("disk")
all_grow = qa_config.get("disk-growth") all_grow = qa_config.get("disk-growth")
...@@ -515,6 +548,11 @@ def TestReplaceDisks(instance, pnode, snode, othernode): ...@@ -515,6 +548,11 @@ def TestReplaceDisks(instance, pnode, snode, othernode):
cmd.append(instance["name"]) cmd.append(instance["name"])
return cmd return cmd
if not IsDiskReplacingSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support disk replacing,"
" skipping test")
return
options = qa_config.get("options", {}) options = qa_config.get("options", {})
use_ialloc = options.get("use-iallocators", True) use_ialloc = options.get("use-iallocators", True)
for data in [ for data in [
......
...@@ -46,6 +46,9 @@ import qa_config ...@@ -46,6 +46,9 @@ import qa_config
import qa_utils import qa_utils
import qa_error import qa_error
from qa_instance import IsFailoverSupported
from qa_instance import IsMigrationSupported
from qa_instance import IsDiskReplacingSupported
from qa_utils import (AssertEqual, AssertIn, AssertMatch, StartLocalCommand) from qa_utils import (AssertEqual, AssertIn, AssertMatch, StartLocalCommand)
from qa_utils import InstanceCheck, INST_DOWN, INST_UP, FIRST_ARG from qa_utils import InstanceCheck, INST_DOWN, INST_UP, FIRST_ARG
...@@ -617,6 +620,10 @@ def TestRapiInstanceRemove(instance, use_client): ...@@ -617,6 +620,10 @@ def TestRapiInstanceRemove(instance, use_client):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestRapiInstanceMigrate(instance): def TestRapiInstanceMigrate(instance):
"""Test migrating instance via RAPI""" """Test migrating instance via RAPI"""
if not IsMigrationSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support migration, skipping"
" test")
return
# Move to secondary node # Move to secondary node
_WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"])) _WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"]))
qa_utils.RunInstanceCheck(instance, True) qa_utils.RunInstanceCheck(instance, True)
...@@ -627,6 +634,10 @@ def TestRapiInstanceMigrate(instance): ...@@ -627,6 +634,10 @@ def TestRapiInstanceMigrate(instance):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestRapiInstanceFailover(instance): def TestRapiInstanceFailover(instance):
"""Test failing over instance via RAPI""" """Test failing over instance via RAPI"""
if not IsFailoverSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support failover, skipping"
" test")
return
# Move to secondary node # Move to secondary node
_WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"])) _WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"]))
qa_utils.RunInstanceCheck(instance, True) qa_utils.RunInstanceCheck(instance, True)
...@@ -676,6 +687,10 @@ def TestRapiInstanceReinstall(instance): ...@@ -676,6 +687,10 @@ def TestRapiInstanceReinstall(instance):
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG) @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestRapiInstanceReplaceDisks(instance): def TestRapiInstanceReplaceDisks(instance):
"""Test replacing instance disks via RAPI""" """Test replacing instance disks via RAPI"""
if not IsDiskReplacingSupported(instance):
print qa_utils.FormatInfo("Instance doesn't support disk replacing,"
" skipping test")
return
fn = _rapi_client.ReplaceInstanceDisks fn = _rapi_client.ReplaceInstanceDisks
_WaitForRapiJob(fn(instance["name"], _WaitForRapiJob(fn(instance["name"],
mode=constants.REPLACE_DISK_AUTO, disks=[])) mode=constants.REPLACE_DISK_AUTO, disks=[]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment