blob: 57a6d7b647527755c23940f78662874b6d6a931f [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import json
2import pytest
3
4from cvp_checks import utils
5
6
7@pytest.mark.parametrize(
8 "group",
9 utils.get_groups(utils.get_configuration(__file__))
10)
11def test_check_default_gateways(local_salt_client, group):
12 config = utils.get_configuration(__file__)
13 netstat_info = local_salt_client.cmd(
14 group, 'cmd.run', ['ip r | sed -n 1p'], expr_form='pcre')
15
16 gateways = {}
17 nodes = netstat_info.keys()
18
19 for node in nodes:
20 if netstat_info[node] not in gateways:
21 gateways[netstat_info[node]] = [node]
22 else:
23 gateways[netstat_info[node]].append(node)
24
25 assert len(gateways.keys()) == 1, \
26 "There were found few gateways within group {group}: {gw}".format(
27 group=group,
28 gw=json.dumps(gateways, indent=4)
29 )