* check for security vulnerabilities on rhel * import * check host is red hat * filepath join * imports
2.8 KiB
Testing
Prerequisites
You need to ensure you have the following tools installed:
- Docker
- GNU make
- Go - only needed for running the tests
- dep (official Go dependency management tool) - needed to prepare for running the tests
- Helm - only needed for running the Kubernetes tests
Prerequisites for testing a RedHat image
If you want to test a container image with Red Hat Enterprise Linux as the base OS, then you need to use a host server with Red Hat Enterprise Linux. You must also have the following tools installed:
Running the tests
There are two main sets of tests:
- Unit tests, which are run during a build
- Docker tests, which test a complete Docker image, using the Docker API
Running the Docker tests
The Docker tests can be run locally on a machine with Docker. For example:
make test-devserver
make test-advancedserver
You can specify the image to use directly by using the MQ_IMAGE_ADVANCEDSERVER or MQ_IMAGE_DEVSERVER variables, for example:
MQ_IMAGE_ADVANCEDSERVER=mqadvanced-server:9.1.1.0-x86_64-ubuntu-16.04 make test-advancedserver
You can pass parameters to go test with an environment variable. For example, to run the "TestGoldenPath" test, run the following command::
TEST_OPTS_DOCKER="-run TestGoldenPath" make test-advancedserver
You can also use the same environment variables you specified when building, for example, the following will try and test an image called mqadvanced-server:9.1.0.0-x86_64-ubuntu-16.04:
MQ_VERSION=9.1.0.0 make test-advancedserver
Running the Docker tests with code coverage
You can produce code coverage results from the Docker tests by running the following:
make build-advancedserver-cover
make test-advancedserver-cover
In order to generate code coverage metrics from the Docker tests, the build step creates a new Docker image with an instrumented version of the code. Each test is then run individually, producing a coverage report each under test/docker/coverage/. These individual reports are then combined. The combined report is written to the coverage directory.
Running the Kubernetes tests
For the Kubernetes tests, you need to have built the Docker image, and pushed it to the registry used by your Kubernetes cluster. Most of the configuration used by the tests is picked up from your kubectl configuration, but you will typically need to specify the image details. For example:
MQ_IMAGE=mycluster.icp:8500/default/mq-devserver make test-kubernetes-devserver