]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
testinfra: add support for podman
authorSébastien Han <seb@redhat.com>
Mon, 19 Nov 2018 10:03:45 +0000 (11:03 +0100)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Tue, 27 Nov 2018 16:47:40 +0000 (16:47 +0000)
Since we are now testing on docker and podman our functionnal tests must
reflect that. So now, if we detect the podman binary we will use it,
otherwise we default to docker.

Signed-off-by: Sébastien Han <seb@redhat.com>
tests/functional/tests/mds/test_mds.py
tests/functional/tests/mgr/test_mgr.py
tests/functional/tests/nfs/test_nfs_ganesha.py
tests/functional/tests/osd/test_osds.py
tests/functional/tests/rbd-mirror/test_rbd_mirror.py
tests/functional/tests/rgw/test_rgw.py
tests/functional/tests/rgw/test_rgw_tuning.py

index 716e4884b107d53c40bb2282710a6104fd63ca01..f0c3f32cc1ffd1a00d131693b4474753f2c05a52 100644 (file)
@@ -22,7 +22,11 @@ class TestMDSs(object):
     def test_mds_is_up(self, node, host):
         hostname = node["vars"]["inventory_hostname"]
         if node['docker']:
-            docker_exec_cmd = 'docker exec ceph-mds-{hostname}'.format(hostname=hostname)
+            container_binary = 'docker'
+            if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+                container_binary = 'podman'
+            docker_exec_cmd = '{container_binary} exec ceph-mds-{hostname}'.format(
+                hostname=hostname, container_binary=container_binary)
         else:
             docker_exec_cmd = ''
 
index a6e62c52b67ffe4e39646a000ef90ec939d193c9..c0eadd991d7857ef7cf6044fd532aa80311327be 100644 (file)
@@ -20,10 +20,14 @@ class TestMGRs(object):
         assert host.service(service_name).is_enabled
 
     def test_mgr_is_up(self, node, host):
-        hostname=node["vars"]["inventory_hostname"]
-        cluster=node["cluster_name"]
+        hostname = node["vars"]["inventory_hostname"]
+        cluster = node["cluster_name"]
         if node['docker']:
-            docker_exec_cmd = 'docker exec ceph-mgr-{hostname}'.format(hostname=hostname)
+            container_binary = 'docker'
+            if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+                container_binary = 'podman'
+            docker_exec_cmd = '{container_binary} exec ceph-mgr-{hostname}'.format(
+                hostname=hostname, container_binary=container_binary)
         else:
             docker_exec_cmd = ''
         cmd = "sudo {docker_exec_cmd} ceph --name mgr.{hostname} --keyring /var/lib/ceph/mgr/{cluster}-{hostname}/keyring --cluster={cluster} --connect-timeout 5 -f json -s".format(
index 8ec9218eacb7bff807bc97e56eedc409cc8e3a91..0a931b4c224ebc614b1ed15ff5b769ac1556479e 100644 (file)
@@ -27,7 +27,11 @@ class TestNFSs(object):
         hostname = node["vars"]["inventory_hostname"]
         cluster = node['cluster_name']
         if node['docker']:
-            docker_exec_cmd = 'docker exec ceph-nfs-{hostname}'.format(hostname=hostname)
+            container_binary = 'docker'
+            if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+                container_binary = 'podman'
+            docker_exec_cmd = '{container_binary} exec ceph-nfs-{hostname}'.format(
+                hostname=hostname, container_binary=container_binary)
         else:
             docker_exec_cmd = ''
         cmd = "sudo {docker_exec_cmd} ceph --name client.rgw.{hostname} --keyring /var/lib/ceph/radosgw/{cluster}-rgw.{hostname}/keyring --cluster={cluster} --connect-timeout 5 -f json -s".format(
index 8bad5c7054f5f12fef44963d88dbfa859d6df941..2182b5d5d031f8e71999994d459a0740347ed97b 100644 (file)
@@ -71,11 +71,15 @@ class TestOSDs(object):
 
     @pytest.mark.docker
     def test_all_docker_osds_are_up_and_in(self, node, host):
-        osd_id = host.check_output(
-            "docker ps -q --filter='name=ceph-osd' | head -1")
-        cmd = "sudo docker exec {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(
+        container_binary = 'docker'
+        if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+            container_binary = 'podman'
+        osd_id = host.check_output(os.path.join(
+            container_binary + " ps -q --filter='name=ceph-osd' | head -1"))
+        cmd = "sudo {container_binary} exec {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"]
+            cluster=node["cluster_name"],
+            container_binary=container_binary
         )
         output = json.loads(host.check_output(cmd))
         assert node["num_osds"] == self._get_nb_up_osds_from_ids(node, output)
index 7d12b268b02ec0ccecdf925be4af6609256951e1..eaa43b810dcd4770682000e12c65744f54fbd6af 100644 (file)
@@ -28,11 +28,15 @@ class TestRbdMirrors(object):
         assert host.service(service_name).is_enabled
 
     def test_rbd_mirror_is_up(self, node, host):
-        hostname=node["vars"]["inventory_hostname"]
-        cluster=node["cluster_name"]
+        hostname = node["vars"]["inventory_hostname"]
+        cluster = node["cluster_name"]
         daemons = []
         if node['docker']:
-            docker_exec_cmd = 'docker exec ceph-rbd-mirror-{hostname}'.format(hostname=hostname)
+            container_binary = 'docker'
+            if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+                container_binary = 'podman'
+            docker_exec_cmd = '{container_binary} exec ceph-rbd-mirror-{hostname}'.format(
+                hostname=hostname, container_binary=container_binary)
         else:
             docker_exec_cmd = ''
         hostname = node["vars"]["inventory_hostname"]
index c940d260b30f6c92373f97ac86b17344acc4f77e..43bbcb274cd082f27279648ec96d8fc962b6caa2 100644 (file)
@@ -23,10 +23,14 @@ class TestRGWs(object):
         assert host.service(service_name).is_enabled
 
     def test_rgw_is_up(self, node, host):
-        hostname=node["vars"]["inventory_hostname"]
-        cluster=node["cluster_name"]
+        hostname = node["vars"]["inventory_hostname"]
+        cluster = node["cluster_name"]
         if node['docker']:
-            docker_exec_cmd = 'docker exec ceph-rgw-{hostname}'.format(hostname=hostname)
+            container_binary = 'docker'
+            if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+                container_binary = 'podman'
+            docker_exec_cmd = '{container_binary} exec ceph-rgw-{hostname}'.format(
+                hostname=hostname, container_binary=container_binary)
         else:
             docker_exec_cmd = ''
         cmd = "sudo {docker_exec_cmd} ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format(
index ff42cf95479c19628f349c42d6d9090f8ea12ef9..69c87a6ad3a487ea80b43bafad919c48d9d59a3e 100644 (file)
@@ -37,9 +37,13 @@ class TestRGWs(object):
     def test_docker_rgw_tuning_pools_are_set(self, node, host):
         hostname = node["vars"]["inventory_hostname"]
         cluster = node['cluster_name']
-        cmd = "sudo docker exec ceph-rgw-{hostname} ceph --cluster={cluster} -n client.rgw.{hostname} --connect-timeout 5 --keyring /var/lib/ceph/radosgw/{cluster}-rgw.{hostname}/keyring  osd dump".format(
+        container_binary = 'docker'
+        if host.exists('podman') and host.ansible("setup")["ansible_facts"]["ansible_distribution"] == 'Fedora':  # noqa E501
+            container_binary = 'podman'
+        cmd = "sudo {container_binary} exec ceph-rgw-{hostname} ceph --cluster={cluster} -n client.rgw.{hostname} --connect-timeout 5 --keyring /var/lib/ceph/radosgw/{cluster}-rgw.{hostname}/keyring  osd dump".format(
             hostname=hostname,
-            cluster=cluster
+            cluster=cluster,
+            container_binary=container_binary
         )
         output = host.check_output(cmd)
         pools = node["vars"].get("rgw_create_pools")