blob: c18c6609d98715cbb7ed76123363b8d7a7a5a154 [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
6def test_single_vip_exists(local_salt_client):
7 """Test checks that there is only one VIP address
8 within one group of nodes (where applicable).
9 Steps:
10 1. Get IP addresses for nodes via salt cmd.run 'ip a | grep /32'
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050011 2. Check that exactly 1 node responds with something.
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030012 """
13 groups = utils.calculate_groups()
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050014
15 keywords_to_exclude_interfaces = ["flannel.1"]
16 exclude_from_grep = " | grep -v {}".format('\|'.join(keywords_to_exclude_interfaces)) \
17 if len(keywords_to_exclude_interfaces) > 0 \
18 else ""
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030019 no_vip = {}
20 for group in groups:
21 if group in ['cmp', 'cfg', 'kvm', 'cmn', 'osd', 'gtw']:
22 continue
23 nodes_list = local_salt_client.cmd(
Oleksii Zhurbabb630be2019-05-09 14:18:17 -050024 tgt="L@" + ','.join(groups[group]),
25 fun='cmd.run',
26 param='ip a | grep /32 ' + exclude_from_grep,
27 expr_form='compound')
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030028 result = [x for x in nodes_list.values() if x]
29 if len(result) != 1:
30 if len(result) == 0:
31 no_vip[group] = 'No vip found'
32 else:
33 no_vip[group] = nodes_list
34 assert len(no_vip) < 1, "Some groups of nodes have problem with vip " \
35 "\n{}".format(json.dumps(no_vip, indent=4))