1 ### Functional testing for OPNFV Kubernetes (K8s) deployments with Functest
3 By: [Konrad Djimeli](mailto:konraddjimeli@gmail.com) (OPNFV Functest Intern)
5 Mentor: [Linda Wang](mailto:wangwulin@huawei.com)
11 Development or integration of tests which can be used to test the functionalities of a Kubernetes deployment, in OPNFV Functest
17 **Kubernetes (K8s)** is an open source container manager and orchestrator, and can be used as a VIM to orchestrate containerized VNFs.
21 ### K8s provides an End-to-End(e2e) testing framework.
23 * Build/deploy/test kubernetes clusters on various providers.
24 * This tests provide a mechanism to test end-to-end behavior of the system.
28 ### K8s End-to-End (e2e)testing
30 * The Kubernetes e2e tests are a combination of tests which fall under various categories such as [slow] (more than five minutes), [Serial] (can not run in parallel), etc
33 ### The k8s e2e tests includes smoke and conformance tests
36 **Smoke test:** Tests a running Kubernetes cluster. Validates that the cluster was deployed, is accessible, and at least satisfies minimal functional requirements. Emphasis on speed and being non-destructive over thoroughness.
39 **Conformance tests** : Test expected to pass on any Kubernetes cluster. It is a subset of tests necessary to demonstrate conformance grows with each release. Conformance is thus considered versioned, with backwards compatibility guarantees and are designed to be run with no cloud provider configured.
42 **The k8s e2e test can be accessed by running the example commands below, within the K8s source code root directory**
46 make WHAT=test/e2e/e2e.test
51 _output/bin/e2e.test --ginkgo.skip="\[Slow\]" --ginkgo.focus=\[Conformance\]"
56 ### Integration of the k8s e2e testing framework with OPNFV Functest
58 In order to integrate k8s e2e tests into functest, various options were considered such as:
62 * Creating a docker image with opnfv/functest-core as base image and making use the Functest’s BashFeature class functionality to run the command for the test.
69 * Creating a docker image with opnfv/functest-core as base image and creating a new class which inherits from the functest.core.testcase.TestCase class, which would contain subclasses for various testcases to be run, which are declared in a testcases.yaml file.
72 **Steps taken to integrate k8s e2e testing into Functest include:**
74 * Creating a docker image with opnfv/functest-core as base image (replaced by xtesting)
75 * Building/setting up the k8s e2e testing framework and it requirements in the docker image
76 * Adding the K8sTesting class which inherits from xtesting.core.testcase.TestCase class. It defines the k8s testcases, ensures required env vars are set and logs test output and results.
77 * Creation of a testcases.yaml file, as required by Functest.
79 Source code can be found on [gerrit](https://gerrit.opnfv.org/gerrit/gitweb?p=functest-kubernetes.git;a=tree)
83 ### Testing OPNFV k8s deployment with Functest
85 To test an example k8s compass deployment, we can do the following
88 **1.** Get and place your k8s deployment config file in a directory accessible by Functest
91 **2.** Create an envfile with required environment variables.
94 DEPLOY_SCENARIO=k8-nosdn-nofeature-ha
95 KUBE_MASTER_IP="192.16.1.210:6443"
96 KUBERNETES_PROVIDER=local
97 KUBE_MASTER_URL=https://192.16.1.210:6443
101 **3.** Run the OPNFV Functest Kubernetes image
104 sudo docker run --env-file envfile \
105 -v path/to/kube/config:/root/.kube/config \
106 opnfv/functest-kubernetes
113 * Version of k8s to be used for testing (currently v1.9.4)
114 * Virtual deployment using various OPNFV deployers (JOID)
118 ### What still needs to be done
120 * Integrating more K8s testcases
121 * Make logging more reliable
122 * Ensure tests work well on different deployments (Compass/Joid/XCI)
123 * Add exhaustive documentation of tests and how they work
124 * Complete/update unit testing
130 *We intend to ensure Functest K8s testing, properly provides functionality testing for OPNFV Kubernetes deployments and to also make it a very reliable testing framework.*