Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame^] | 1 | import pytest |
| 2 | from cvp_checks import utils |
| 3 | from collections import Counter |
| 4 | |
| 5 | |
| 6 | @pytest.mark.parametrize( |
| 7 | "group", |
| 8 | utils.get_groups(utils.get_configuration(__file__)) |
| 9 | ) |
| 10 | def test_single_vip(local_salt_client, group): |
| 11 | local_salt_client.cmd(group, 'saltutil.sync_all', expr_form='pcre') |
| 12 | nodes_list = local_salt_client.cmd( |
| 13 | group, 'grains.item', ['ipv4'], expr_form='pcre') |
| 14 | |
| 15 | ipv4_list = [] |
| 16 | |
| 17 | for node in nodes_list: |
| 18 | ipv4_list.extend(nodes_list.get(node).get('ipv4')) |
| 19 | |
| 20 | cnt = Counter(ipv4_list) |
| 21 | |
| 22 | for ip in cnt: |
| 23 | if ip == '127.0.0.1': |
| 24 | continue |
| 25 | elif cnt[ip] > 1: |
| 26 | assert "VIP IP duplicate found " \ |
| 27 | "in group {}\n{}".format(group, ipv4_list) |