From 18337ca9d3220d5fa632f11e55981b2521b858a7 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 9 Feb 2010 10:30:40 +0100
Subject: [PATCH] Implement instance rename QA tests

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 qa/ganeti-qa.py   |  5 +++++
 qa/qa-sample.json | 13 +++++++------
 qa/qa_instance.py | 17 +++++++++++++++++
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 5c399e72c..a7f34509d 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -157,6 +157,11 @@ def RunCommonInstanceTests(instance):
   if qa_config.TestEnabled('instance-reboot'):
     RunTest(qa_instance.TestInstanceReboot, instance)
 
+  if qa_config.TestEnabled('instance-rename'):
+    RunTest(qa_instance.TestInstanceShutdown, instance)
+    RunTest(qa_instance.TestInstanceRename, instance)
+    RunTest(qa_instance.TestInstanceStartup, instance)
+
   if qa_config.TestEnabled('tags'):
     RunTest(qa_tags.TestInstanceTags, instance)
 
diff --git a/qa/qa-sample.json b/qa/qa-sample.json
index f051ec9b2..d167e06e9 100644
--- a/qa/qa-sample.json
+++ b/qa/qa-sample.json
@@ -62,17 +62,18 @@
     "instance-add-plain-disk": true,
     "instance-add-drbd-disk": true,
 
-    "instance-list": true,
+    "instance-automatic-restart": false,
+    "instance-consecutive-failures": false,
+    "instance-export": true,
     "instance-failover": true,
+    "instance-import": true,
     "instance-info": true,
+    "instance-list": true,
     "instance-modify": true,
-    "instance-export": true,
-    "instance-import": true,
-    "instance-reinstall": true,
     "instance-reboot": true,
+    "instance-reinstall": true,
+    "instance-rename": true,
     "instance-shutdown": true,
-    "instance-automatic-restart": false,
-    "instance-consecutive-failures": false,
 
     "# This test might fail with certain hypervisor types, depending": null,
     "# on whether they support the `gnt-instance console' command.": null,
diff --git a/qa/qa_instance.py b/qa/qa_instance.py
index af3afeb6a..8552e2686 100644
--- a/qa/qa_instance.py
+++ b/qa/qa_instance.py
@@ -127,6 +127,23 @@ def TestInstanceReinstall(instance):
                        utils.ShellQuoteArgs(cmd)).wait(), 0)
 
 
+def TestInstanceRename(instance):
+  """gnt-instance rename"""
+  master = qa_config.GetMasterNode()
+
+  rename_source = instance['name']
+  rename_target = qa_config.get('rename', None)
+  if rename_target is None:
+    print qa_utils.FormatError('"rename" entry is missing')
+    return
+
+  for name1, name2 in [(rename_source, rename_target),
+                       (rename_target, rename_source)]:
+    cmd = ['gnt-instance', 'rename', name1, name2]
+    AssertEqual(StartSSH(master['primary'],
+                         utils.ShellQuoteArgs(cmd)).wait(), 0)
+
+
 def TestInstanceFailover(instance):
   """gnt-instance failover"""
   master = qa_config.GetMasterNode()
-- 
GitLab