Files
my-rook-config/tests/README.md
T
Travis Nielsen ce52a07477 test: simplify instructions for minikube
Simplify the test documentation on running the integration tests
to clarify that any K8s cluster can be used, and only support
minikube in the instructions.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2021-09-23 22:16:53 +00:00

117 lines
3.7 KiB
Markdown

# Rook Test Framework
The Rook Test Framework is used to run end to end and integration tests on Rook. The framework depends on a running instance of Kubernetes.
The framework also provides scripts for starting Kubernetes so users can
quickly spin up a Kubernetes cluster. The Test framework is designed to install Rook, run tests, and uninstall Rook.
## Install Kubernetes
You can choose any Kubernetes install of your choice. The test framework only depends on `kubectl` being configured.
An optional helper script is provided to install Kubernetes with minikube.
### Minikube
Starting the cluster on Minikube is as simple as running:
```console
tests/scripts/minikube.sh up
```
To copy Rook images generated from your local build into the Minikube VM, run the following commands after `minikube.sh up` succeeded:
```console
tests/scripts/minikube.sh update
tests/scripts/minikube.sh helm
```
Stopping the cluster and destroying the Minikube VM can be done with:
```console
tests/scripts/minikube.sh clean
```
For faster iteration during development, take a snapshot of the fresh minikube VM and then reset
the VM each time you need a clean environment.
## Install Helm
Use [helm.sh](/tests/scripts/helm.sh) to install Helm and set up Rook charts defined under `_output/charts` (generated by build):
- To install and set up Helm charts for Rook run `tests/scripts/helm.sh up`.
- To clean up `tests/scripts/helm.sh clean`.
**NOTE:** These helper scripts depend on some artifacts under the `_output/` directory generated during build time.
These scripts should be run from the project root. e.g., `tests/script/minikube.sh up`.
**NOTE**: If Helm is not available in your `PATH`, Helm will be downloaded to a temporary directory (`/tmp/rook-tests-scripts-helm`) and used from that directory.
## Run Tests
From the project root do the following after bringing up your Kubernetes cluster such as minikube:
### 1. Build rook
`make build`
### 2. Start Kubernetes
Start the minikube cluster and copy the local build into minikube:
```console
tests/scripts/minikube.sh up
```
### 3. Run integration tests
Some settings are available to run the tests under different environments. The settings are all configured with environment variables.
See [environment.go](/tests/framework/installer/environment.go) for the available environment variables.
At least you should set the following variables.
```console
export TEST_HELM_PATH=/tmp/rook-tests-scripts-helm/linux-amd64/helm
export TEST_BASE_DIR=WORKING_DIR
export TEST_SCRATCH_DEVICE=<block device> # for example, TEST_SCRATCH_DEVICE=/dev/sdb
```
Please note that the integration tests erase the contents of TEST_SCRATCH_DEVICE.
To run all integration tests:
```console
go test -v -timeout 7200s github.com/rook/rook/tests/integration
```
After running tests, you can get test logs under "tests/integration/_output".
To run a specific suite (uses regex):
```console
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration
```
To run specific tests inside a suite:
```console
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration -testify.m TestARookClusterInstallation_SmokeTest
```
### To run tests on OpenShift environment
- Setup OpenShift environment and export KUBECONFIG before executing the tests.
- Make sure `oc` executable file is in the PATH.
- Only `CephSmokeSuite` is currently supported on OpenShift.
- Set few environment variables:
```console
export TEST_ENV_NAME=openshift
export TEST_STORAGE_CLASS=gp2
export TEST_BASE_DIR=/tmp
export RETRY_MAX=40
```
To run the `CephSmokeSuite`:
```console
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration
```