2016-10-28 03:39:12 +08:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2016-12-03 22:07:09 +08:00
|
|
|
@pytest.fixture()
|
2016-12-06 23:54:50 +08:00
|
|
|
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.
|
|
|
|
"""
|
2016-12-03 22:07:09 +08:00
|
|
|
vars = Ansible.get_variables()
|
|
|
|
node_type = vars["group_names"][0]
|
2016-12-06 00:07:04 +08:00
|
|
|
if not request.node.get_marker(node_type) and not request.node.get_marker('all'):
|
2016-12-03 22:07:09 +08:00
|
|
|
pytest.skip("Not a valid test for node type")
|
|
|
|
|
2016-12-06 06:21:52 +08:00
|
|
|
if request.node.get_marker("journal_collocation") and not vars.get("journal_collocation"):
|
|
|
|
pytest.skip("Skipping because scenario is not using journal collocation")
|
|
|
|
|
2016-12-06 05:03:44 +08:00
|
|
|
osd_ids = []
|
|
|
|
if node_type == "osds":
|
|
|
|
result = Command.check_output('sudo ls /var/lib/ceph/osd/ | grep -oP "\d+$"')
|
|
|
|
osd_ids = result.split("\n")
|
|
|
|
|
2016-12-04 10:01:30 +08:00
|
|
|
# I can assume eth1 because I know all the vagrant
|
|
|
|
# boxes we test with use that interface
|
|
|
|
address = Interface("eth1").addresses[0]
|
2016-12-05 23:47:33 +08:00
|
|
|
subnet = ".".join(vars["public_network"].split(".")[0:-1])
|
2016-12-04 10:01:30 +08:00
|
|
|
data = dict(
|
|
|
|
address=address,
|
2016-12-05 23:47:33 +08:00
|
|
|
subnet=subnet,
|
2016-12-04 10:01:30 +08:00
|
|
|
vars=vars,
|
2016-12-06 05:03:44 +08:00
|
|
|
osd_ids=osd_ids,
|
2016-12-04 10:01:30 +08:00
|
|
|
)
|
|
|
|
return data
|
|
|
|
|
2016-12-03 22:07:09 +08:00
|
|
|
|
|
|
|
def pytest_collection_modifyitems(session, config, items):
|
|
|
|
for item in items:
|
|
|
|
test_path = item.location[0]
|
|
|
|
if "mon" in test_path:
|
|
|
|
item.add_marker(pytest.mark.mons)
|
|
|
|
elif "osd" in test_path:
|
|
|
|
item.add_marker(pytest.mark.osds)
|
|
|
|
elif "mds" in test_path:
|
|
|
|
item.add_marker(pytest.mark.mdss)
|
|
|
|
elif "rgw" in test_path:
|
|
|
|
item.add_marker(pytest.mark.rgws)
|
|
|
|
else:
|
|
|
|
item.add_marker(pytest.mark.all)
|
2016-12-06 06:21:52 +08:00
|
|
|
|
|
|
|
if "journal_collocation" in test_path:
|
|
|
|
item.add_marker(pytest.mark.journal_collocation)
|