From 69df9d2b98b4986fb9bf3877f502658e1236b942 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 11 Jan 2011 18:50:15 +0100
Subject: [PATCH] QA: Fix duplicated OOB tests

Patch f55312bd added the OOB tests to TestClusterVerify, which is not
actually a test for cluster verify, but a runner for cluster verify
that is called multiple times, for each instance type, etc. This led
to running the OOB commands multiple times, which is painful
especially as this is a slow test.

The patch moves this to a separate test, that is run only once.

Furthermore, the way that data files are copied around is very
inefficient: touch + mv + chmod + mv + rm for each node (5 times
number of nodes), whereas it could be simply: touch on master, chmod
on master, cluster copyfile, chmod on master, cluster copyfile,
cluster command rm, i.e. only 5 fixed ssh calls to the master. The
code is changed as such, for increased speed.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 qa/ganeti-qa.py  |  1 +
 qa/qa_cluster.py | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index ed56dec97..3d6163414 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -164,6 +164,7 @@ def RunClusterTests():
     ("cluster-command", qa_cluster.TestClusterCommand),
     ("cluster-burnin", qa_cluster.TestClusterBurnin),
     ("cluster-master-failover", qa_cluster.TestClusterMasterFailover),
+    ("cluster-oob", qa_cluster.TestClusterOob),
     ("rapi", qa_rapi.TestVersion),
     ("rapi", qa_rapi.TestEmptyCluster),
     ]:
diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py
index 89159a72c..296f7c763 100644
--- a/qa/qa_cluster.py
+++ b/qa/qa_cluster.py
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2007, 2010 Google Inc.
+# Copyright (C) 2007, 2010, 2011 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
@@ -118,8 +118,8 @@ def TestClusterRename():
     AssertCommand(data)
 
 
-def TestClusterVerify():
-  """gnt-cluster verify"""
+def TestClusterOob():
+  """out-of-band framework"""
   oob_path_exists = "/tmp/ganeti-qa-oob-does-exist-%s" % utils.NewUUID()
 
   AssertCommand(["gnt-cluster", "verify"])
@@ -129,10 +129,9 @@ def TestClusterVerify():
 
   AssertCommand(["gnt-cluster", "verify"], fail=True)
 
-  for node in qa_config.get("nodes"):
-    node_name = node["primary"]
-    remote_file = qa_utils.UploadData(node_name, "", mode=0400)
-    AssertCommand(["mv", remote_file, oob_path_exists], node=node_name)
+  AssertCommand(["touch", oob_path_exists])
+  AssertCommand(["chmod", "0400", oob_path_exists])
+  AssertCommand(["gnt-cluster", "copyfile", oob_path_exists])
 
   try:
     AssertCommand(["gnt-cluster", "modify", "--node-parameters",
@@ -140,18 +139,19 @@ def TestClusterVerify():
 
     AssertCommand(["gnt-cluster", "verify"], fail=True)
 
-    for node in qa_config.get("nodes"):
-      node_name = node["primary"]
-      AssertCommand(["chmod", "0500", oob_path_exists], node=node_name)
+    AssertCommand(["chmod", "0500", oob_path_exists])
+    AssertCommand(["gnt-cluster", "copyfile", oob_path_exists])
 
     AssertCommand(["gnt-cluster", "verify"])
   finally:
-    for node in qa_config.get("nodes"):
-      node_name = node["primary"]
-      AssertCommand(["rm", oob_path_exists], node=node_name)
+    AssertCommand(["gnt-cluster", "command", "rm", oob_path_exists])
 
   AssertCommand(["gnt-cluster", "modify", "--node-parameters",
                  "oob_program="])
+
+
+def TestClusterVerify():
+  """gnt-cluster verify"""
   AssertCommand(["gnt-cluster", "verify"])
 
 
-- 
GitLab