From caea3b321d2c44f5a7cadbb36731ad9ef93e9293 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 29 Feb 2008 15:33:27 +0000
Subject: [PATCH] Implement QA tests for gnt-cluster rename

Reviewed-by: imsnah
---
 qa/ganeti-qa.py   |  3 +++
 qa/qa-sample.yaml |  2 ++
 qa/qa_cluster.py  | 31 +++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 42b95b843..5f6c1047c 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -91,6 +91,9 @@ def RunClusterTests():
   if qa_config.TestEnabled('cluster-verify'):
     RunTest(qa_cluster.TestClusterVerify)
 
+  if qa_config.TestEnabled('cluster-rename'):
+    RunTest(qa_cluster.TestClusterRename)
+
   if qa_config.TestEnabled('cluster-info'):
     RunTest(qa_cluster.TestClusterVersion)
     RunTest(qa_cluster.TestClusterInfo)
diff --git a/qa/qa-sample.yaml b/qa/qa-sample.yaml
index 57fe764b5..cbb482879 100644
--- a/qa/qa-sample.yaml
+++ b/qa/qa-sample.yaml
@@ -1,5 +1,6 @@
 # Cluster name
 name: xen-test
+rename: xen-test-rename
 hypervisor-type: xen-3.0
 
 # System to use
@@ -36,6 +37,7 @@ tests:
   cluster-copyfile: True
   cluster-master-failover: True
   cluster-destroy: True
+  cluster-rename: True
 
   node-info: True
   node-volumes: True
diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py
index 70d1c4386..dfd6efed3 100644
--- a/qa/qa_cluster.py
+++ b/qa/qa_cluster.py
@@ -79,6 +79,37 @@ def TestClusterInit():
                        utils.ShellQuoteArgs(cmd)).wait(), 0)
 
 
+@qa_utils.DefineHook('cluster-rename')
+def TestClusterRename():
+  """gnt-cluster rename"""
+  master = qa_config.GetMasterNode()
+
+  cmd = ['gnt-cluster', 'rename', '-f']
+
+  original_name = qa_config.get('name')
+  rename_target = qa_config.get('rename', None)
+  if rename_target is None:
+    print qa_utils.FormatError('"rename" entry is missing')
+    return
+
+  cmd_1 = cmd + [rename_target]
+  cmd_2 = cmd + [original_name]
+
+  cmd_verify = ['gnt-cluster', 'verify']
+
+  AssertEqual(StartSSH(master['primary'],
+                       utils.ShellQuoteArgs(cmd_1)).wait(), 0)
+
+  AssertEqual(StartSSH(master['primary'],
+                       utils.ShellQuoteArgs(cmd_verify)).wait(), 0)
+
+  AssertEqual(StartSSH(master['primary'],
+                       utils.ShellQuoteArgs(cmd_2)).wait(), 0)
+
+  AssertEqual(StartSSH(master['primary'],
+                       utils.ShellQuoteArgs(cmd_verify)).wait(), 0)
+
+
 @qa_utils.DefineHook('cluster-verify')
 def TestClusterVerify():
   """gnt-cluster verify"""
-- 
GitLab