blob: 3d90218a6c11a16f8ebbaa2b9ae50efc85d1fedc [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import pytest
2import json
3from cvp_checks import utils
4
5
6@pytest.mark.parametrize(
7 "group",
8 utils.get_groups(utils.get_configuration(__file__))
9)
10def test_check_services(local_salt_client, group):
11 config = utils.get_configuration(__file__)
12
13 output = local_salt_client.cmd(group, 'service.get_all', expr_form='pcre')
14
15 if len(output.keys()) < 2:
16 pytest.skip("Nothing to compare - only 1 node")
17
18 nodes = []
19 pkts_data = []
20 my_set = set()
21
22 for node in output:
23 nodes.append(node)
24 my_set.update(output[node])
25
26 for srv in my_set:
27 diff = []
28 row = []
29 for node in nodes:
30 if srv in output[node]:
31 diff.append(srv)
32 row.append("{}: +".format(node))
33 else:
34 row.append("{}: No service".format(node))
35 if diff.count(diff[0]) < len(nodes):
36 row.sort()
37 row.insert(0, srv)
38 pkts_data.append(row)
39 assert len(pkts_data) <= 1, \
40 "Several problems found for {0} group: {1}".format(
41 group, json.dumps(pkts_data, indent=4))