Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 1 | import utils |
| 2 | import json |
Oleksii Zhurba | bb630be | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 3 | import pytest |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 4 | |
| 5 | |
Oleksii Zhurba | 23c1833 | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 6 | @pytest.mark.smoke |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [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 | bb630be | 2019-05-09 14:18:17 -0500 | [diff] [blame] | 12 | 2. Check that exactly 1 node responds with something. |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 13 | """ |
| 14 | groups = utils.calculate_groups() |
Oleksii Zhurba | bb630be | 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 "" |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 20 | no_vip = {} |
| 21 | for group in groups: |
Sergey Galkin | 2aeb62d | 2019-12-02 16:03:43 +0400 | [diff] [blame] | 22 | if group in ['cmp', 'cfg', 'kvm', 'cmn', 'osd', 'gtw', 'dns', 'apt']: |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 23 | continue |
| 24 | nodes_list = local_salt_client.cmd( |
Oleksii Zhurba | bb630be | 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') |
Ekaterina Chernova | c73bc4e | 2019-11-12 14:56:03 +0300 | [diff] [blame^] | 29 | result = [x for x in list(nodes_list.values()) if x] |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 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 |
Dmitriy Kruglov | bc0a88b | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 35 | 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 | ) |