Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 1 | import utils |
| 2 | import json |
Oleksii Zhurba | 100dc38 | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 3 | import pytest |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 4 | |
| 5 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 6 | @pytest.mark.smoke |
Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 7 | def 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 Zhurba | 100dc38 | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 12 | 2. Check that exactly 1 node responds with something. |
Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 13 | """ |
| 14 | groups = utils.calculate_groups() |
Oleksii Zhurba | 100dc38 | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 15 | |
| 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 "" |
Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 20 | no_vip = {} |
| 21 | for group in groups: |
Oleksii Zhurba | ede8b89 | 2019-05-30 09:37:23 -0500 | [diff] [blame^] | 22 | if group in ['cmp', 'cfg', 'kvm', 'cmn', 'osd', 'gtw', 'dns']: |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 23 | continue |
Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 24 | nodes_list = local_salt_client.cmd( |
Oleksii Zhurba | 100dc38 | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 25 | tgt="L@" + ','.join(groups[group]), |
| 26 | fun='cmd.run', |
| 27 | param='ip a | grep /32 ' + exclude_from_grep, |
| 28 | expr_form='compound') |
Oleksii Zhurba | 10b3603 | 2019-04-24 18:16:43 -0500 | [diff] [blame] | 29 | result = [x for x in nodes_list.values() if x] |
| 30 | if len(result) != 1: |
| 31 | if len(result) == 0: |
| 32 | no_vip[group] = 'No vip found' |
| 33 | else: |
| 34 | no_vip[group] = nodes_list |
| 35 | assert len(no_vip) < 1, "Some groups of nodes have problem with vip " \ |
| 36 | "\n{}".format(json.dumps(no_vip, indent=4)) |