diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index b275e9866..dbd8380c3 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -25,4 +25,5 @@ - [VPC](./topics/vpc.md) - [Development](./developers/development.md) - [Releasing](./developers/releasing.md) + - [Testing](./developers/testing.md) - [Reference](./reference/reference.md) diff --git a/docs/src/developers/development.md b/docs/src/developers/development.md index 64c5c32a7..251f5d9ea 100644 --- a/docs/src/developers/development.md +++ b/docs/src/developers/development.md @@ -259,10 +259,23 @@ For any issues, please refer to the [troubleshooting guide](../topics/troublesho To run E2E locally run: ```sh +# Required env vars to run e2e tests +export INSTALL_K3S_PROVIDER=true +export INSTALL_RKE2_PROVIDER=true +export LINODE_REGION=us-sea +export LINODE_CONTROL_PLANE_MACHINE_TYPE=g6-standard-2 +export LINODE_MACHINE_TYPE=g6-standard-2 + +# IMPORTANT: Set linode, k3s, and rke2 providers in this config file. +# Find an example at e2e/gha-clusterctl-config.yaml +export CLUSTERCTL_CONFIG=~/.cluster-api/clusterctl.yaml + make e2etest ``` -This command creates a KIND cluster, and executes all the defined tests. +This command creates a KIND cluster, and executes all the defined tests. + +For more details on E2E tests, please refer to [E2E Testing](./testing.md) ```admonish warning Please ensure you have [increased maximum open files on your host](https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files) diff --git a/docs/src/developers/testing.md b/docs/src/developers/testing.md index 526c021fe..24dc6307d 100644 --- a/docs/src/developers/testing.md +++ b/docs/src/developers/testing.md @@ -1,12 +1,23 @@ # CAPL Testing + + +- [Unit Tests](#unit-tests) + - [Executing Tests](#executing-tests) + - [Creating Tests](#creating-tests) +- [E2E Tests](#e2e-tests) + - [Running Tests](#running-tests) + - [Adding Tests](#adding-tests) + + + ## Unit Tests -### Running Tests +### Executing Tests In order to run the unit tests run the following command ```bash make test ``` -### Adding tests +### Creating Tests General unit tests of functions follow the same conventions for testing using Go's `testing` standard library, along with the [testify](https://github.com/stretchr/testify) toolkit for making assertions. Unit tests that require API clients use mock clients generated using [gomock](https://github.com/uber-go/mock). To simplify the usage of mock clients, this repo also uses an internal library defined in `mock/mocktest`. @@ -178,7 +189,7 @@ For e2e tests CAPL uses the [Chainsaw project](https://kyverno.github.io/chainsa spin up a cluster with the CAPL controllers installed and then uses `chainsaw-test.yaml` files to drive e2e testing. All test live in the e2e folder with a directory structure of `e2e/${COMPONENT}/${TEST_NAME}` -### Running tests +### Running Tests In order to run e2e tests run the following commands: ```bash # Required env vars to run e2e tests @@ -220,7 +231,7 @@ There are other selectors you can use to invoke specfic tests. Please look at th *Note: For any flavor e2e tests, please set the required env variables* -### Adding tests +### Adding Tests 1. Create a new directory under the controller you are testing with the naming scheme of `e2e/${COMPONENT}/${TEST_NAME}` 2. Create a minimal `chainsaw-test.yaml` file in the new test dir ```yaml