Skip to content

Commit

Permalink
Clean up and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
komer3 committed Apr 30, 2024
1 parent 6ee9c79 commit 369cd1d
Show file tree
Hide file tree
Showing 22 changed files with 415 additions and 18 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/build_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,18 @@ jobs:
if: github.ref == 'refs/heads/main'
run: make e2etest
env:
E2E_FLAGS: '--selector all --assert-timeout 15m0s'
INSTALL_K3S_PROVIDER: true
INSTALL_RKE2_PROVIDER: true
LINODE_REGION: us-sea
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
LINODE_MACHINE_TYPE: g6-standard-2
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/clusterctl-config.yaml
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/gha-clusterctl-config.yaml


- name: Quick E2E Test
if: github.ref != 'refs/heads/main'
run: make e2etest
env:
# TODO: Switch selector to quick before the PR can be merged
E2E_FLAGS: '--assert-timeout 10m0s'
# TODO: ALL the var below need to be deleted before the PR can be merged
INSTALL_K3S_PROVIDER: true
INSTALL_RKE2_PROVIDER: true
LINODE_REGION: us-sea
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
LINODE_MACHINE_TYPE: g6-standard-2
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/clusterctl-config.yaml

- name: Copy logs
if: ${{ always() }}
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ test: generate fmt vet envtest ## Run tests.

.PHONY: e2etest
e2etest: generate local-release local-deploy chainsaw
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e $(E2E_FLAGS)
ifeq ($(strip $(E2E_FLAGS)),) ## If E2E_FLAGS not set, run quick e2e tests
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e --selector quick
else
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e $(E2E_FLAGS)
endif

local-deploy: kind ctlptl tilt kustomize clusterctl
@echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode
Expand Down
44 changes: 41 additions & 3 deletions docs/src/developers/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,52 @@ var _ = Describe("linode creation", func() {
For e2e tests CAPL uses the [Chainsaw project](https://kyverno.github.io/chainsaw) which leverages `kind` and `tilt` to
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/${CONTROLLER_NAME}/${TEST_NAME}`
All test live in the e2e folder with a directory structure of `e2e/${COMPONENT}/${TEST_NAME}`
### Running tests
In order to run e2e tests run the following command
In order to run e2e tests run the following command.
```bash
make e2etest
```
*Note: By default `make e2etest` runs only the controller e2e tests*

In order to run capl-cluster-flavors test, you need to pass flags to chainsaw by setting env var `E2E_FLAGS`

Example: Only running e2e tests for flavors *(default, k3s, rke2)*
```bash
# Required env vars to run flavor 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 E2E_FLAGS='--selector flavors --assert-timeout 10m0s'
```
*Note: We need to bump up the assert timeout to 10 mins to allow the cluster to complete building and become available*

There are other selectors you can use to invoke specfic tests. Please look at the table below for all the selectors available:

| Tests | Selector |
| ------------- | ------------- |
| All E2E Tests | `all` |
| All Controllers | `quick` |
| All Flavors (default, k3s, rke2) | `flavors` |
| K3S Cluster | `k3s` |
| RKE2 Cluster | `rke2` |
| Default (kubeadm) Cluster | `default-cluster` |
| Linode Cluster Controller | `linodecluster` |
| Linode Machine Controller | `linodemachine` |
| Linode Obj Controller | `linodeobj` |
| Linode VPC Controller | `linodevpc` |

*Note: For any flavor e2e tests, please set the required env variables*

### Adding tests
1. Create a new directory under the controller you are testing with the naming scheme of `e2e/${CONTROLLER_NAME}/${TEST_NAME}`
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
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
labels:
default-cluster:
flavors:
all:
spec:
bindings:
# A short identifier for the E2E test run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
labels:
k3s:
flavors:
all:
spec:
bindings:
# A short identifier for the E2E test run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
labels:
rke2:
flavors:
all:
spec:
bindings:
# A short identifier for the E2E test run
Expand Down
Loading

0 comments on commit 369cd1d

Please sign in to comment.