]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
tests: rename CephNode to node and add a bit of documentation
authorAndrew Schoen <aschoen@redhat.com>
Tue, 6 Dec 2016 15:54:50 +0000 (09:54 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 6 Dec 2016 20:56:20 +0000 (14:56 -0600)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
tests/conftest.py
tests/functional/tests/mon/test_mons.py
tests/functional/tests/osd/test_journal_collocation.py
tests/functional/tests/osd/test_osds.py
tests/functional/tests/test_install.py

index 6250db6272151121cddbcce1b8a666c957790c31..3053b53269bb58f6b0cff4a3f100e974f8aa993d 100644 (file)
@@ -2,7 +2,15 @@ import pytest
 
 
 @pytest.fixture()
-def CephNode(Ansible, Interface, Command, request):
+def node(Ansible, Interface, Command, request):
+    """
+    This fixture represents a single node in the ceph cluster. Using the
+    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.
+    """
     vars = Ansible.get_variables()
     node_type = vars["group_names"][0]
     if not request.node.get_marker(node_type) and not request.node.get_marker('all'):
index 44e63bdda13bf74149f2f95c80fe3822e2a4db9a..1ba4d1d68f02bdd353219374f98cbd4d1a66d26c 100644 (file)
@@ -1,29 +1,29 @@
 
 class TestMons(object):
 
-    def test_ceph_mon_package_is_installed(self, CephNode, Package):
+    def test_ceph_mon_package_is_installed(self, node, Package):
         assert Package("ceph-mon").is_installed
 
-    def test_mon_listens_on_6789(self, CephNode, Socket):
-        assert Socket("tcp://%s:6789" % CephNode["address"]).is_listening
+    def test_mon_listens_on_6789(self, node, Socket):
+        assert Socket("tcp://%s:6789" % node["address"]).is_listening
 
-    def test_mon_service_is_running(self, CephNode, Service):
-        service_name = "ceph-mon@ceph-%s" % CephNode["vars"]["inventory_hostname"]
+    def test_mon_service_is_running(self, node, Service):
+        service_name = "ceph-mon@ceph-%s" % node["vars"]["inventory_hostname"]
         assert Service(service_name).is_running
 
-    def test_mon_service_is_enabled(self, CephNode, Service):
-        service_name = "ceph-mon@ceph-%s" % CephNode["vars"]["inventory_hostname"]
+    def test_mon_service_is_enabled(self, node, Service):
+        service_name = "ceph-mon@ceph-%s" % node["vars"]["inventory_hostname"]
         assert Service(service_name).is_enabled
 
-    def test_can_get_cluster_health(self, CephNode, Command):
+    def test_can_get_cluster_health(self, node, Command):
         output = Command.check_output("sudo ceph -s")
         assert output.strip().startswith("cluster")
 
 
 class TestOSDs(object):
 
-    def test_all_osds_are_up_and_in(self, CephNode, Command):
+    def test_all_osds_are_up_and_in(self, node, Command):
         output = Command.check_output("sudo ceph -s")
-        num_osds = len(CephNode["vars"]["devices"])
+        num_osds = len(node["vars"]["devices"])
         phrase = "{num_osds} osds: {num_osds} up, {num_osds} in".format(num_osds=num_osds)
         assert phrase in output
index 254e618d50deb5c470f23c315624ea09591ee4f9..9a5b820b2fe5338e6332dcfb2134ad9298d118f4 100644 (file)
@@ -1,7 +1,7 @@
 
 class TestOSD(object):
 
-    def test_osds_are_all_collocated(self, CephNode, Command):
-        # TODO: figure out way to paramaterize CephNode['vars']['devices'] for this test
-        for device in CephNode["vars"]["devices"]:
+    def test_osds_are_all_collocated(self, node, Command):
+        # TODO: figure out way to paramaterize node['vars']['devices'] for this test
+        for device in node["vars"]["devices"]:
             assert Command.check_output("sudo blkid -s PARTLABEL -o value %s2" % device) == "ceph journal"
index 81bf599a49de676c7caeddc346662afc6c35cd9f..e3052e21242e9444dc2cbe679194f5981b1004f4 100644 (file)
@@ -1,23 +1,23 @@
 
 class TestOSDs(object):
 
-    def test_ceph_osd_package_is_installed(self, CephNode, Package):
+    def test_ceph_osd_package_is_installed(self, node, Package):
         assert Package("ceph-osd").is_installed
 
-    def test_osd_listens_on_6800(self, CephNode, Socket):
-        assert Socket("tcp://%s:6800" % CephNode["address"]).is_listening
+    def test_osd_listens_on_6800(self, node, Socket):
+        assert Socket("tcp://%s:6800" % node["address"]).is_listening
 
-    def test_osd_services_are_running(self, CephNode, Service):
-        # TODO: figure out way to paramaterize CephNode['osd_ids'] for this test
-        for osd_id in CephNode["osd_ids"]:
+    def test_osd_services_are_running(self, node, Service):
+        # TODO: figure out way to paramaterize node['osd_ids'] for this test
+        for osd_id in node["osd_ids"]:
             assert Service("ceph-osd@%s" % osd_id).is_running
 
-    def test_osd_services_are_enabled(self, CephNode, Service):
-        # TODO: figure out way to paramaterize CephNode['osd_ids'] for this test
-        for osd_id in CephNode["osd_ids"]:
+    def test_osd_services_are_enabled(self, node, Service):
+        # TODO: figure out way to paramaterize node['osd_ids'] for this test
+        for osd_id in node["osd_ids"]:
             assert Service("ceph-osd@%s" % osd_id).is_enabled
 
-    def test_osd_are_mounted(self, CephNode, MountPoint):
-        # TODO: figure out way to paramaterize CephNode['osd_ids'] for this test
-        for osd_id in CephNode["osd_ids"]:
+    def test_osd_are_mounted(self, node, MountPoint):
+        # TODO: figure out way to paramaterize node['osd_ids'] for this test
+        for osd_id in node["osd_ids"]:
             assert MountPoint("/var/lib/ceph/osd/ceph-%s" % osd_id).exists
index 23f6e362c2fd4d5de2197427f569ebd0ac12a566..d12f6123b238e4c988c8717a24cb43a30d3d279e 100644 (file)
@@ -19,22 +19,22 @@ class TestInstall(object):
 
 class TestCephConf(object):
 
-    def test_ceph_config_has_inital_members_line(self, CephNode, File):
+    def test_ceph_config_has_inital_members_line(self, node, File):
         assert File("/etc/ceph/ceph.conf").contains("^mon initial members = .*$")
 
-    def test_initial_members_line_has_correct_value(self, CephNode, File):
+    def test_initial_members_line_has_correct_value(self, node, File):
         mons = ",".join("ceph-%s" % host
-                        for host in CephNode["vars"]["groups"]["mons"])
+                        for host in node["vars"]["groups"]["mons"])
         line = "mon initial members = {}".format(mons)
         assert File("/etc/ceph/ceph.conf").contains(line)
 
-    def test_ceph_config_has_mon_host_line(self, CephNode, File):
+    def test_ceph_config_has_mon_host_line(self, node, File):
         assert File("/etc/ceph/ceph.conf").contains("^mon host = .*$")
 
-    def test_mon_host_line_has_correct_value(self, CephNode, File):
-        num_mons = len(CephNode["vars"]["groups"]["mons"])
+    def test_mon_host_line_has_correct_value(self, node, File):
+        num_mons = len(node["vars"]["groups"]["mons"])
         mon_ips = []
         for x in range(0, num_mons):
-            mon_ips.append("{}.1{}".format(CephNode["subnet"], x))
+            mon_ips.append("{}.1{}".format(node["subnet"], x))
         line = "mon host = {}".format(",".join(mon_ips))
         assert File("/etc/ceph/ceph.conf").contains(line)