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 | |
| 17 | def pytest_namespace(): |
| 18 | return {'contrail': None} |
| 19 | |
| 20 | |
| 21 | @pytest.fixture(scope='module') |
| 22 | def contrail(local_salt_client): |
| 23 | probe = local_salt_client.cmd( |
| 24 | 'opencontrail:control', |
| 25 | 'pillar.get', |
| 26 | 'opencontrail:control:version', |
| 27 | expr_form='pillar') |
| 28 | if not probe: |
| 29 | pytest.skip("Contrail is not found on this environment") |
| 30 | versions = set(probe.values()) |
| 31 | if len(versions) != 1: |
| 32 | pytest.fail('Contrail versions are not the same: {}'.format(probe)) |
| 33 | pytest.contrail = str(versions.pop())[:1] |