blob: 69fd116ee83c3454ecd11a616a19ebb30e377149 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import json
2import pytest
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_default_gateways(local_salt_client, nodes_in_group):
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00008 netstat_info = local_salt_client.cmd(
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -05009 "L@"+','.join(nodes_in_group), 'cmd.run', ['ip r | sed -n 1p'], expr_form='compound')
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000010
11 gateways = {}
12 nodes = netstat_info.keys()
13
14 for node in nodes:
15 if netstat_info[node] not in gateways:
16 gateways[netstat_info[node]] = [node]
17 else:
18 gateways[netstat_info[node]].append(node)
19
20 assert len(gateways.keys()) == 1, \
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -050021 "There were found few gateways: {gw}".format(
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000022 gw=json.dumps(gateways, indent=4)
23 )