Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame^] | 1 | # Copyright 2017 Mirantis, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | import pytest |
| 15 | import time |
| 16 | |
| 17 | from tcp_tests import logger |
| 18 | |
| 19 | LOG = logger.logger |
| 20 | |
| 21 | |
| 22 | class TestFailoverK8s(object): |
| 23 | |
| 24 | @pytest.mark.grap_versions |
| 25 | @pytest.mark.fail_snapshot |
| 26 | def test_k8s_master_vip_migration(self, show_step, k8s_deployed, underlay, |
| 27 | k8s_actions, common_services_actions, |
| 28 | config, hardware): |
| 29 | """Test restart and shutdown master with VIP |
| 30 | |
| 31 | Scenario: |
| 32 | 1. Deploy mcp with k8s ha |
| 33 | 2. Check keepalived pillar configuration |
| 34 | 3. Find master node with assigned VIP |
| 35 | 4. Reboot server with VIP |
| 36 | 5. Check that VIP was migrated |
| 37 | 6. Check keepalived pillar configuration |
| 38 | 7. Check api server availability |
| 39 | 8. Run conformance on node with VIP |
| 40 | """ |
| 41 | show_step(1) |
| 42 | show_step(2) |
| 43 | common_services_actions.check_keepalived_pillar() |
| 44 | |
| 45 | show_step(3) |
| 46 | vip = k8s_actions.get_keepalived_vip() |
| 47 | LOG.info("VIP ip address: {}".format(vip)) |
| 48 | minion_vip = common_services_actions.get_keepalived_vip_minion_id(vip) |
| 49 | LOG.info("VIP {0} is on {1}".format(vip, minion_vip)) |
| 50 | |
| 51 | show_step(4) |
| 52 | hardware.warm_restart_nodes(underlay, minion_vip) |
| 53 | |
| 54 | show_step(5) |
| 55 | try: |
| 56 | new_minion_vip =\ |
| 57 | common_services_actions.get_keepalived_vip_minion_id(vip) |
| 58 | except Exception: |
| 59 | time.sleep(15) |
| 60 | new_minion_vip = \ |
| 61 | common_services_actions.get_keepalived_vip_minion_id(vip) |
| 62 | LOG.info("VIP {0} migrated to {1}".format(vip, new_minion_vip)) |
| 63 | assert new_minion_vip != minion_vip |
| 64 | |
| 65 | show_step(6) |
| 66 | common_services_actions.check_keepalived_pillar() |
| 67 | |
| 68 | show_step(7) |
| 69 | curl_output = ''.join(underlay.check_call( |
| 70 | cmd="curl -k -s 'https://{}'".format(vip), |
| 71 | host=config.salt.salt_master_host, raise_on_err=False)['stdout']) |
| 72 | assert "apiVersion" in curl_output |
| 73 | |
| 74 | show_step(8) |
| 75 | k8s_actions.run_conformance(node_name=new_minion_vip) |