From 677e16eb3cdb54cd55f04d56456ed1f14c5d1d30 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 6 Oct 2010 13:41:49 +0200
Subject: [PATCH] QA: Fix instance move tests

The instance move tests were moving the instance from node pair (A,_) to
(B, A), and left it there. This patch makes sure that the first step
moves the instance to (B,A) but the second one back to (A,B), so that
the instance is left on the same primary node.

The original secondary node is lost though, if I read the code
correctly.

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

diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 070a1b34a..b06155f35 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -234,7 +234,7 @@ def RunExportImportTests(instance, pnode):
       pnode2 = qa_config.AcquireNode(exclude=pnode)
       try:
         RunTest(qa_rapi.TestInterClusterInstanceMove, instance, newinst,
-                pnode2, pnode)
+                pnode, pnode2)
       finally:
         qa_config.ReleaseNode(pnode2)
     finally:
diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py
index 5f679567b..add87e405 100644
--- a/qa/qa_rapi.py
+++ b/qa/qa_rapi.py
@@ -1,6 +1,6 @@
 #
 
-# Copyright (C) 2007, 2008 Google Inc.
+# Copyright (C) 2007, 2008, 2009, 2010 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
@@ -405,22 +405,26 @@ def TestInterClusterInstanceMove(src_instance, dest_instance, pnode, snode):
   rapi_pw_file.flush()
 
   # TODO: Run some instance tests before moving back
-  for srcname, destname in [(src_instance["name"], dest_instance["name"]),
-                            (dest_instance["name"], src_instance["name"])]:
+
+  # note: pnode is the *current* primary node, so we move it first to
+  # snode, then back
+  for si, di, pn, sn in [(src_instance["name"], dest_instance["name"],
+                          snode["primary"], pnode["primary"]),
+                         (dest_instance["name"], src_instance["name"],
+                          pnode["primary"], snode["primary"])]:
     cmd = [
       "../tools/move-instance",
       "--verbose",
       "--src-ca-file=%s" % _rapi_ca.name,
       "--src-username=%s" % _rapi_username,
       "--src-password-file=%s" % rapi_pw_file.name,
-      "--dest-instance-name=%s" % destname,
-      "--dest-primary-node=%s" % pnode["primary"],
-      "--dest-secondary-node=%s" % snode["primary"],
+      "--dest-instance-name=%s" % di,
+      "--dest-primary-node=%s" % pn,
+      "--dest-secondary-node=%s" % sn,
       "--net=0:mac=%s" % constants.VALUE_GENERATE,
-
       master["primary"],
       master["primary"],
-      srcname,
+      si,
       ]
 
     AssertEqual(StartLocalCommand(cmd).wait(), 0)
-- 
GitLab