Add QA for gnt-instance modify --new-primary
authorKlaus Aehlig <aehlig@google.com>
Thu, 14 Mar 2013 11:52:49 +0000 (12:52 +0100)
committerGuido Trotter <ultrotter@google.com>
Tue, 2 Apr 2013 11:02:05 +0000 (13:02 +0200)
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: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

qa/ganeti-qa.py
qa/qa-sample.json
qa/qa_instance.py

index e7f14ff..5ffd44f 100755 (executable)
@@ -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)
index d4bf9bd..59af154 100644 (file)
     "instance-list": true,
     "instance-migrate": true,
     "instance-modify": true,
+    "instance-modify-primary": true,
     "instance-reboot": true,
     "instance-reinstall": true,
     "instance-rename": true,
index 4607294..d3b2f25 100644 (file)
@@ -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)"""