]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
tests: test `test_all_docker_osds_are_up_and_in()` from mon nodes v3.2.0beta6
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 16 Oct 2018 14:25:12 +0000 (16:25 +0200)
committerSébastien Han <seb@redhat.com>
Wed, 17 Oct 2018 15:07:25 +0000 (17:07 +0200)
Let's get the osd tree from mons instead on osds.
This way we don't have to predict an OSD container name.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
tests/functional/tests/mon/test_osds_from_mons.py [new file with mode: 0644]
tests/functional/tests/osd/test_osds.py

diff --git a/tests/functional/tests/mon/test_osds_from_mons.py b/tests/functional/tests/mon/test_osds_from_mons.py
new file mode 100644 (file)
index 0000000..f8eeab7
--- /dev/null
@@ -0,0 +1,28 @@
+import pytest
+import json
+
+
+class TestOsdsFromMons(object):
+    def _get_nb_osd_up(self, osd_tree):
+        nb_up = 0
+        for n in osd_tree['nodes']:
+            if n['type'] == 'osd' and n['status'] == 'up':
+                nb_up += 1
+        return nb_up
+
+    @pytest.mark.no_docker
+    def test_all_osds_are_up_and_in(self, node, host):
+        cmd = "sudo ceph --cluster={cluster} --connect-timeout 5 osd tree -f json".format(cluster=node["cluster_name"])
+        output = json.loads(host.check_output(cmd))
+        nb_osd_up = self._get_nb_osd_up(output)
+        assert int(node["num_osds"]) == int(nb_osd_up)
+
+    @pytest.mark.docker
+    def test_all_docker_osds_are_up_and_in(self, node, host):
+        cmd = "sudo docker exec ceph-mon-{inventory_hostname} ceph --cluster={cluster} --connect-timeout 5 osd tree -f json".format(
+            cluster=node["cluster_name"],
+            inventory_hostname=node['vars']['inventory_hostname']
+        )
+        output = json.loads(host.check_output(cmd))
+        nb_osd_up = self._get_nb_osd_up(output)
+        assert node["num_osds"] == nb_osd_up
index 851c7d7f520117661bdb2750c5a1b726fe3778b1..20fbeacb48d1de9e00bd95d3008f238217980e2f 100644 (file)
@@ -47,40 +47,3 @@ class TestOSDs(object):
     @pytest.mark.lvm_scenario
     def test_ceph_volume_systemd_is_installed(self, node, host):
         host.exists('ceph-volume-systemd')
-
-    def _get_osd_id_from_host(self, node, osd_tree):
-        children = []
-        for n in osd_tree['nodes']:
-            if n['name'] == node['vars']['inventory_hostname'] and n['type'] == 'host':
-                children = n['children']
-        return children
-
-    def _get_nb_up_osds_from_ids(self, node, osd_tree):
-        nb_up = 0
-        ids = self._get_osd_id_from_host(node, osd_tree)
-        for n in osd_tree['nodes']:
-            if n['id'] in ids and n['status'] == 'up':
-                nb_up += 1
-        return nb_up
-
-    @pytest.mark.no_docker
-    def test_all_osds_are_up_and_in(self, node, host):
-        cmd = "sudo ceph --cluster={cluster} --connect-timeout 5 --keyring /var/lib/ceph/bootstrap-osd/{cluster}.keyring -n client.bootstrap-osd osd tree -f json".format(cluster=node["cluster_name"])
-        output = json.loads(host.check_output(cmd))
-        assert node["num_osds"] == self._get_nb_up_osds_from_ids(node, output)
-
-    @pytest.mark.docker
-    def test_all_docker_osds_are_up_and_in(self, node, host):
-        osd_scenario = node["vars"].get('osd_scenario', False)
-        if osd_scenario in ['lvm', 'lvm-batch']:
-            osd_id = "0"
-        else:
-            hostname = node["vars"]["inventory_hostname"]
-            osd_id = os.path.join(hostname+"-sda")
-
-        cmd = "sudo docker exec ceph-osd-{osd_id} ceph --cluster={cluster} --connect-timeout 5 --keyring /var/lib/ceph/bootstrap-osd/{cluster}.keyring -n client.bootstrap-osd osd tree -f json".format(
-            osd_id=osd_id,
-            cluster=node["cluster_name"]
-        )
-        output = json.loads(host.check_output(cmd))
-        assert node["num_osds"] == self._get_nb_up_osds_from_ids(node, output)