A testing tool for running Maistra Service Mesh tasks on an OpenShift 4.x cluster.
This project aims to automate Maistra Service Mesh tasks on an OpenShift 4.x Cluster.
The testing tasks are based on istio.io Doc Tasks
Name | Version |
---|---|
OS | Linux |
Golang | 1.13+ |
OpenSSl | 1.1.1+ |
oc client | 4.x |
Before you run the tests in this repository, you must ensure that the following prerequisites are met:
-
The OpenShift CLI tool
oc
is installed. You can download it from mirror openshift-v4 clients. Extract theopenshift-client-...tar.gz
file and ensure that the parent directory ofoc
andkubectl
is part of yourPATH
environment variable. -
You must be logged into the cluster. You can log in using the command
oc login -u [user] -p [token] --server=[OCP API server]
-
RedHat Service Mesh Operator is installed in the cluster.
-
The
gotestsum
package is installed on the machine used to run the test suite:go install gotest.tools/gotestsum@latest
-
The Helm package manager is installed on the machine used to run the test suite:
To run the tests, you can either use make test
or run the ./scripts/runtests.sh
script directly.
Both approaches are equivalent, since make test
simply runs the runtests.sh
script.
Both support running a single test, a group of tests, or the entire suite.
For information about the test results, refer to section [Test Results](#Test results).
To run all the test cases against all the ServiceMeshControlPlane
versions supported by the current version of the OSSM operator, run the following command:
make test
This command runs the entire test suite against the minimum supported ServiceMeshControlPlane
version, then for the next, and so on.
By default, maistra-test-tool assumes that the OSSM Operator version is 2.4.0
and runs tests against the v2.2
, v2.3
, and v2.4
version of the ServiceMeshControlPlane.
To run against the '2.3.x' version of the Operator, run the tests with the OPERATOR_VERSION
environment variable set to 2.3.x
. For example, for Operator version 2.3.3
, run the tests as follows:
OPERATOR_VERSION=2.3.3 make test
To run all the test cases in a specific test group against all the supported ServiceMeshControlPlane
versions, specify the test group name in the TEST_GROUP
environment variable.
For example, to run the tests in the smoke
group, run the following command:
TEST_GROUP=smoke make test
See pkg/util/test/test.go for a list of available test groups.
To run a single test case against all the supported ServiceMeshControlPlane
versions, specify the name of the test function after make test <name>
.
For example, to run the TestFaultInjection
test case, run the following command:
make test TestFaultInjection
Alternatively, you can run a specific test case by specifying the name in the TEST_CASE
environment.
For example, to run the TestFaultInjection
test case, run the following command:
TEST_CASE=TestFaultInjection make test
See the *_test.go
source files to find the test case names.
By default, make test
runs test cases against all supported versions of ServiceMeshControlPlane
. When you want to run against a single ServiceMeshControlPlane
version, specify the version in the SMCP_VERSION
environment variable.
For example, to run the tests against version v2.4
, run them as follows:
SMCP_VERSION=2.4 make test
NOTE: you may include or omit the v
prefix in the version number.
By default, the tests assume that the cluster nodes use the x86 architecture. If your cluster uses a different architecture, set the OCP_ARCH
environment variable before running the tests.
For IBM Power Systems, run tests with:
OCP_ARCH=p make test
For IBM zSystems, run tests with:
OCP_ARCH=z make test
For ARM-based clusters, run tests with:
OCP_ARCH=arm make test
To run tests on Red Hat Openshift Service on AWS (ROSA), set the ROSA
environment variable to true
:
ROSA=true make test
The test suite contains both single- and multi-cluster test cases.
By default, only single-cluster test cases are run.
To run multi-cluster tests, ensure that the KUBECONFIG2
environment variable points to the kubeconfig
file for the second cluster.
The tests in maistra-test-tool are standard go tests and can be run in an IDE using standard methods. No special setup is required.
Due to the eventually-consistent nature of OpenShift clusters, each test performs a series of retry attempts of each action it performs.
By default, each attempt is logged, which typically results in a series of transient failures being shown in the log.
You can prevent maistra-test-tool from logging each attempt by setting the LOG_FAILED_RETRY_ATTEMPTS
environment variable to false
.
The verbose output is mostly useful while writing or debugging tests. In CI systems, using the less-verbose form might be preffered.
To disable verbose logging, run the tests as follows:
LOG_FAILED_RETRY_ATTEMPTS=false make test
You can also run the test suite in a container, using the image quay.io/maistra/maistra-test-tool:latest
.
In addition to the environment variables explained above, you must also set the following environment variables:
OCP_API_URL
- The URL of the OpenShift API server.OCP_TOKEN
- The authentication token for OpenShift. Alternatively, you can set the username and password via theOCP_CRED_USR
andOCP_CRED_PSW
environment variables.OCP_CRED_USR
- The username to use when logging into OpenShift.OCP_CRED_PSW
- The login password.
For example, to run all the tests against your local CodeReady Containers cluster, run the following command:
podman run -it \
--add-host api.crc.testing:$(crc ip) \
-e OCP_API_URL=https://api.crc.testing:6443 \
-e OCP_TOKEN=<token> \
quay.io/maistra/maistra-test-tool:latest
Use the -e
option to set the environment variables that affect the execution of the test suite, as described in the previous sections.
Each time you run make test
, a new directory named result-<timestamp>
containing the results of the test run is created under tests/
.
Additionally, a symbolic link named result-latest
is updated to point to the latest result directory every time you run make test
.
The result directory might look as the following example:
tests/
└── result-20230203040506/ The root result directory for a particular test run.
├── v2.2/ Contains the results against the v2.3 version of the ServiceMeshControlPlane.
│ ├── failures-must-gather/ Contains must-gather snapshots of cluster resources for each failed test.
│ │ └── 123-TestSomething Must-gather captured when the TestSomething failed.
│ ├── failed.log Output of the failed test cases.
│ ├── output.log Output of all test cases executed for this ServiceMeshControlPlane version.
│ ├── report.xml JUnit XML report for this ServiceMeshControlPlane version.
│ ├── reruns.txt List of test cases that failed and were executed multiple times.
│ └── skipped.log List of skipped test cases and corresponding reasons.
│ └── documentation.txt List of all the test cases and subtest cases executed in the test run and his steps.
├── ...
└── output.log The full test log across all SMCP versions.