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