Commit 4c1a464b authored by Iustin Pop's avatar Iustin Pop

Rework instance rename QA tests

After looking again at the QA speeds, it turned out that instance
rename was run 12 times via the command line and 12 times via RAPI;
outside of start/stop which we need for maintenance during QA, this is
the most used test.

This patch does a few changes with regard to instance rename:

- it changes rename functions to rename the instance back to the
  original name
- which allows us not to run said functions twice, A→B and then B→A

This brings down the number of rename tests from 12 to 8 (for both
cmdline and RAPI).

Furthermore, the CLI rename test was doing too many actual instance
renames (at Ganeti level), so we rework it to be simpler (brings down
the average duration from ~27s to ~21s), and we reorganise the run of
various tests such that we do fewer instances start/stop tests (10
instead of 14).

Overall we only gain about 3 minutes (~7%), but still it's a speedup.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 468b828e
......@@ -245,31 +245,38 @@ def RunCommonInstanceTests(instance):
RunTestIf(["instance-console", "rapi"],
qa_rapi.TestRapiInstanceConsole, instance)
RunTestIf("instance-reinstall", qa_instance.TestInstanceShutdown, instance)
DOWN_TESTS = ["instance-reinstall", "instance-rename"]
# shutdown instance for any 'down' tests
RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance)
# now run the 'down' state tests
RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
RunTestIf(["instance-reinstall", "rapi"],
qa_rapi.TestRapiInstanceReinstall, instance)
RunTestIf("instance-reinstall", qa_instance.TestInstanceStartup, instance)
RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
# RAPI reinstall will leave the instance up by default, so we have
# to stop it again
RunTestIf(["instance-reinstall", "rapi"],
qa_rapi.TestRapiInstanceShutdown, instance)
if qa_config.TestEnabled("instance-rename"):
rename_source = instance["name"]
rename_target = qa_config.get("rename", None)
RunTest(qa_instance.TestInstanceShutdown, instance)
# perform instance rename to the same name
RunTest(qa_instance.TestInstanceRename, rename_source, rename_source)
RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
RunTest(qa_instance.TestInstanceRenameAndBack,
rename_source, rename_source)
RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
rename_source, rename_source)
if rename_target is not None:
# perform instance rename to a different name, if we have one configured
RunTest(qa_instance.TestInstanceRename, rename_source, rename_target)
RunTest(qa_instance.TestInstanceRename, rename_target, rename_source)
RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
RunTest(qa_instance.TestInstanceRenameAndBack,
rename_source, rename_target)
RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
rename_source, rename_target)
RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
rename_target, rename_source)
RunTest(qa_instance.TestInstanceStartup, instance)
# and now start the instance again
RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance)
RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
RunTestIf("tags", qa_tags.TestInstanceTags, instance)
......
#
#
# Copyright (C) 2007, 2011 Google Inc.
# Copyright (C) 2007, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -147,13 +147,15 @@ def _CheckSsconfInstanceList(instance):
_ReadSsconfInstanceList())
def TestInstanceRename(rename_source, rename_target):
"""gnt-instance rename"""
_CheckSsconfInstanceList(rename_source)
AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
_CheckSsconfInstanceList(rename_target)
AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
def TestInstanceRenameAndBack(rename_source, rename_target):
"""gnt-instance rename
This must leave the instance with the original name, not the target
name.
"""
_CheckSsconfInstanceList(rename_source)
# first do a rename to a different actual name, expecting it to fail
qa_utils.AddToEtcHosts(["meeeeh-not-exists", rename_target])
try:
AssertCommand(["gnt-instance", "rename", rename_source, rename_target],
......@@ -161,8 +163,12 @@ def TestInstanceRename(rename_source, rename_target):
_CheckSsconfInstanceList(rename_source)
finally:
qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
# and now rename instance to rename_target...
AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
_CheckSsconfInstanceList(rename_target)
# and back
AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
_CheckSsconfInstanceList(rename_source)
def TestInstanceFailover(instance):
......
#
#
# Copyright (C) 2007, 2008, 2009, 2010, 2011 Google Inc.
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -609,9 +609,15 @@ def TestRapiInstanceStartup(instance):
_WaitForRapiJob(_rapi_client.StartupInstance(instance["name"]))
def TestRapiInstanceRename(rename_source, rename_target):
"""Test renaming instance via RAPI"""
def TestRapiInstanceRenameAndBack(rename_source, rename_target):
"""Test renaming instance via RAPI
This must leave the instance with the original name (in the
non-failure case).
"""
_WaitForRapiJob(_rapi_client.RenameInstance(rename_source, rename_target))
_WaitForRapiJob(_rapi_client.RenameInstance(rename_target, rename_source))
def TestRapiInstanceReinstall(instance):
......
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