This page describes the testing strategy for the Istio CNI plugin and how to run the tests.
The CNI has the following tests available.
-
Unit, functional, and lint tests
-
Istio e2e tests triggered on a istio/cni change
-
Istio e2e tests with the CNI enabled triggered on a istio/istio change
-
Manually executed e2e tests
The primary test environments for testing the Istio CNI plugin are:
- Istio Prow (GKE)
- Developer private test environments
PR triggers from the istio/istio repo will execute a new prow job added to istio/test-infra called e2e_simple_cni. The test wrapper script is added via PR 9557
The "mason" component of istio/test-infra has been modified to create GKE clusters with
the network policy
feature enabled which is a requirement for GKE to enable the CNI network-plugin
in the installed kubelets. This has already been merged into istio/test-infra. The
GKE network policy is enabled by "mason" for prow jobs that call "mason_client"
with --type=gke-e2e-test-latest
(a.k.a. resource type).
make precommit
executes lint and format checks.
To execute all unit and functional tests use the make test
target.
NOTE: The install-test
make target requires docker and filesystem host mount
capability.
The following target triggers the Istio CNI plugin unit-tests:
make cmd-test
- install-test (
make install-test
)- Requires docker
- docker runs the
install-cni
container with test dirs mounted and env vars set to known Kubernetes settings - does file compares to determine if the results match the expected configuration
The istio/cni repo will not have its own e2e tests. The istio/istio e2e tests will be utilized with the CNI enabled to validate that the CNI correctly interoperates with the istio/istio code base. Both the istio/istio repo and the istio/cni repo will have gate tests that run one or more of the Istio e2e tests with the CNI enabled to validate that the CNI works properly.
In order to run the e2e tests in a local environment confirm:
-
That you can successfully run the desired Istio e2e tests in your local environment without the CNI enabled
-
That your local environment supports the requirements for the CNI plugin
To run any of the Istio e2e test follow these steps:
-
Clone the Istio repo in your local environment.
-
Install the CNI components as described in the Usage section: Usage. This might include building your own images and/or charts or pulling the images and charts from official repositories.
-
Step 2 includes setting appropriate Helm values. The HUB and TAG value can be overridden using the environement variables:
export ISTIO_CNI_HUB=yourhub
export ISTIO_CNI_TAG=yourtag
--set "excludeNamespaces={}"
- Run any of the Istio e2e targets after setting up a few environment variables:
export ENABLE_ISTIO_CNI=true
export E2E_ARGS=--kube_inject_configmap=istio-sidecar-injector
The tag $YOUR_CNI_TAG
should be set to the $TAG
value you used when you built your CNI image.
The hub $YOUR_CNI_HUB
should be set to the location you used when you built your CNI image.
Istio in most cases runs the e2e tests in the istio-system
namespace and therefore the excludeNamespaces
must be set to NULL
.
The e2e tests normally use istioctl
to inject the sidecar and it is necessary to use a ConfigMap
without the initContainers
section.
Depending on your environment you may need to override other default settings.
If the tag
and hub
is not set, the test will use the latest hub and tag values checked into the istio/cni repository. The default tag
and hub
values are fine to use if you do not want to build your own CNI images.
The CNI will not be uninstalled after the test is completed.