blob: 36ca70e4a3e648456085e66fde734787997da2b6 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import json
2import pytest
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +00003import os
Hanna Arhipova16e93fb2019-01-23 19:03:01 +02004import utils
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00005
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 )