Skip to content
Snippets Groups Projects
Commit d0a44ec0 authored by Klaus Aehlig's avatar Klaus Aehlig Committed by Guido Trotter
Browse files

Add QA for gnt-instance modify --new-primary


Add a simple walk through the intended use case of
gnt-instance modify --new-primary for the disk template
file. The tested scenario is shutting down an instance,
manually moving the disk to the new node, setting the
new primary, and starting up the instance on the new
node. It is also verified that the operation is rejected
while the instance is still running on the old node.

Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 6970c89c
No related branches found
No related tags found
No related merge requests found
......@@ -602,6 +602,11 @@ def RunInstanceTests():
instance, inodes)
RunTest(qa_instance.TestInstanceStartup, instance)
RunCommonInstanceTests(instance)
if qa_config.TestEnabled("instance-modify-primary"):
othernode = qa_config.AcquireNode()
RunTest(qa_instance.TestInstanceModifyPrimaryAndBack,
instance, inodes[0], othernode)
othernode.Release()
RunGroupListTests()
RunExportImportTests(instance, inodes)
RunHardwareFailureTests(instance, inodes)
......
......@@ -185,6 +185,7 @@
"instance-list": true,
"instance-migrate": true,
"instance-modify": true,
"instance-modify-primary": true,
"instance-reboot": true,
"instance-reinstall": true,
"instance-rename": true,
......
......@@ -24,6 +24,7 @@
"""
import operator
import os
import re
from ganeti import utils
......@@ -573,6 +574,38 @@ def TestInstanceModify(instance):
AssertCommand(["gnt-instance", "modify", "--online", instance.name])
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
def TestInstanceModifyPrimaryAndBack(instance, currentnode, othernode):
"""gnt-instance modify --new-primary
This will leave the instance on its original primary node, not other node.
"""
if instance.disk_template != constants.DT_FILE:
print qa_utils.FormatInfo("Test only supported for the file disk template")
return
name = instance.name
current = currentnode.primary
other = othernode.primary
filestorage = qa_config.get("file-storage-dir")
disk = os.path.join(filestorage, name)
AssertCommand(["gnt-instance", "modify", "--new-primary=%s" % other, name],
fail=True)
AssertCommand(["gnt-instance", "shutdown", name])
AssertCommand(["scp", "-r", disk, "%s:%s" % (other, filestorage)])
AssertCommand(["gnt-instance", "modify", "--new-primary=%s" % other, name])
AssertCommand(["gnt-instance", "startup", name])
# and back
AssertCommand(["gnt-instance", "shutdown", name])
AssertCommand(["rm", "-rf", disk], node=other)
AssertCommand(["gnt-instance", "modify", "--new-primary=%s" % current, name])
AssertCommand(["gnt-instance", "startup", name])
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
def TestInstanceStoppedModify(instance):
"""gnt-instance modify (stopped 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