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