Unit test bulk-adding normal nodes
authorHelga Velroyen <helgav@google.com>
Thu, 12 Nov 2015 10:06:26 +0000 (11:06 +0100)
committerHelga Velroyen <helgav@google.com>
Tue, 17 Nov 2015 15:35:58 +0000 (16:35 +0100)
This patch adds a unit test that tests adding a bulk
of normal nodes' SSH keys to the cluster.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

test/py/ganeti.backend_unittest.py

index 3e06399..6185592 100755 (executable)
@@ -1095,6 +1095,13 @@ class TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
             "new_node_key_%s" % num,
             False, True, False)
 
+  def _GetNewNumberedNormalNode(self, num):
+    """Returns the properties of a new normal node."""
+    return ("new_node_name_%s" % num,
+            "new_node_uuid_%s" % num,
+            "new_node_key_%s" % num,
+            False, False, False)
+
   def testAddMasterCandidate(self):
     (new_node_name, new_node_uuid, new_node_key, is_master_candidate,
      is_potential_master_candidate, is_master) = self._GetNewMasterCandidate()
@@ -1243,6 +1250,25 @@ class TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     self._ssh_file_manager.AssertNoNodeHasPublicKey(new_node_uuid, new_node_key)
     self._ssh_file_manager.AssertNoNodeHasAuthorizedKey(new_node_key)
 
+  def testAddNormalBulk(self):
+    num_nodes = 3
+    (node_list, key_map) = self._SetupNodeBulk(
+        num_nodes, self._GetNewNumberedNormalNode)
+
+    self.assertRaises(
+        AssertionError, backend.AddNodeSshKeyBulk, node_list,
+        self._potential_master_candidates,
+        pub_key_file=self._pub_key_file,
+        ssconf_store=self._ssconf_mock,
+        noded_cert_file=self.noded_cert_file,
+        run_cmd_fn=self._run_cmd_mock)
+
+    for node_info in node_list:
+      self._ssh_file_manager.AssertNoNodeHasPublicKey(
+          node_info.uuid, key_map[node_info.name])
+      self._ssh_file_manager.AssertNoNodeHasAuthorizedKey(
+          key_map[node_info.name])
+
   def testPromoteToMasterCandidate(self):
     # Get one of the potential master candidates
     node_name, node_info = \