Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | import pytest |
| 2 | import json |
Oleksii Zhurba | e0668ae | 2017-10-27 23:58:18 +0000 | [diff] [blame] | 3 | import os |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 4 | from cvp_checks import utils |
| 5 | |
| 6 | |
| 7 | @pytest.mark.parametrize( |
| 8 | "group", |
Oleksii Zhurba | e0dedb5 | 2018-01-16 00:55:25 +0000 | [diff] [blame^] | 9 | utils.node_groups.keys() |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 10 | ) |
| 11 | def test_check_services(local_salt_client, group): |
Oleksii Zhurba | e0dedb5 | 2018-01-16 00:55:25 +0000 | [diff] [blame^] | 12 | output = local_salt_client.cmd("L@"+','.join(utils.node_groups[group]), 'service.get_all', expr_form='compound') |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 13 | |
| 14 | if len(output.keys()) < 2: |
| 15 | pytest.skip("Nothing to compare - only 1 node") |
| 16 | |
| 17 | nodes = [] |
| 18 | pkts_data = [] |
| 19 | my_set = set() |
| 20 | |
| 21 | for node in output: |
| 22 | nodes.append(node) |
| 23 | my_set.update(output[node]) |
| 24 | |
| 25 | for srv in my_set: |
| 26 | diff = [] |
| 27 | row = [] |
| 28 | for node in nodes: |
| 29 | if srv in output[node]: |
| 30 | diff.append(srv) |
| 31 | row.append("{}: +".format(node)) |
| 32 | else: |
| 33 | row.append("{}: No service".format(node)) |
| 34 | if diff.count(diff[0]) < len(nodes): |
| 35 | row.sort() |
| 36 | row.insert(0, srv) |
| 37 | pkts_data.append(row) |
| 38 | assert len(pkts_data) <= 1, \ |
| 39 | "Several problems found for {0} group: {1}".format( |
| 40 | group, json.dumps(pkts_data, indent=4)) |