Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 1 | import json |
Oleksii Zhurba | 23c1833 | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 2 | import pytest |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 3 | |
| 4 | |
Oleksii Zhurba | 23c1833 | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 5 | @pytest.mark.full |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 6 | def 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 | ) |