From f4fc3bbfea5cb2400483d3f0532340837c62f7e3 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Sun, 17 Sep 2017 11:16:54 +0200 Subject: [PATCH] ci: add precise tests to valide daemons are up Add daemon health check for rgw, mds, mgr, rbd mirror. Signed-off-by: Guillaume Abrioux Co-Authored-by: Guillaume Abrioux --- tests/conftest.py | 4 ++ tests/functional/tests/mds/__init__.py | 0 tests/functional/tests/mds/test_mds.py | 39 +++++++++++++++ tests/functional/tests/mgr/__init__.py | 0 tests/functional/tests/mgr/test_mgr.py | 44 +++++++++++++++++ tests/functional/tests/rbd-mirror/__init__.py | 0 .../tests/rbd-mirror/test_rbd_mirror.py | 44 +++++++++++++++++ tests/functional/tests/rgw/__init__.py | 0 tests/functional/tests/rgw/test_rgw.py | 47 +++++++++++++++++++ 9 files changed, 178 insertions(+) create mode 100644 tests/functional/tests/mds/__init__.py create mode 100644 tests/functional/tests/mds/test_mds.py create mode 100644 tests/functional/tests/mgr/__init__.py create mode 100644 tests/functional/tests/mgr/test_mgr.py create mode 100644 tests/functional/tests/rbd-mirror/__init__.py create mode 100644 tests/functional/tests/rbd-mirror/test_rbd_mirror.py create mode 100644 tests/functional/tests/rgw/__init__.py create mode 100644 tests/functional/tests/rgw/test_rgw.py diff --git a/tests/conftest.py b/tests/conftest.py index f8b2ec92e..2030b1346 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -101,6 +101,10 @@ def pytest_collection_modifyitems(session, config, items): item.add_marker(pytest.mark.osds) elif "mds" in test_path: item.add_marker(pytest.mark.mdss) + elif "mgr" in test_path: + item.add_marker(pytest.mark.mgrs) + elif "rbd-mirror" in test_path: + item.add_marker(pytest.mark.rbdmirrors) elif "rgw" in test_path: item.add_marker(pytest.mark.rgws) elif "nfs" in test_path: diff --git a/tests/functional/tests/mds/__init__.py b/tests/functional/tests/mds/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/tests/mds/test_mds.py b/tests/functional/tests/mds/test_mds.py new file mode 100644 index 000000000..a8665868c --- /dev/null +++ b/tests/functional/tests/mds/test_mds.py @@ -0,0 +1,39 @@ +import pytest +import json + +class TestMDSs(object): + + @pytest.mark.no_docker + def test_mds_is_installed(self, node, host): + assert host.package("ceph-mds").is_installed + + def test_mds_service_is_running(self, node, host): + service_name = "ceph-mds@{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_running + + def test_mds_service_is_enabled(self, node, host): + service_name = "ceph-mds@{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_enabled + + @pytest.mark.no_docker + def test_mds_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cmd = "sudo ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format(cluster=node['cluster_name']) + output = host.check_output(cmd) + daemons = json.loads(output)["fsmap"]["by_rank"][0]["name"] + assert hostname in daemons + + @pytest.mark.docker + def test_docker_mds_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cmd = "sudo docker exec ceph-mds-{hostname} ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=node["vars"]["inventory_hostname"], + cluster=node["cluster_name"] + ) + output = host.check_output(cmd) + daemons = json.loads(output)["fsmap"]["by_rank"][0]["name"] + assert hostname in daemons diff --git a/tests/functional/tests/mgr/__init__.py b/tests/functional/tests/mgr/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/tests/mgr/test_mgr.py b/tests/functional/tests/mgr/test_mgr.py new file mode 100644 index 000000000..146ac0062 --- /dev/null +++ b/tests/functional/tests/mgr/test_mgr.py @@ -0,0 +1,44 @@ +import pytest +import json + +class TestMGRs(object): + + @pytest.mark.no_docker + def test_mgr_is_installed(self, node, host): + assert host.package("ceph-mgr").is_installed + + def test_mgr_service_is_running(self, node, host): + service_name = "ceph-mgr@{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_running + + def test_mgr_service_is_enabled(self, node, host): + service_name = "ceph-mgr@{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_enabled + + @pytest.mark.no_docker + def test_mgr_is_up(self, node, host): + hostname=node["vars"]["inventory_hostname"] + cluster=node["cluster_name"] + cmd = "sudo ceph --name mgr.{hostname} --keyring /var/lib/ceph/mgr/{cluster}-{hostname}/keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=hostname, + cluster=cluster + ) + output = host.check_output(cmd) + daemons = json.loads(output)["mgrmap"]["active_name"] + assert hostname in daemons + + @pytest.mark.docker + def test_docker_mgr_is_up(self, node, host): + hostname=node["vars"]["inventory_hostname"] + cluster=node["cluster_name"] + cmd = "sudo docker exec ceph-mgr-{hostname} ceph --name mgr.{hostname} --keyring /var/lib/ceph/mgr/{cluster}-{hostname}/keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=node["vars"]["inventory_hostname"], + cluster=node["cluster_name"] + ) + output = host.check_output(cmd) + daemons = json.loads(output)["mgrmap"]["active_name"] + assert hostname in daemons diff --git a/tests/functional/tests/rbd-mirror/__init__.py b/tests/functional/tests/rbd-mirror/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/tests/rbd-mirror/test_rbd_mirror.py b/tests/functional/tests/rbd-mirror/test_rbd_mirror.py new file mode 100644 index 000000000..92b5b8c4d --- /dev/null +++ b/tests/functional/tests/rbd-mirror/test_rbd_mirror.py @@ -0,0 +1,44 @@ +import pytest +import json + +class TestRbdMirrors(object): + + @pytest.mark.no_docker + def test_rbd_mirror_is_installed(self, node, host): + assert host.package("rbd-mirror").is_installed + + def test_rbd_mirror_service_is_running(self, node, host): + service_name = "ceph-rbd-mirror@rbd-mirror.{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_running + + def test_rbd_mirror_service_is_enabled(self, node, host): + service_name = "ceph-rbd-mirror@rbd-mirror.{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_enabled + + @pytest.mark.no_docker + def test_rbd_mirror_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cluster = node['cluster_name'] + cmd = "sudo ceph --name client.bootstrap-rbd --keyring /var/lib/ceph/bootstrap-rbd/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=hostname, + cluster=cluster + ) + output = host.check_output(cmd) + daemons = [i for i in json.loads(output)["servicemap"]["services"]["rbd-mirror"]["daemons"]] + assert hostname in daemons + + @pytest.mark.docker + def test_docker_rbd_mirror_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cluster = node['cluster_name'] + cmd = "sudo docker exec ceph-rbd-mirror-{hostname} ceph --name client.bootstrap-rbd --keyring /var/lib/ceph/bootstrap-rbd/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=hostname, + cluster=cluster + ) + output = host.check_output(cmd) + daemons = [i for i in json.loads(output)["servicemap"]["services"]["rbd-mirror"]["daemons"]] + assert hostname in daemons diff --git a/tests/functional/tests/rgw/__init__.py b/tests/functional/tests/rgw/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/tests/rgw/test_rgw.py b/tests/functional/tests/rgw/test_rgw.py new file mode 100644 index 000000000..653ee9a27 --- /dev/null +++ b/tests/functional/tests/rgw/test_rgw.py @@ -0,0 +1,47 @@ +import pytest +import json + +class TestRGWs(object): + + @pytest.mark.no_docker + def test_rgw_is_installed(self, node, host): + result = host.package("radosgw").is_installed + if not result: + result = host.package("ceph-radosgw").is_installed + assert result + + def test_rgw_service_is_running(self, node, host): + service_name = "ceph-radosgw@rgw.{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_running + + def test_rgw_service_is_enabled(self, node, host): + service_name = "ceph-radosgw@rgw.{hostname}".format( + hostname=node["vars"]["inventory_hostname"] + ) + assert host.service(service_name).is_enabled + + @pytest.mark.no_docker + def test_rgw_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cluster = node['cluster_name'] + cmd = "sudo ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=hostname, + cluster=cluster + ) + output = host.check_output(cmd) + daemons = [i for i in json.loads(output)["servicemap"]["services"]["rgw"]["daemons"]] + assert hostname in daemons + + @pytest.mark.docker + def test_docker_rgw_is_up(self, node, host): + hostname = node["vars"]["inventory_hostname"] + cluster = node['cluster_name'] + cmd = "sudo docker exec ceph-rgw-{hostname} ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/{cluster}.keyring --cluster={cluster} --connect-timeout 5 -f json -s".format( + hostname=hostname, + cluster=cluster + ) + output = host.check_output(cmd) + daemons = [i for i in json.loads(output)["servicemap"]["services"]["rgw"]["daemons"]] + assert hostname in daemons -- 2.39.5