Files
my-rook-config/Documentation/Contributing/rook-test-framework.md
T

106 lines
3.6 KiB
Markdown
Raw Normal View History

---
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.
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)
```
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
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:
```console
export TEST_HELM_PATH=/tmp/rook-tests-scripts-helm/helm
export TEST_BASE_DIR=WORKING_DIR
2021-10-28 10:03:35 +02:00
export TEST_SCRATCH_DEVICE=/dev/vdb
```
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.
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
go test -v -timeout 1800s -run CephSmokeSuite github.com/rook/rook/tests/integration
```
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
```
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
```console
export TEST_ENV_NAME=openshift
2024-08-19 11:40:50 +05:30
export TEST_STORAGE_CLASS=gp2-csi
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