blob: 284956d9dde24694bf50414b4da318c68eb74724 [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
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -05007def 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 Zhurbaa10927b2017-09-27 22:09:23 +00009
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 Zhurbad0ae87f2018-03-26 13:36:25 -050035 "Several problems found: {1}".format(
36 json.dumps(pkts_data, indent=4))