Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame^] | 1 | import json |
| 2 | |
| 3 | |
| 4 | def 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 | ) |