blob: f64c2560ed3adc8305c2f51851b4e1562adf0181 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import pytest
2import cvp_checks.utils as utils
3
4
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -05005@pytest.fixture(scope='session')
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00006def local_salt_client():
7 return utils.init_salt_client()
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -05008
9nodes = utils.calculate_groups()
10
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050011
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -050012@pytest.fixture(scope='session', params=nodes.values(), ids=nodes.keys())
13def nodes_in_group(request):
14 return request.param
Mikhail Chernike6d470f2018-08-08 18:29:57 +020015
16
Oleksii Zhurba8ce9fcf2018-10-05 18:38:22 +030017@pytest.fixture(scope='session')
18def check_prometheus(local_salt_client):
19 salt_output = local_salt_client.cmd(
20 'prometheus:server',
21 'test.ping',
22 expr_form='pillar')
23 if not salt_output:
24 pytest.skip("Prometheus service or prometheus:server pillar \
25 are not found on this environment.")
26
27
28@pytest.fixture(scope='session')
29def check_kibana(local_salt_client):
30 salt_output = local_salt_client.cmd(
31 'kibana:server',
32 'test.ping',
33 expr_form='pillar')
34 if not salt_output:
35 pytest.skip("Kibana service or kibana:server pillar \
36 are not found on this environment.")
37
38
39@pytest.fixture(scope='session')
40def check_grafana(local_salt_client):
41 salt_output = local_salt_client.cmd(
42 'grafana:client',
43 'test.ping',
44 expr_form='pillar')
45 if not salt_output:
46 pytest.skip("Grafana service or grafana:client pillar \
47 are not found on this environment.")
48
49
Mikhail Chernike6d470f2018-08-08 18:29:57 +020050def pytest_namespace():
51 return {'contrail': None}
52
53
54@pytest.fixture(scope='module')
55def contrail(local_salt_client):
56 probe = local_salt_client.cmd(
57 'opencontrail:control',
58 'pillar.get',
59 'opencontrail:control:version',
60 expr_form='pillar')
61 if not probe:
62 pytest.skip("Contrail is not found on this environment")
63 versions = set(probe.values())
64 if len(versions) != 1:
65 pytest.fail('Contrail versions are not the same: {}'.format(probe))
66 pytest.contrail = str(versions.pop())[:1]