FROM opnfv/functest-core
+ARG BRANCH=master
ARG K8S_TAG=v1.7.3
RUN apk --no-cache add --update make bash go \
(cd /src/k8s.io/kubernetes && \
make kubectl ginkgo && \
make WHAT=test/e2e/e2e.test) && \
- rm -rf /src/k8s.io/kubernetes/.git
+ git clone https://gerrit.opnfv.org/gerrit/functest-kubernetes /src/functest-kubernetes && \
+ (cd /src/functest-kubernetes && git fetch origin $BRANCH && git checkout FETCH_HEAD) && \
+ pip install /src/functest-kubernetes && \
+ rm -rf /src/k8s.io/kubernetes/.git /src/functest-kubernetes
+COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml
+CMD ["run_tests", "-t", "all"]
--- /dev/null
+---
+tiers:
+ -
+ name: k8s_e2e
+ order: 1
+ ci_loop: '(daily)|(weekly)'
+ description: >-
+ A set of e2e tests integrated from kubernetes project.
+ testcases:
+ -
+ case_name: k8s_smoke
+ project_name: functest
+ criteria: 100
+ blocking: false
+ description: >-
+ Smoke Tests a running Kubernetes cluster, which
+ validates the deployed cluster is accessible, and
+ at least satisfies minimal functional requirements.
+ dependencies:
+ installer: '(compass)|(joid)'
+ scenario: 'k8-*'
+ run:
+ module: 'functest_kubernetes.k8stest'
+ class: 'K8sSmokeTest'
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+"""
+Define the parent for Kubernetes testing.
+"""
+
+from __future__ import division
+
+import logging
+import os
+import subprocess
+import time
+
+from functest.core import testcase
+
+
+LOGGER = logging.getLogger(__name__)
+
+
+class K8sTesting(testcase.TestCase):
+ """Kubernetes test runner"""
+
+ def __init__(self, **kwargs):
+ super(K8sTesting, self).__init__(**kwargs)
+ self.cmd = []
+ self.result = 0
+ self.start_time = 0
+ self.stop_time = 0
+
+ def run_kubetest(self):
+ """Run the test suites"""
+ cmd_line = self.cmd
+ LOGGER.info("Starting k8s test: '%s'.", cmd_line)
+
+ process = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ remark = []
+ lines = process.stdout.readlines()
+ for i in range(len(lines) - 1, -1, -1):
+ new_line = str(lines[i])
+
+ if 'SUCCESS!' in new_line or 'FAIL!' in new_line:
+ remark = new_line.replace('--', '|').split('|')
+ break
+
+ if remark and 'SUCCESS!' in remark[0]:
+ self.result = 100
+
+ def run(self):
+
+ if not os.path.isfile(os.getenv('KUBECONFIG')):
+ LOGGER.error("Cannot run k8s testcases. Config file not found ")
+ return self.EX_RUN_ERROR
+
+ self.start_time = time.time()
+ try:
+ self.run_kubetest()
+ res = self.EX_OK
+ except Exception as ex: # pylint: disable=broad-except
+ LOGGER.error("Error with running %s", str(ex))
+ res = self.EX_RUN_ERROR
+
+ self.stop_time = time.time()
+ return res
+
+ def check_envs(self): # pylint: disable=no-self-use
+ """Check if required environment variables are set"""
+ try:
+ assert 'DEPLOY_SCENARIO' in os.environ
+ assert 'KUBECONFIG' in os.environ
+ assert 'KUBE_MASTER' in os.environ
+ assert 'KUBE_MASTER_IP' in os.environ
+ assert 'KUBERNETES_PROVIDER' in os.environ
+ assert 'KUBE_MASTER_URL' in os.environ
+ except Exception as ex:
+ raise Exception("Cannot run k8s testcases. "
+ "Please check env var: %s" % str(ex))
+
+
+class K8sSmokeTest(K8sTesting):
+ """Kubernetes smoke test suite"""
+ def __init__(self, **kwargs):
+ if "case_name" not in kwargs:
+ kwargs.get("case_name", 'k8s_smoke')
+ super(K8sSmokeTest, self).__init__(**kwargs)
+ self.check_envs()
+ self.cmd = ['/src/k8s.io/kubernetes/cluster/test-smoke.sh', '--host',
+ os.getenv('KUBE_MASTER_URL')]
--- /dev/null
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
+pbr!=2.1.0,>=2.0.0 # Apache-2.0
+functest
--- /dev/null
+[metadata]
+name = functest.kubernetes
+version = 6
+home-page = https://wiki.opnfv.org/display/functest
+
+[files]
+packages = functest_kubernetes
--- /dev/null
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+#
+# 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.
+
+# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
+import setuptools
+
+# In python < 2.7.4, a lazy loading of package `pbr` will break
+# setuptools if some other modules registered functions in `atexit`.
+# solution from: http://bugs.python.org/issue15881#msg170215
+try:
+ import multiprocessing # noqa
+except ImportError:
+ pass
+
+setuptools.setup(
+ setup_requires=['pbr>=2.0.0'],
+ pbr=True)
--- /dev/null
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
+git+https://gerrit.opnfv.org/gerrit/functest#egg=functest
+coverage!=4.4,>=4.0 # Apache-2.0
+mock>=2.0 # BSD
+nose # LGPL
+flake8<2.6.0,>=2.5.4 # MIT
+pylint==1.4.5 # GPLv2
+yamllint
--- /dev/null
+[tox]
+envlist = pep8,pylint,yamllint,py27,py35
+
+[testenv]
+usedevelop = True
+deps =
+ -r{toxinidir}/test-requirements.txt
+install_command = pip install {opts} {packages}
+
+[testenv:pep8]
+basepython = python2.7
+commands = flake8
+
+[testenv:pylint]
+basepython = python2.7
+whitelist_externals = bash
+modules =
+ functest_kubernetes
+commands =
+ pylint --disable=locally-disabled --reports=n {[testenv:pylint]modules}
+
+[testenv:yamllint]
+basepython = python2.7
+files =
+ docker
+commands =
+ yamllint {[testenv:yamllint]files}