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