Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | import json |
| 2 | import pytest |
| 3 | |
| 4 | from cvp_checks import utils |
| 5 | |
| 6 | |
| 7 | @pytest.mark.parametrize( |
| 8 | "group", |
| 9 | utils.get_groups(utils.get_configuration(__file__)) |
| 10 | ) |
| 11 | def test_check_default_gateways(local_salt_client, group): |
| 12 | config = utils.get_configuration(__file__) |
| 13 | netstat_info = local_salt_client.cmd( |
| 14 | group, 'cmd.run', ['ip r | sed -n 1p'], expr_form='pcre') |
| 15 | |
| 16 | gateways = {} |
| 17 | nodes = netstat_info.keys() |
| 18 | |
| 19 | for node in nodes: |
| 20 | if netstat_info[node] not in gateways: |
| 21 | gateways[netstat_info[node]] = [node] |
| 22 | else: |
| 23 | gateways[netstat_info[node]].append(node) |
| 24 | |
| 25 | assert len(gateways.keys()) == 1, \ |
| 26 | "There were found few gateways within group {group}: {gw}".format( |
| 27 | group=group, |
| 28 | gw=json.dumps(gateways, indent=4) |
| 29 | ) |