]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ci: add functionnal tests for iscsi
authorSébastien Han <seb@redhat.com>
Thu, 29 Mar 2018 10:19:29 +0000 (12:19 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 8 Jun 2018 08:21:54 +0000 (10:21 +0200)
We test if:

* packages are installed
* services are runnning
* service units are enabled

Also fix linting issues

Signed-off-by: Sébastien Han <seb@redhat.com>
tests/conftest.py
tests/functional/tests/iscsi/__init__.py [new file with mode: 0644]
tests/functional/tests/iscsi/test_iscsi.py [new file with mode: 0644]

index 6b53c64d8934defbe7e6f45b1b4cbecedd18f650..a4a5660311fb01036be15d9f101f3af5c6d7dc75 100644 (file)
@@ -6,11 +6,12 @@ import os
 def node(host, request):
     """
     This fixture represents a single node in the ceph cluster. Using the
-    host.ansible fixture provided by testinfra it can access all the ansible variables
-    provided to it by the specific test scenario being ran.
+    host.ansible fixture provided by testinfra it can access all the ansible
+    variables provided to it by the specific test scenario being ran.
 
-    You must include this fixture on any tests that operate on specific type of node
-    because it contains the logic to manage which tests a node should run.
+    You must include this fixture on any tests that operate on specific type
+    of node because it contains the logic to manage which tests a node
+    should run.
     """
     ansible_vars = host.ansible.get_variables()
     # tox will pass in this environment variable. we need to do it this way
@@ -22,13 +23,13 @@ def node(host, request):
     osd_auto_discovery = ansible_vars.get("osd_auto_discovery")
     lvm_scenario = ansible_vars.get("osd_scenario") == 'lvm'
     ceph_release_num = {
-      'jewel': 10,
-      'kraken': 11,
-      'luminous': 12,
-      'mimic': 13,
-      'dev': 99
+        'jewel': 10,
+        'kraken': 11,
+        'luminous': 12,
+        'mimic': 13,
+        'dev': 99
     }
-    if not request.node.get_marker(node_type) and not request.node.get_marker('all'):
+    if not request.node.get_marker(node_type) and not request.node.get_marker('all'):  # noqa E501
         pytest.skip("Not a valid test for node type: %s" % node_type)
 
     if request.node.get_marker("no_lvm_scenario") and lvm_scenario:
@@ -38,10 +39,12 @@ def node(host, request):
         pytest.skip("Not a valid test for non-lvm scenarios")
 
     if request.node.get_marker("no_docker") and docker:
-        pytest.skip("Not a valid test for containerized deployments or atomic hosts")
+        pytest.skip(
+            "Not a valid test for containerized deployments or atomic hosts")
 
     if request.node.get_marker("docker") and not docker:
-        pytest.skip("Not a valid test for non-containerized deployments or atomic hosts")
+        pytest.skip(
+            "Not a valid test for non-containerized deployments or atomic hosts")  # noqa E501
 
     if node_type == "mgrs" and ceph_stable_release == "jewel":
         pytest.skip("mgr nodes can not be tested with ceph release jewel")
@@ -49,14 +52,18 @@ def node(host, request):
     if node_type == "nfss" and ceph_stable_release == "jewel":
         pytest.skip("nfs nodes can not be tested with ceph release jewel")
 
-    if request.node.get_marker("from_luminous") and ceph_release_num[ceph_stable_release] < ceph_release_num['luminous']:
-        pytest.skip("This test is only valid for releases starting from Luminous and above")
+    if node_type == "iscsi_gws" and ceph_stable_release == "jewel":
+        pytest.skip("iscsi_gws nodes can not be tested with ceph release jewel")  # noqa E501
 
-    if request.node.get_marker("before_luminous") and ceph_release_num[ceph_stable_release] >= ceph_release_num['luminous']:
+    if request.node.get_marker("from_luminous") and ceph_release_num[ceph_stable_release] < ceph_release_num['luminous']:  # noqa E501
+        pytest.skip(
+            "This test is only valid for releases starting from Luminous and above")  # noqa E501
+
+    if request.node.get_marker("before_luminous") and ceph_release_num[ceph_stable_release] >= ceph_release_num['luminous']:  # noqa E501
         pytest.skip("This test is only valid for release before Luminous")
 
     journal_collocation_test = ansible_vars.get("osd_scenario") == "collocated"
-    if request.node.get_marker("journal_collocation") and not journal_collocation_test:
+    if request.node.get_marker("journal_collocation") and not journal_collocation_test:  # noqa E501
         pytest.skip("Scenario is not using journal collocation")
 
     osd_ids = []
@@ -129,6 +136,8 @@ def pytest_collection_modifyitems(session, config, items):
             item.add_marker(pytest.mark.rgws)
         elif "nfs" in test_path:
             item.add_marker(pytest.mark.nfss)
+        elif "iscsi" in test_path:
+            item.add_marker(pytest.mark.iscsi_gws)
         else:
             item.add_marker(pytest.mark.all)
 
diff --git a/tests/functional/tests/iscsi/__init__.py b/tests/functional/tests/iscsi/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/functional/tests/iscsi/test_iscsi.py b/tests/functional/tests/iscsi/test_iscsi.py
new file mode 100644 (file)
index 0000000..171a8a6
--- /dev/null
@@ -0,0 +1,41 @@
+import pytest
+import json
+
+
+class TestiSCSIs(object):
+
+    @pytest.mark.no_docker
+    def test_tcmu_runner_is_installed(self, node, host):
+        assert host.package("tcmu-runner").is_installed
+
+    @pytest.mark.no_docker
+    def test_rbd_target_api_is_installed(self, node, host):
+        assert host.package("rbd-target-api").is_installed
+
+    @pytest.mark.no_docker
+    def test_rbd_target_gw_is_installed(self, node, host):
+        assert host.package("rbd-target-gw").is_installed
+
+    def test_tcmu_runner_service_is_running(self, node, host):
+        service_name = "tcmu-runner"
+        assert host.service(service_name).is_running
+
+    def test_rbd_target_api_service_is_running(self, node, host):
+        service_name = "rbd-target-api"
+        assert host.service(service_name).is_running
+
+    def test_rbd_target_gw_service_is_running(self, node, host):
+        service_name = "rbd-target-gw"
+        assert host.service(service_name).is_running
+
+    def test_tcmu_runner_service_is_enabled(self, node, host):
+        service_name = "tcmu-runner"
+        assert host.service(service_name).is_enabled
+
+    def test_rbd_target_api_service_is_enabled(self, node, host):
+        service_name = "rbd-target-api"
+        assert host.service(service_name).is_enabled
+
+    def test_rbd_target_gw_service_is_enabled(self, node, host):
+        service_name = "rbd-target-gw"
+        assert host.service(service_name).is_enabled