Skip to content

Commit

Permalink
Add testing page to mdbook (#302)
Browse files Browse the repository at this point in the history
* Add testing page to mdbook

---------

Co-authored-by: Khaja Omer <[email protected]>
  • Loading branch information
komer3 and komer3 authored May 2, 2024
1 parent 3ac4ac0 commit eb93610
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
- [VPC](./topics/vpc.md)
- [Development](./developers/development.md)
- [Releasing](./developers/releasing.md)
- [Testing](./developers/testing.md)
- [Reference](./reference/reference.md)
15 changes: 14 additions & 1 deletion docs/src/developers/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 15 additions & 4 deletions docs/src/developers/testing.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# CAPL Testing

<!-- TOC depthFrom:2 -->

- [Unit Tests](#unit-tests)
- [Executing Tests](#executing-tests)
- [Creating Tests](#creating-tests)
- [E2E Tests](#e2e-tests)
- [Running Tests](#running-tests)
- [Adding Tests](#adding-tests)

<!-- /TOC -->

## 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`.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eb93610

Please sign in to comment.