2017-04-28 08:02:37 -07:00
|
|
|
# Rook Test Framework
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2018-06-09 15:40:08 +02:00
|
|
|
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.
|
2021-09-21 15:35:50 -06:00
|
|
|
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.
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2021-09-21 15:35:50 -06:00
|
|
|
## Install Kubernetes
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2022-08-15 17:35:30 +05:30
|
|
|
To install Kubernetes follow Rook's [developer guide](https://rook.io/docs/rook/latest/Contributing/development-environment/).
|
2018-08-22 16:14:59 +02:00
|
|
|
|
2017-09-19 01:10:50 -07:00
|
|
|
## Run Tests
|
2020-04-13 16:10:39 -06:00
|
|
|
|
2021-09-21 15:35:50 -06:00
|
|
|
### 1. Build rook
|
|
|
|
|
|
2021-10-28 10:03:35 +02:00
|
|
|
Now that the Kubernetes cluster is running we need to populate the Docker registry environment variables:
|
2021-09-21 15:35:50 -06:00
|
|
|
|
|
|
|
|
```console
|
2021-10-28 10:03:35 +02:00
|
|
|
eval $(minikube docker-env -p minikube)
|
2018-06-09 15:40:08 +02:00
|
|
|
```
|
|
|
|
|
|
2021-10-28 10:03:35 +02:00
|
|
|
The build process will build and push the images to the Docker registry **inside** the Minikube
|
|
|
|
|
virtual machine.
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
make build
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Now tag the newly built images to `rook/ceph:local-build` for running tests, or `rook/ceph:master` if creating sample manifests::
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
docker tag $(docker images|awk '/build-/ {print $1}') rook/ceph:local-build
|
|
|
|
|
docker tag rook/ceph:local-build rook/ceph:master
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2. Run integration tests
|
2017-06-29 23:58:02 -07:00
|
|
|
|
2020-04-13 16:10:39 -06:00
|
|
|
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.
|
2020-09-02 00:03:48 +09:00
|
|
|
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
|
2021-10-28 10:03:35 +02:00
|
|
|
export TEST_SCRATCH_DEVICE=/dev/vdb
|
2020-09-02 00:03:48 +09:00
|
|
|
```
|
|
|
|
|
|
2022-08-15 17:35:30 +05:30
|
|
|
Change the `TEST_SCRATCH_DEVICE` and point it to the correct block device name based on the driver that's being used.
|
|
|
|
|
If you are using the `virtualbox` minikube driver, the device should be `/dev/sdb`.
|
|
|
|
|
|
|
|
|
|
Please note that the integration tests erase the contents of `TEST_SCRATCH_DEVICE`.
|
2020-04-13 16:10:39 -06:00
|
|
|
|
|
|
|
|
To run all integration tests:
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2020-09-02 00:38:24 +09:00
|
|
|
```console
|
2021-01-08 10:45:48 +00:00
|
|
|
go test -v -timeout 7200s github.com/rook/rook/tests/integration
|
2017-05-17 23:23:05 -07:00
|
|
|
```
|
2020-09-02 00:38:24 +09:00
|
|
|
|
2022-08-15 17:35:30 +05:30
|
|
|
After running tests, you can get test logs under `tests/integration/_output`.
|
2021-03-12 19:57:59 +00:00
|
|
|
|
2020-04-13 16:10:39 -06:00
|
|
|
To run a specific suite (uses regex):
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2020-09-02 00:38:24 +09:00
|
|
|
```console
|
2020-10-09 16:58:25 +00:00
|
|
|
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration
|
2017-05-17 23:23:05 -07:00
|
|
|
```
|
2017-06-29 23:58:02 -07:00
|
|
|
|
2020-04-13 16:10:39 -06:00
|
|
|
To run specific tests inside a suite:
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2020-09-02 00:38:24 +09:00
|
|
|
```console
|
2020-11-27 22:35:24 +09:00
|
|
|
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration -testify.m TestARookClusterInstallation_SmokeTest
|
2017-06-29 23:58:02 -07:00
|
|
|
```
|
2020-08-31 12:33:57 +05:30
|
|
|
|
2021-10-28 10:03:35 +02:00
|
|
|
### 3. To run tests on OpenShift environment
|
2020-08-31 12:33:57 +05:30
|
|
|
|
|
|
|
|
- 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:
|
2021-09-21 15:35:50 -06:00
|
|
|
|
|
|
|
|
```console
|
2020-08-31 12:33:57 +05:30
|
|
|
export TEST_ENV_NAME=openshift
|
|
|
|
|
export TEST_STORAGE_CLASS=gp2
|
|
|
|
|
export TEST_BASE_DIR=/tmp
|
|
|
|
|
export RETRY_MAX=40
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-21 15:35:50 -06:00
|
|
|
To run the `CephSmokeSuite`:
|
|
|
|
|
|
2020-08-31 12:33:57 +05:30
|
|
|
```console
|
2021-02-18 18:24:22 +05:30
|
|
|
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration
|
2020-08-31 12:33:57 +05:30
|
|
|
```
|