blob: 60ac4a7c9747ea2c4f5196d4e1a34002c68147b5 [file] [log] [blame]
Vladimir Jigulinee1faa52018-06-25 13:00:51 +04001# 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.
14import pytest
15import time
16
17from tcp_tests import logger
18
19LOG = logger.logger
20
21
22class TestFailoverK8s(object):
23
Vladimir Jigulin2154e4b2018-11-14 12:14:05 +040024 @pytest.mark.grab_versions
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040025 @pytest.mark.fail_snapshot
Vladimir Jigulineb8b8132019-03-19 15:34:02 +040026 @pytest.mark.k8s_system
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040027 def test_k8s_master_vip_migration(self, show_step, k8s_deployed, underlay,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030028 k8s_actions, core_actions,
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040029 config, hardware):
30 """Test restart and shutdown master with VIP
31
32 Scenario:
33 1. Deploy mcp with k8s ha
34 2. Check keepalived pillar configuration
35 3. Find master node with assigned VIP
36 4. Reboot server with VIP
37 5. Check that VIP was migrated
38 6. Check keepalived pillar configuration
39 7. Check api server availability
40 8. Run conformance on node with VIP
41 """
42 show_step(1)
43 show_step(2)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030044 core_actions.check_keepalived_pillar()
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040045
46 show_step(3)
47 vip = k8s_actions.get_keepalived_vip()
48 LOG.info("VIP ip address: {}".format(vip))
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030049 minion_vip = core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040050 LOG.info("VIP {0} is on {1}".format(vip, minion_vip))
51
52 show_step(4)
53 hardware.warm_restart_nodes(underlay, minion_vip)
54
55 show_step(5)
56 try:
57 new_minion_vip =\
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030058 core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040059 except Exception:
60 time.sleep(15)
61 new_minion_vip = \
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030062 core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040063 LOG.info("VIP {0} migrated to {1}".format(vip, new_minion_vip))
64 assert new_minion_vip != minion_vip
65
66 show_step(6)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030067 core_actions.check_keepalived_pillar()
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040068
69 show_step(7)
70 curl_output = ''.join(underlay.check_call(
71 cmd="curl -k -s 'https://{}'".format(vip),
72 host=config.salt.salt_master_host, raise_on_err=False)['stdout'])
73 assert "apiVersion" in curl_output
74
Vladimir Jigulin174aab12019-01-28 22:17:46 +040075 k8s_actions.renew_controller(controller_node_name=new_minion_vip)
76
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040077 show_step(8)
Vladimir Jigulin174aab12019-01-28 22:17:46 +040078 k8s_actions.start_conformance_inside_pod()