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 | |
Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame^] | 7 | def test_check_services(local_salt_client, nodes_in_group): |
| 8 | output = local_salt_client.cmd("L@"+','.join(nodes_in_group), 'service.get_all', expr_form='compound') |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 9 | |
| 10 | if len(output.keys()) < 2: |
| 11 | pytest.skip("Nothing to compare - only 1 node") |
| 12 | |
| 13 | nodes = [] |
| 14 | pkts_data = [] |
| 15 | my_set = set() |
| 16 | |
| 17 | for node in output: |
| 18 | nodes.append(node) |
| 19 | my_set.update(output[node]) |
| 20 | |
| 21 | for srv in my_set: |
| 22 | diff = [] |
| 23 | row = [] |
| 24 | for node in nodes: |
| 25 | if srv in output[node]: |
| 26 | diff.append(srv) |
| 27 | row.append("{}: +".format(node)) |
| 28 | else: |
| 29 | row.append("{}: No service".format(node)) |
| 30 | if diff.count(diff[0]) < len(nodes): |
| 31 | row.sort() |
| 32 | row.insert(0, srv) |
| 33 | pkts_data.append(row) |
| 34 | assert len(pkts_data) <= 1, \ |
Oleksii Zhurba | d0ae87f | 2018-03-26 13:36:25 -0500 | [diff] [blame^] | 35 | "Several problems found: {1}".format( |
| 36 | json.dumps(pkts_data, indent=4)) |