2017-04-28 08:02:37 -07:00
# Rook Test Framework
2017-06-26 21:52:06 -07:00
2017-07-20 23:30:32 -07: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.
The framework also provides scripts for starting kubernetes using kubeadm or minikube so users can
2017-08-09 17:34:10 -07:00
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
2017-05-03 16:43:33 -07:00
## Requirements
2017-04-28 08:02:37 -07:00
1. Docker version => 1.2 && < 17.0
2017-07-20 23:30:32 -07:00
2. Ubuntu 16 (the framework has only been tested on this version)
2017-06-29 23:58:02 -07:00
3. Kubernetes with kubectl configured
4. Rook
2017-06-26 21:52:06 -07:00
## Instructions
2017-05-03 16:43:33 -07:00
2017-07-20 23:30:32 -07:00
### Setup
2017-06-29 23:58:02 -07:00
#### Install Kubernetes
2017-07-20 23:30:32 -07:00
You can choose any kubernetes flavor of your choice. The test framework only depends on kubectl being configured.
The framework also provides scripts to install Kubernetes. There are two scripts to start the cluster:
2017-09-28 12:05:20 -07:00
1. **Minikube** (recommended for MacOS): Run [minikube.sh ](/tests/scripts/minikube.sh ) to setup a single-node Minikube kubernetes.
1. Minikube v0.21.0 and higher is supported. Older minikube versions do not have cephfs or rbd tools installed.
1. If using Kubernetes v1.7.3 or higher, then Minikube v0.22.2 or higher is required.
1. **Kubeadm** (recommended for ubuntu): run [kubeadm.sh ](/tests/scripts/kubeadm.sh ) to setup a single-node K8s cluster using kubeadm
2017-08-09 17:34:10 -07:00
These start-up scripts are designed to start any version of kubernetes, Based on `KUBE_VERSION` environment variable
2017-09-06 23:36:13 -07:00
By default they start kubernetes version v1.7.5.
2017-08-09 17:34:10 -07:00
e.g. To kubernetes version v1.6.7
```
export KUBE_VERSION=v1.6.7
tests/scripts/kubeadm.sh up
```
2017-08-24 14:55:01 -07:00
To stop the cluster : `tests/scripts/kubeadm.sh clean` or `tests/scripts/miniube.sh clean`
2017-06-29 23:58:02 -07:00
2017-09-06 23:36:13 -07:00
To copy rook images generated by build into minikube vm, run the following commands after `minikube.sh up`
```
tests/scripts/minikube.sh update
tests/scripts/minikube.sh helm
2017-09-28 12:05:20 -07:00
```
kubeadm.sh starts kubernetes on the host, so all the images generated by build should be available to the cluster.
2017-09-06 23:36:13 -07:00
2017-04-28 08:02:37 -07:00
2017-08-24 14:55:01 -07:00
### 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:** *kubeadm.sh, minikube.sh and helm.sh scripts depend on some artifacts under _output dir generated during build time, these scripts
should be run from project root. eg* `tests/script/kubeadm.sh up`
2017-04-28 08:02:37 -07:00
2017-09-19 01:10:50 -07:00
## Run Tests
From the project root do the following:
#### 1. Build rook:
run `make build`
#### 2. Start kubernetes
using one of the following:
2017-09-06 23:36:13 -07:00
- using Kubeadm
```
tests/scripts/kubeadm.sh up
2017-09-19 01:10:50 -07:00
tests/scripts/helm.sh up
` ``
2017-09-06 23:36:13 -07:00
- using minikube
` ``
tests/scripts/minikube.sh up
tests/scripts/minikube.sh helm
tests/scripts/helm.sh up
` ``
2017-06-26 21:52:06 -07:00
2017-09-19 01:10:50 -07:00
#### 3. Run integration tests:
Integration tests can be run using tests binary ` _output/tests/${platform}/integration` that is generated during build time
eg ` ~/integration -test.v `
2017-06-29 23:58:02 -07:00
### Test parameters
2017-09-19 01:10:50 -07:00
In addition to standard go tests parameters, the following custom parameters are available while running tests
2017-05-17 23:23:05 -07:00
Parameter | Description | Possible values | Default
2017-06-26 21:52:06 -07:00
--- |--- | --- | ---
2017-05-17 23:23:05 -07:00
rook_platform| platform rook needs to be installed on | kubernetes | kubernetes
2017-09-28 12:05:20 -07:00
k8s_version | version of Kubernetes to be installed | v1.5+ | v1.7.5
2017-06-26 21:52:06 -07:00
rook_image | rook image name to be installed | valid image name | rook/rook
toolbox_image | toolbox image name to be installed | valid image name | rook/toolbox
2017-05-17 23:23:05 -07:00
skip_install_rook | skips installing rook (if already installed) | true or false | false
2017-06-29 23:58:02 -07:00
load_parallel_runs | performs concurrent operations (optional used for load test) | any number | 20
2017-05-17 23:23:05 -07:00
2017-07-20 23:30:32 -07:00
If the ` install_rook` flag is set to false, then all the other flags are ignored
and tests are run without rook being installed and setup. Use this flag to run tests against
2017-06-26 21:52:06 -07:00
a pre-installed/configured rook.
2017-05-17 23:23:05 -07:00
2017-09-19 01:10:50 -07:00
2017-08-09 17:34:10 -07:00
### Running Tests with parameters.
2017-05-17 23:23:05 -07:00
2017-07-20 23:30:32 -07:00
#### To run all integration tests run
2017-05-17 23:23:05 -07:00
` ``
2017-09-19 01:10:50 -07:00
go test -v -timeout 1800s github.com/rook/rook/tests/integration
2017-05-17 23:23:05 -07:00
` ``
2017-09-19 01:10:50 -07:00
#### To run a specific suite (uses regex)
2017-06-29 23:58:02 -07:00
` ``
2017-09-19 01:10:50 -07:00
go test -v -timeout 1800s -run SmokeSuite github.com/rook/rook/tests/integration
2017-05-17 23:23:05 -07:00
` ``
2017-06-29 23:58:02 -07:00
2017-09-19 01:10:50 -07:00
#### To run specific tests inside a suite:
2017-05-17 23:23:05 -07:00
` ``
2017-09-19 01:10:50 -07:00
go test -v -timeout 1800s -run SmokeSuite github.com/rook/rook/tests/integration -testify.m TestRookClusterInstallation_smokeTest
2017-06-29 23:58:02 -07:00
` ``
2017-09-19 01:10:50 -07:00
##### To run specific without installing rook
2017-06-29 23:58:02 -07:00
` ``
2017-09-19 01:10:50 -07:00
go test -v -timeout 1800s -run SmokeSuite github.com/rook/rook/tests/integration --skip_install_rook=true
2017-06-29 23:58:02 -07:00
` ``
2017-07-20 23:30:32 -07:00
If the ` skip_install_rook` flag is set to true, then rook is not uninstalled either.
2017-06-29 23:58:02 -07:00
2017-06-08 12:19:48 -07:00
#### Run Longhaul Tests
2017-07-20 23:30:32 -07:00
Using the ` go test -count n` option, any tests can be repeated ` n` number of times to simulate load or longhaul test. Although
any test can be converted to a longhaul test, it's ideal to run integration tests under load for an extended period. Also a new custom test flag ` load_parallel_runs` is added to control the number of concurrent operations being performed.
2017-06-29 23:58:02 -07:00
For example look at the [block long haul test](/tests/block/k8s/longhaul/basicBlockonghaul_test.go)
2017-06-08 12:19:48 -07:00
To run a longhaul test you can run any integration test with ` -count` and ` --load_parallel_runs` options
e.g.
` ``
2017-08-09 17:34:10 -07:00
go test -run TestK8sBlockLongHaul github.com/rook/rook/tests/longhaul --load_parallel_runs=20 -count=1000
2017-06-08 12:19:48 -07:00
` ``
2017-08-09 17:34:10 -07:00
The Longhaul test just like other test is going to install rook if it's not already installed, but it is not going to clean up test data or uninstall rook after the run.
Longhaul test is designed to run multiple times on the same setup and installation of rook to tests its stability. Test Data and rook should be cleaned up manually after the test.
2017-05-17 23:23:05 -07:00
Prerequisites :
2017-07-20 23:30:32 -07:00
* Go installed and GO_PATH set
2017-10-27 13:48:07 -07:00
* Dep installed
2017-07-20 23:30:32 -07:00
* when running tests locally, make sure ` kubectl` is accessible globally as the test framework uses kubectl
2017-05-17 23:23:05 -07:00