-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for KUDO integration tests and move into test/integ…
…ration. (#490) * Add documentation for KUDO integration tests and move into test/integration. * Add test/ to Dockerfile. * Document --test since it is already merged. * Improve comments around go test CLI arguments * Move test data for test harness into pkg/test/test_data/.
- Loading branch information
1 parent
9175502
commit 2aa1194
Showing
25 changed files
with
111 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
apiVersion: kudo.k8s.io/v1alpha1 | ||
kind: TestSuite | ||
crdDir: ./config/crds/ | ||
manifestsDir: ./config/samples/test-operator/ | ||
manifestsDir: ./test/manifests/ | ||
testDirs: | ||
- ./pkg/test/test_data/ | ||
- ./test/integration | ||
startKUDO: true | ||
startControlPlane: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Setup | ||
|
||
To setup the tests locally, you need either: | ||
|
||
* Docker | ||
|
||
Or: | ||
|
||
* Go | ||
* kubebuilder | ||
|
||
## Downloading kubebuilder | ||
|
||
To setup kubebuilder, fetch the latest release from [Github](https://github.com/kubernetes-sigs/kubebuilder/releases) and extract `etcd` and `kube-apiserver` into `/usr/local/kubebuilder/bin/`. | ||
|
||
# Docker only | ||
|
||
If you don't want to install kubebuilder and other dependencies of KUDO locally, you can build KUDO and run the tests inside a Docker container. | ||
|
||
To run tests inside a Docker container, you can just execute: | ||
|
||
`./test/run_tests.sh` | ||
|
||
|
||
# Without Docker | ||
|
||
## Running unit tests | ||
|
||
Unit tests are written for KUDO using the standard Go testing library. You can run the unit tests: | ||
|
||
``` | ||
make test | ||
``` | ||
|
||
## Running integration tests | ||
|
||
Or run all tests: | ||
|
||
``` | ||
make integration-test | ||
``` | ||
|
||
## Declarative tests | ||
|
||
Most tests written for KUDO use the [declarative test harness](https://kudo.dev/docs/testing) with the controller-runtime's envtest (which starts `etcd` and `kube-apiserver` locally). This means that tests can be written for and run against KUDO without requiring a Kubernetes cluster (or even Docker). | ||
|
||
The test suite is configured by `kudo-test.yaml` and the tests live in `test/integration/`. Prior to running the tests, all KUDO CRDs and manifests in `test/manifests/` are installed into the test cluster. | ||
|
||
The test harness also starts KUDO, so it is recommended to use `go run` to run the test suite as this will include the latest built changes from your KUDO checkout. | ||
|
||
### CLI examples | ||
|
||
Run all integration tests: | ||
|
||
``` | ||
go run ./cmd/kubectl-kudo test | ||
``` | ||
|
||
Run a specific integration test (e.g., the `patch` test from `test/integration/patch`): | ||
|
||
``` | ||
go run ./cmd/kubectl-kudo test --test patch | ||
``` | ||
|
||
Run tests against a live cluster: | ||
|
||
``` | ||
go run ./cmd/kubectl-kudo test --start-control-plane=false | ||
``` | ||
|
||
Run tests against a live cluster and do not delete resources after running: | ||
|
||
``` | ||
go run ./cmd/kubectl-kudo test --start-control-plane=false --skip-delete | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.7.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.7.9 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.