blob: 92a6a5e90088c0e2447e8b7a8f1730e4c3cb58eb [file] [log] [blame]
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03001import utils
2import json
Oleksii Zhurbabb630be2019-05-09 14:18:17 -05003import pytest
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03004
5
Oleksii Zhurba23c18332019-05-09 18:53:40 -05006@pytest.mark.smoke
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03007def test_single_vip_exists(local_salt_client):
8 """Test checks that there is only one VIP address
9 within one group of nodes (where applicable).
10 Steps:
11 1. Get IP addresses for nodes via salt cmd.run 'ip a | grep /32'
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050012 2. Check that exactly 1 node responds with something.
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030013 """
14 groups = utils.calculate_groups()
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050015
16 keywords_to_exclude_interfaces = ["flannel.1"]
17 exclude_from_grep = " | grep -v {}".format('\|'.join(keywords_to_exclude_interfaces)) \
18 if len(keywords_to_exclude_interfaces) > 0 \
19 else ""
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030020 no_vip = {}
21 for group in groups:
Sergey Galkin2aeb62d2019-12-02 16:03:43 +040022 if group in ['cmp', 'cfg', 'kvm', 'cmn', 'osd', 'gtw', 'dns', 'apt']:
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030023 continue
24 nodes_list = local_salt_client.cmd(
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050025 tgt="L@" + ','.join(groups[group]),
26 fun='cmd.run',
27 param='ip a | grep /32 ' + exclude_from_grep,
28 expr_form='compound')
Ekaterina Chernovac73bc4e2019-11-12 14:56:03 +030029 result = [x for x in list(nodes_list.values()) if x]
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030030 if len(result) != 1:
31 if len(result) == 0:
32 no_vip[group] = 'No vip found'
33 else:
34 no_vip[group] = nodes_list
Dmitriy Kruglovbc0a88b2019-08-20 11:45:35 +020035 assert len(no_vip) < 1, (
36 "The following group(s) of nodes have problem with vip:\n{}".format(
37 json.dumps(no_vip, indent=4))
38 )