blob: b872c363861f7502e2fe237ed22fdbfc04780800 [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
26 def test_k8s_master_vip_migration(self, show_step, k8s_deployed, underlay,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030027 k8s_actions, core_actions,
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040028 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)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030043 core_actions.check_keepalived_pillar()
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040044
45 show_step(3)
46 vip = k8s_actions.get_keepalived_vip()
47 LOG.info("VIP ip address: {}".format(vip))
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030048 minion_vip = core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040049 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 =\
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030057 core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040058 except Exception:
59 time.sleep(15)
60 new_minion_vip = \
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030061 core_actions.get_keepalived_vip_minion_id(vip)
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040062 LOG.info("VIP {0} migrated to {1}".format(vip, new_minion_vip))
63 assert new_minion_vip != minion_vip
64
65 show_step(6)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030066 core_actions.check_keepalived_pillar()
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040067
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)