blob: d7ee5a1333b7bcca1c4c7ec4e56c7aa0b6edc286 [file] [log] [blame]
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +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.
14
15import pytest
16
17from tcp_tests import logger
18from tcp_tests import settings
19
20LOG = logger.logger
21
22
23class TestMCPK8sActions(object):
24 """Test class for different k8s actions"""
25
Tatyana Leontovichc411ec32017-10-09 14:48:00 +030026 @pytest.mark.grab_versions
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +040027 @pytest.mark.fail_snapshot
28 def test_k8s_externaldns_coredns(self, show_step, config, k8s_deployed):
29 """Test externaldns integration with coredns
30
31 Scenario:
32 1. Install k8s with externaldns addon enabled(including etcd, coredns)
33 2. Start simple service
34 3. Expose deployment
35 4. Annotate service with domain name
36 5. Try to get service using nslookup
37 """
38
39 if not (config.k8s_deploy.kubernetes_externaldns_enabled and
40 config.k8s_deploy.kubernetes_coredns_enabled):
41 pytest.skip("Test requires Externaldns and coredns addons enabled")
42
43 show_step(1)
44 k8sclient = k8s_deployed.api
45 assert k8sclient.nodes.list() is not None, "Can not get nodes list"
46
47 show_step(2)
48 name = 'test-nginx'
49 k8s_deployed.kubectl_run(name, 'nginx', '80')
50
51 show_step(3)
52 k8s_deployed.kubectl_expose('deployment', name, '80', 'ClusterIP')
53
Victor Ryzhenkin66d39372017-09-28 19:25:48 +040054 hostname = "test.{0}.local.".format(settings.LAB_CONFIG_NAME)
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +040055 annotation = "\"external-dns.alpha.kubernetes.io/" \
56 "hostname={0}\"".format(hostname)
57 show_step(4)
58 k8s_deployed.kubectl_annotate('service', name, annotation)
59
60 show_step(5)
61 dns_host = k8s_deployed.get_svc_ip('coredns')
62 k8s_deployed.nslookup(hostname, dns_host)