blob: 8cea8809d53d587c69388b15b8b54cc768e4333f [file] [log] [blame]
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03001import json
2
3
4def test_check_default_gateways(local_salt_client, nodes_in_group):
5 netstat_info = local_salt_client.cmd(
6 tgt="L@"+','.join(nodes_in_group),
7 param='ip r | sed -n 1p',
8 expr_form='compound')
9
10 gateways = {}
11
12 for node in netstat_info.keys():
13 gateway = netstat_info[node]
14 if isinstance(gateway, bool):
15 gateway = 'Cannot access node(-s)'
16 if gateway not in gateways:
17 gateways[gateway] = [node]
18 else:
19 gateways[gateway].append(node)
20
21 assert len(gateways.keys()) == 1, \
22 "There were found few gateways: {gw}".format(
23 gw=json.dumps(gateways, indent=4)
24 )