Skip to content

Commit bf09e5e

Browse files
committed
docs: add new e2e guide to book
Signed-off-by: Carlos Salas <[email protected]>
1 parent 1b12a43 commit bf09e5e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

docs/book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
- [Try unreleased changes with Nightly Builds](./developers/nightlies.md)
2525
- [Creating a cluster](./developers/cluster-creation.md)
2626
- [CI Jobs](./developers/jobs.md)
27+
- [Adding new E2E test](./developers/e2e.md)
2728
- [Releasing](./developers/releasing.md)
2829
- [Roadmap](./roadmap.md)

docs/book/src/developers/e2e.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Adding new E2E test
2+
3+
E2E tests verify a complete, real-world workflow ensuring that all parts of the system work together as expected. If you are introducing a new feature that interconnects with other parts of the software, you will likely be required to add a verification step for this functionality with a new E2E scenario (unless it is already covered by existing test suites).
4+
5+
<aside class="note">
6+
7+
<h1>Tip</h1>
8+
9+
You can find all logic and configuration files in the E2E folder of the repository [here](https://github.com/kubernetes-sigs/cluster-api-provider-gcp/tree/main/test/e2e)
10+
11+
</aside>
12+
13+
## Create a cluster template
14+
15+
The test suite will provision a cluster based on a pre-defined yaml template (stored in `./test/e2e/data`) which is then sourced in `./test/e2e/config/gcp-ci.yaml`. New cluster definitions for E2E tests have to be added and sourced before being available to use in the E2E workflow.
16+
17+
## Add test case
18+
19+
When the template is available, you can reference it as a flavor in Go. For example, adding a new test for self-managed cluster provisioning would look like the following:
20+
21+
```golang
22+
Context("Creating a control-plane cluster with an internal load balancer", func() {
23+
It("Should create a cluster with 1 control-plane and 1 worker node with an internal load balancer", func() {
24+
By("Creating a cluster with internal load balancer")
25+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
26+
ClusterProxy: bootstrapClusterProxy,
27+
ConfigCluster: clusterctl.ConfigClusterInput{
28+
LogFolder: clusterctlLogFolder,
29+
ClusterctlConfigPath: clusterctlConfigPath,
30+
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
31+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
32+
Flavor: "ci-with-internal-lb",
33+
Namespace: namespace.Name,
34+
ClusterName: clusterName,
35+
KubernetesVersion: e2eConfig.GetVariable(KubernetesVersion),
36+
ControlPlaneMachineCount: ptr.To[int64](1),
37+
WorkerMachineCount: ptr.To[int64](1),
38+
},
39+
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
40+
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
41+
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
42+
}, result)
43+
})
44+
})
45+
```
46+
47+
In this case, the flavor `ci-with-internal-lb` is a reference to the template `cluster-template-ci-with-internal-lb.yaml` which is available in `./test/e2e/data/infrastructure-gcp/cluster-template-ci-with-internal-lb.yaml`.

0 commit comments

Comments
 (0)