]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
tests: fix *_has_correct_value tests
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 19 Jun 2018 16:08:10 +0000 (18:08 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 21 Jun 2018 15:24:46 +0000 (17:24 +0200)
It might happen that the list of ips/hosts in following line (ceph.conf)
- `mon initial memebers = <hosts>`
- `mon host = <ips>`

are not ordered the same way depending on deployment.

This patch makes the tests looking for each ip or hostname in respective
lines.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit f68936ca7e7f556c8d8cee8b2c4565a3c94f72f9)
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
tests/functional/tests/mon/test_mons.py
tests/functional/tests/test_install.py

index d15cda38655a5533132a931429930880182bffe3..638112e22829328dca03f758c588fc4c8fafcba3 100644 (file)
@@ -1,5 +1,5 @@
 import pytest
-
+import re
 
 class TestMons(object):
 
@@ -31,11 +31,14 @@ class TestMons(object):
     def test_ceph_config_has_inital_members_line(self, node, File):
         assert File(node["conf_path"]).contains("^mon initial members = .*$")
 
-    def test_initial_members_line_has_correct_value(self, node, File):
-        mons = ",".join("%s" % host
-                        for host in node["vars"]["groups"]["mons"])
-        line = "mon initial members = {}".format(mons)
-        assert File(node["conf_path"]).contains(line)
+    def test_initial_members_line_has_correct_value(self, node, host, File):
+        mon_initial_members_line = host.check_output("grep 'mon initial members = ' /etc/ceph/{cluster}.conf".format(cluster=node['cluster_name']))
+        result = True
+        for host in node["vars"]["groups"]["mons"]:
+            pattern = re.compile(host)
+            if pattern.search(mon_initial_members_line) == None:
+                result = False
+                assert result
 
 
 class TestOSDs(object):
index 33a8205b25610f78ef1db31242405d4db180bbcc..4300ab2b4fb20766adebe131e1bb14e52ead2576 100644 (file)
@@ -1,5 +1,5 @@
 import pytest
-
+import re
 
 class TestInstall(object):
 
@@ -26,8 +26,10 @@ class TestCephConf(object):
         assert File(node["conf_path"]).contains("^mon host = .*$")
 
     def test_mon_host_line_has_correct_value(self, node, host):
-        mon_ips = []
+        mon_host_line = host.check_output("grep 'mon host = ' /etc/ceph/{cluster}.conf".format(cluster=node['cluster_name']))
+        result=True
         for x in range(0, node["num_mons"]):
-            mon_ips.append("{}.1{}".format(node["subnet"], x))
-        line = "mon host = {}".format(",".join(mon_ips))
-        assert host.file(node["conf_path"]).contains(line)
+            pattern=re.compile(("{}.1{}".format(node["subnet"], x)))
+            if pattern.search(mon_host_line) == None:
+                result=False
+            assert result