blob: be0bc16f3743c8817c4601a5f0b63b946cb3d3e1 [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 Zhurbae0dedb52018-01-16 00:55:25 +00009 utils.node_groups.keys()
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000010)
11def test_check_services(local_salt_client, group):
Oleksii Zhurbae0dedb52018-01-16 00:55:25 +000012 output = local_salt_client.cmd("L@"+','.join(utils.node_groups[group]), 'service.get_all', expr_form='compound')
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000013
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))