| Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | import pytest | 
|  | 2 | import cvp_checks.utils as utils | 
|  | 3 |  | 
|  | 4 |  | 
| Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame] | 5 | @pytest.fixture(scope='session') | 
| Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 6 | def local_salt_client(): | 
|  | 7 | return utils.init_salt_client() | 
| Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame] | 8 |  | 
|  | 9 | nodes = utils.calculate_groups() | 
|  | 10 |  | 
| Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 11 |  | 
| Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame] | 12 | @pytest.fixture(scope='session', params=nodes.values(), ids=nodes.keys()) | 
|  | 13 | def nodes_in_group(request): | 
|  | 14 | return request.param | 
| Mikhail Chernik | e6d470f | 2018-08-08 18:29:57 +0200 | [diff] [blame] | 15 |  | 
|  | 16 |  | 
| Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 17 | @pytest.fixture(scope='session') | 
|  | 18 | def 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') | 
|  | 29 | def 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') | 
|  | 40 | def 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 Chernik | e6d470f | 2018-08-08 18:29:57 +0200 | [diff] [blame] | 50 | def pytest_namespace(): | 
|  | 51 | return {'contrail': None} | 
|  | 52 |  | 
|  | 53 |  | 
|  | 54 | @pytest.fixture(scope='module') | 
|  | 55 | def 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] |