tests: rename CephNode to node and add a bit of documentation

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
pull/1150/head
Andrew Schoen 2016-12-06 09:54:50 -06:00
parent 73705933c9
commit 5f81638b5e
5 changed files with 41 additions and 33 deletions

View 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'):

View 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

View 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"

View 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

View 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)