[k8s] Add base test for externaldns integration
- Add test for externaldns with coredns backend on basic
deployments.
- Add few core functions as remote executions of kubectl.
User-Story: https://mirantis.jira.com/browse/PROD-12826
Change-Id: I9230ddd75905759eb2d0ba8486ba896d2094cebb
diff --git a/tcp_tests/tests/system/test_k8s_actions.py b/tcp_tests/tests/system/test_k8s_actions.py
new file mode 100644
index 0000000..77ed04a
--- /dev/null
+++ b/tcp_tests/tests/system/test_k8s_actions.py
@@ -0,0 +1,61 @@
+# Copyright 2017 Mirantis, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import pytest
+
+from tcp_tests import logger
+from tcp_tests import settings
+
+LOG = logger.logger
+
+
+class TestMCPK8sActions(object):
+ """Test class for different k8s actions"""
+
+ @pytest.mark.fail_snapshot
+ def test_k8s_externaldns_coredns(self, show_step, config, k8s_deployed):
+ """Test externaldns integration with coredns
+
+ Scenario:
+ 1. Install k8s with externaldns addon enabled(including etcd, coredns)
+ 2. Start simple service
+ 3. Expose deployment
+ 4. Annotate service with domain name
+ 5. Try to get service using nslookup
+ """
+
+ if not (config.k8s_deploy.kubernetes_externaldns_enabled and
+ config.k8s_deploy.kubernetes_coredns_enabled):
+ pytest.skip("Test requires Externaldns and coredns addons enabled")
+
+ show_step(1)
+ k8sclient = k8s_deployed.api
+ assert k8sclient.nodes.list() is not None, "Can not get nodes list"
+
+ show_step(2)
+ name = 'test-nginx'
+ k8s_deployed.kubectl_run(name, 'nginx', '80')
+
+ show_step(3)
+ k8s_deployed.kubectl_expose('deployment', name, '80', 'ClusterIP')
+
+ hostname = "test.{0}.local".format(settings.LAB_CONFIG_NAME)
+ annotation = "\"external-dns.alpha.kubernetes.io/" \
+ "hostname={0}\"".format(hostname)
+ show_step(4)
+ k8s_deployed.kubectl_annotate('service', name, annotation)
+
+ show_step(5)
+ dns_host = k8s_deployed.get_svc_ip('coredns')
+ k8s_deployed.nslookup(hostname, dns_host)