As by now a new master candidate node is generated quite
often, we add a function for it to remove some duplicate
code.

Signed-off-by: Helga Velroyen <[email protected]>
---
 test/py/ganeti.backend_unittest.py | 52 ++++++++++++--------------------------
 1 file changed, 16 insertions(+), 36 deletions(-)

diff --git a/test/py/ganeti.backend_unittest.py 
b/test/py/ganeti.backend_unittest.py
index 3c207f8..804cd63 100755
--- a/test/py/ganeti.backend_unittest.py
+++ b/test/py/ganeti.backend_unittest.py
@@ -1095,13 +1095,13 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
 
     self._ssh_port_map[name] = self._SSH_PORT
 
+  def _GetNewMasterCandidate(self):
+    """Returns the properties of a new master candidate node."""
+    return ("new_node_name", "new_node_uuid", "new_node_key", True, True, 
False)
+
   def testAddMasterCandidate(self):
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     self._AddNewNodeToTestData(
         new_node_name, new_node_uuid, new_node_key,
@@ -1339,12 +1339,8 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
             if '3' not in name and '5' not in name]
 
   def testAddKeyWithOfflineNodes(self):
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     self._AddNewNodeToTestData(
         new_node_name, new_node_uuid, new_node_key,
@@ -1408,12 +1404,8 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     takes a couple of retries to succeed.
 
     """
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     self._AddNewNodeToTestData(
         new_node_name, new_node_uuid, new_node_key,
@@ -1445,12 +1437,8 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     successfully rolled back and thus the state of the cluster is cleaned up.
 
     """
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     self._AddNewNodeToTestData(
         new_node_name, new_node_uuid, new_node_key,
@@ -1488,12 +1476,8 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     to succeed.
 
     """
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     other_node_name, _, _, _, _, _ = self._ssh_file_manager \
         .GetAllMasterCandidates()[0]
@@ -1527,12 +1511,8 @@ class 
TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     updated.
 
     """
-    new_node_name = "new_node_name"
-    new_node_uuid = "new_node_uuid"
-    new_node_key = "new_node_key"
-    is_master_candidate = True
-    is_potential_master_candidate = True
-    is_master = False
+    (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
+     is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
 
     other_node_name, _, _, _, _, _ = self._ssh_file_manager \
         .GetAllMasterCandidates()[0]
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to