summaryrefslogtreecommitdiffstats
path: root/tests/test_discovery.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_discovery.py')
-rw-r--r--tests/test_discovery.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index c3a1329..7869a2e 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -194,3 +194,22 @@ class TestDiscovery(TestCaseBase):
'gluster_auto_discovery!10.70.43.57!10.70.43.57'})
hostConfig = {HOST_SERVICES: hostServices}
return hostConfig
+
+ def mockGetUuidToHostConfigDict(self):
+ hostDict = {}
+ hostDict['0001'] = {'host_name': 'old-host1'}
+ hostDict['0002'] = {'host_name': 'old-host2'}
+ hostDict['0003'] = {'host_name': 'old-host3'}
+ return hostDict
+
+ def testReplaceHostNamesWithCurrentName(self):
+ server_utils.getUuidToHostConfigDict = self.mockGetUuidToHostConfigDict
+ clusterData = [{'uuid': '0001', 'hostname': 'new-host1'},
+ {'uuid': '0002', 'hostname': 'new-host2'},
+ {'uuid': '0004', 'hostname': 'new-host4'},
+ {'uuid': '0005', 'hostname': 'new-host5'}]
+ discovery.replaceHostNamesWithCurrentName(clusterData)
+ self.assertEqual(clusterData[0]['hostname'], 'old-host1')
+ self.assertEqual(clusterData[1]['hostname'], 'old-host2')
+ self.assertEqual(clusterData[2]['hostname'], 'new-host4')
+ self.assertEqual(clusterData[3]['hostname'], 'new-host5')