blob: 60d1894b54f9bba2e4b943feb13bd194ae0da665 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import pytest
2from cvp_checks import utils
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +00003import os
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00004from collections import Counter
5
6
7@pytest.mark.parametrize(
8 "group",
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +00009 utils.get_groups(os.path.basename(__file__))
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000010)
11def test_single_vip(local_salt_client, group):
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +000012 if "skipped" in group:
13 pytest.skip("skipped in config")
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000014 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)