2023-08-16 23:24:33 -06:00
|
|
|
---
|
|
|
|
|
title: Rook Test Framework
|
|
|
|
|
---
|
|
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
# Integration Tests
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
The integration tests run end-to-end tests on Rook in a running instance of Kubernetes.
|
|
|
|
|
The framework includes scripts for starting Kubernetes so users can
|
|
|
|
|
quickly spin up a Kubernetes cluster. The tests are generally designed to install Rook, run tests, and uninstall Rook.
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
The CI runs the integration tests with each PR and each master or release branch build.
|
2023-08-23 18:49:28 +05:30
|
|
|
If the tests fail in a PR, [access](development-flow.md#tmate-session) the tmate for debugging.
|
2017-06-26 21:52:06 -07:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
This document will outline the steps to run the integration tests locally in a minikube environment, should the CI
|
|
|
|
|
not be sufficient to troubleshoot.
|
2018-08-22 16:14:59 +02:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
!!! hint
|
|
|
|
|
The CI is generally much simpler to troubleshoot than running these tests locally. Running the tests locally is rarely necessary.
|
2020-04-13 16:10:39 -06:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
!!! warning
|
|
|
|
|
A risk of running the tests locally is that a local disk is required during the tests. If not running
|
|
|
|
|
in a VM, your laptop or other test machine could be destroyed.
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
## Install Minikube
|
|
|
|
|
|
|
|
|
|
Follow Rook's [developer guide](https://rook.io/docs/rook/latest/Contributing/development-environment/) to install Minikube.
|
|
|
|
|
|
|
|
|
|
## Build Rook image
|
|
|
|
|
|
|
|
|
|
Now that the Kubernetes cluster is running we need to populate the Docker registry to allow local image builds
|
|
|
|
|
to be easily used inside Minikube.
|
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
|
|
|
```
|
|
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
`make build` will now build and push the images to the Docker registry **inside** the Minikube
|
2021-10-28 10:03:35 +02:00
|
|
|
virtual machine.
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
make build
|
|
|
|
|
```
|
|
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
Tag the newly built images to `rook/ceph:local-build` for running tests, or `rook/ceph:master` if creating example manifests::
|
2021-10-28 10:03:35 +02:00
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
docker tag $(docker images|awk '/build-/ {print $1}') rook/ceph:local-build
|
|
|
|
|
docker tag rook/ceph:local-build rook/ceph:master
|
|
|
|
|
```
|
|
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
## 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.
|
2023-05-19 13:05:28 -06:00
|
|
|
|
|
|
|
|
Set the following variables:
|
2020-09-02 00:03:48 +09:00
|
|
|
|
|
|
|
|
```console
|
2022-02-07 17:43:24 +01:00
|
|
|
export TEST_HELM_PATH=/tmp/rook-tests-scripts-helm/helm
|
2020-09-02 00:03:48 +09:00
|
|
|
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
|
|
|
```
|
|
|
|
|
|
2025-06-12 12:08:53 +02:00
|
|
|
The `helm` tool is expected to be installed on the system. If it is not available in the `$PATH`, set the variable `TEST_HELM_PATH`.
|
|
|
|
|
otherwise, it should be set to the non-standard location of the `helm` binary.
|
|
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
Set `TEST_SCRATCH_DEVICE` to the correct block device name based on the driver that's being used.
|
2022-08-15 17:35:30 +05:30
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
!!! hint
|
|
|
|
|
If using the `virtualbox` minikube driver, the device should be `/dev/sdb`
|
2020-04-13 16:10:39 -06:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
!!! warning
|
|
|
|
|
The integration tests erase the contents of `TEST_SCRATCH_DEVICE` when the test is completed
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
To run a specific suite, specify the suite name:
|
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
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
After running tests, see test logs under `tests/integration/_output`.
|
|
|
|
|
|
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
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
!!! info
|
|
|
|
|
Only the golang test suites are documented to run locally. Canary and other tests have only ever been supported in the CI.
|
2020-08-31 12:33:57 +05:30
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
## Running tests on OpenShift
|
|
|
|
|
|
|
|
|
|
1. Setup OpenShift environment and export KUBECONFIG
|
|
|
|
|
2. Make sure `oc` executable file is in the PATH.
|
|
|
|
|
3. Only the `CephSmokeSuite` is currently supported on OpenShift.
|
|
|
|
|
4. Set the following environment variables depending on the environment:
|
2021-09-21 15:35:50 -06:00
|
|
|
|
2024-04-22 11:54:27 -06:00
|
|
|
```console
|
|
|
|
|
export TEST_ENV_NAME=openshift
|
2024-08-19 11:40:50 +05:30
|
|
|
export TEST_STORAGE_CLASS=gp2-csi
|
2024-04-22 11:54:27 -06:00
|
|
|
export TEST_BASE_DIR=/tmp
|
|
|
|
|
```
|
2020-08-31 12:33:57 +05:30
|
|
|
|
2023-05-19 13:05:28 -06:00
|
|
|
5. Run the integration tests
|