From: Sébastien Han Date: Mon, 19 Nov 2018 10:03:45 +0000 (+0100) Subject: testinfra: add support for podman X-Git-Tag: v4.0.0beta1~182 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcc765d7c72c3b3cefe35a198081d5bebbad813f;p=ceph-ansible.git testinfra: add support for podman 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 --- diff --git a/tests/functional/tests/mds/test_mds.py b/tests/functional/tests/mds/test_mds.py index 716e4884b..f0c3f32cc 100644 --- a/tests/functional/tests/mds/test_mds.py +++ b/tests/functional/tests/mds/test_mds.py @@ -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 = '' diff --git a/tests/functional/tests/mgr/test_mgr.py b/tests/functional/tests/mgr/test_mgr.py index a6e62c52b..c0eadd991 100644 --- a/tests/functional/tests/mgr/test_mgr.py +++ b/tests/functional/tests/mgr/test_mgr.py @@ -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( diff --git a/tests/functional/tests/nfs/test_nfs_ganesha.py b/tests/functional/tests/nfs/test_nfs_ganesha.py index 8ec9218ea..0a931b4c2 100644 --- a/tests/functional/tests/nfs/test_nfs_ganesha.py +++ b/tests/functional/tests/nfs/test_nfs_ganesha.py @@ -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( diff --git a/tests/functional/tests/osd/test_osds.py b/tests/functional/tests/osd/test_osds.py index 8bad5c705..2182b5d5d 100644 --- a/tests/functional/tests/osd/test_osds.py +++ b/tests/functional/tests/osd/test_osds.py @@ -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) diff --git a/tests/functional/tests/rbd-mirror/test_rbd_mirror.py b/tests/functional/tests/rbd-mirror/test_rbd_mirror.py index 7d12b268b..eaa43b810 100644 --- a/tests/functional/tests/rbd-mirror/test_rbd_mirror.py +++ b/tests/functional/tests/rbd-mirror/test_rbd_mirror.py @@ -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"] diff --git a/tests/functional/tests/rgw/test_rgw.py b/tests/functional/tests/rgw/test_rgw.py index c940d260b..43bbcb274 100644 --- a/tests/functional/tests/rgw/test_rgw.py +++ b/tests/functional/tests/rgw/test_rgw.py @@ -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( diff --git a/tests/functional/tests/rgw/test_rgw_tuning.py b/tests/functional/tests/rgw/test_rgw_tuning.py index ff42cf954..69c87a6ad 100644 --- a/tests/functional/tests/rgw/test_rgw_tuning.py +++ b/tests/functional/tests/rgw/test_rgw_tuning.py @@ -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")