You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/src/developer/testing.md
+15-16Lines changed: 15 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,8 @@ if this is not possible, a viable solution is to use mocks (e.g CAPA).
27
27
28
28
### Generic providers
29
29
When writing tests core Cluster API contributors should ensure that the code works with any providers, and thus it is required
30
-
to not use any specific provider implementation. Instead, the so-called generic providers e.g. "GenericInfrastructureCluster"
31
-
should be used because they implement the plain Cluster API contract. This prevents tests from relying on assumptions that
30
+
to not use any specific provider implementation. Instead, the so-called generic providers e.g. "GenericInfrastructureCluster"
31
+
should be used because they implement the plain Cluster API contract. This prevents tests from relying on assumptions that
32
32
may not hold true in all cases.
33
33
34
34
Please note that in the long term we would like to improve the implementation of generic providers, centralizing
@@ -46,11 +46,11 @@ the test cluster.
46
46
With this approach it is possible to interact with Cluster API almost like in a real environment, by creating/updating
47
47
Kubernetes objects and waiting for the controllers to take action. See the [quick reference](#quick-reference) below for more details.
48
48
49
-
Also in case of integration tests, considerations about [mocking external APIs](#mocking-external-apis) and usage of [generic providers](#generic-providers) apply.
49
+
Also in case of integration tests, considerations about [mocking external APIs](#mocking-external-apis) and usage of [generic providers](#generic-providers) apply.
50
50
51
51
## Fuzzing tests
52
52
53
-
Fuzzing tests automatically inject randomly generated inputs, often invalid or with unexpected values, into functions to discover vulnerabilities.
53
+
Fuzzing tests automatically inject randomly generated inputs, often invalid or with unexpected values, into functions to discover vulnerabilities.
54
54
55
55
Two different types of fuzzing are currently being used on the Cluster API repository:
56
56
@@ -78,7 +78,7 @@ In light of continuing improving our practice around this ambitious goal, we are
78
78
79
79
Each contribution in growing this set of utilities or their adoption across the codebase is more than welcome!
80
80
81
-
Another consideration that can help in improving test maintainability is the idea of testing "by layers"; this idea could
81
+
Another consideration that can help in improving test maintainability is the idea of testing "by layers"; this idea could
82
82
apply whenever we are testing "higher-level" functions that internally uses one or more "lower-level" functions;
83
83
in order to avoid writing/maintaining redundant tests, whenever possible contributors should take care of testing
84
84
_only_ the logic that is implemented in the "higher-level" function, delegating the test function called internally
@@ -243,28 +243,27 @@ Execute the run configuration with `Debug`.
243
243
244
244
<h1>Tips</h1>
245
245
246
-
The e2e tests create a new management cluster with kind on each run. To avoid this and speed up the test execution the tests can
246
+
The e2e tests create a new management cluster with kind on each run. To avoid this and speed up the test execution the tests can
247
247
also be run against a management cluster created by [tilt](./tilt.md):
248
248
```bash
249
249
# Create a kind cluster
250
250
./hack/kind-install-for-capd.sh
251
251
# Set up the management cluster via tilt
252
-
tilt up
252
+
tilt up
253
253
```
254
254
Now you can start the e2e test via IDE as described above but with the additional `-e2e.use-existing-cluster=true` flag.
255
255
256
256
**Note**: This can also be used to debug controllers during e2e tests as described in [Developing Cluster API with Tilt](./tilt.md#wiring-up-debuggers).
257
257
258
-
The e2e tests also create a local clusterctl repository. After it has been created on a first test execution this step can also be
259
-
skipped by setting `-e2e.clusterctl-config=<ARTIFACTS>/repository/clusterctl-config.yaml`. This also works with a clusterctl repository created
258
+
The e2e tests also create a local clusterctl repository. After it has been created on a first test execution this step can also be
259
+
skipped by setting `-e2e.clusterctl-config=<ARTIFACTS>/repository/clusterctl-config.yaml`. This also works with a clusterctl repository created
260
260
via [Create the local repository](http://localhost:3000/clusterctl/developers.html#create-the-local-repository).
261
261
262
262
**Feature gates**: E2E tests often use features which need to be enabled first. Make sure to enable the feature gates in the tilt settings file:
263
263
```yaml
264
264
kustomize_substitutions:
265
265
CLUSTER_TOPOLOGY: "true"
266
266
EXP_MACHINE_POOL: "true"
267
-
EXP_CLUSTER_RESOURCE_SET: "true"
268
267
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
269
268
EXP_RUNTIME_SDK: "true"
270
269
EXP_MACHINE_SET_PREFLIGHT_CHECKS: "true"
@@ -352,7 +351,7 @@ As alternative to loki, JSON logs can be visualized with a human readable timest
352
351
353
352
The `(. | tostring)` part could also be customized to only output parts of the JSON logline.
354
353
E.g.:
355
-
354
+
356
355
* `(.err)` to only output the error message part.
357
356
* `(.msg)` to only output the message part.
358
357
* `(.controller + " " + .msg)` to output the controller name and message part.
@@ -405,7 +404,7 @@ func TestMain(m *testing.M) {
405
404
```
406
405
407
406
Most notably, [envtest] provides not only a real API server to use during testing, but it offers the opportunity
408
-
to configure one or more controllers to run against the test cluster, as well as creating informers index.
407
+
to configure one or more controllers to run against the test cluster, as well as creating informers index.
409
408
410
409
```golang
411
410
func TestMain(m *testing.M) {
@@ -423,7 +422,7 @@ func TestMain(m *testing.M) {
423
422
if err := index.AddDefaultIndexes(ctx, mgr); err != nil {
424
423
panic(fmt.Sprintf("unable to setup index: %v", err))
425
424
}
426
-
425
+
427
426
// Run tests
428
427
...
429
428
}
@@ -440,8 +439,8 @@ should take care in ensuring each test runs in isolation from the others, by:
440
439
- Avoiding object name conflict.
441
440
442
441
Developers should also be aware of the fact that the informers cache used to access the [envtest]
443
-
depends on actual etcd watches/API calls for updates, and thus it could happen that after creating
444
-
or deleting objects the cache takes a few milliseconds to get updated. This can lead to test flakes,
442
+
depends on actual etcd watches/API calls for updates, and thus it could happen that after creating
443
+
or deleting objects the cache takes a few milliseconds to get updated. This can lead to test flakes,
445
444
and thus it always recommended to use patterns like create and wait or delete and wait; Cluster API env
446
445
test provides a set of utils for this scope.
447
446
@@ -530,7 +529,7 @@ comes with a set of limitations that could hamper the validity of a test, most n
530
529
of the test objects.
531
530
- the [fakeclient] does not use a cache based on informers/API calls/etcd watches, so the test written in this way
532
531
can't help in surfacing race conditions related to how those components behave in real cluster.
533
-
- there is no support for cache index/operations using cache indexes.
532
+
- there is no support for cache index/operations using cache indexes.
534
533
535
534
Accordingly, using [fakeclient] is not suitable for all the use cases, so in some cases contributors will be required
536
535
to use [envtest] instead. In case of doubts about which one to use when writing tests, don't hesitate to ask for
The `ClusterResourceSet` feature is introduced to provide a way to automatically apply a set of resources (such as CNI/CSI) defined by users to matching newly-created/existing clusters.
Copy file name to clipboardExpand all lines: docs/book/src/tasks/experimental-features/experimental-features.md
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ temporary location for features which will be moved to their permanent locations
8
8
Users can enable/disable features by setting OS environment variables before running `clusterctl init`, e.g.:
9
9
10
10
```yaml
11
-
export EXP_CLUSTER_RESOURCE_SET=true
11
+
export EXP_RUNTIME_SDK=true
12
12
13
13
clusterctl init --infrastructure vsphere
14
14
```
15
15
16
16
As an alternative to environment variables, it is also possible to set variables in the clusterctl config file located at `$XDG_CONFIG_HOME/cluster-api/clusterctl.yaml`, e.g.:
17
17
```yaml
18
18
# Values for environment variable substitution
19
-
EXP_CLUSTER_RESOURCE_SET: "true"
19
+
EXP_RUNTIME_SDK: "true"
20
20
```
21
21
In case a variable is defined in both the config file and as an OS environment variable, the environment variable takes precedence.
22
22
For more information on how to set variables for clusterctl, see [clusterctl Configuration File](../../clusterctl/configuration.md)
@@ -30,7 +30,6 @@ As an example, Cluster API Provider Azure (CAPZ) has support for MachinePool thr
30
30
One way is to set experimental variables on the clusterctl config file. For CAPI, these configs are under ./test/e2e/config/... such as `docker.yaml`:
31
31
```yaml
32
32
variables:
33
-
EXP_CLUSTER_RESOURCE_SET: "true"
34
33
EXP_MACHINE_POOL: "true"
35
34
CLUSTER_TOPOLOGY: "true"
36
35
EXP_RUNTIME_SDK: "true"
@@ -45,7 +44,6 @@ On development environments started with `Tilt`, features can be enabled by sett
Copy file name to clipboardExpand all lines: docs/book/src/user/quick-start.md
-1Lines changed: 0 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -746,7 +746,6 @@ project][Proxmox getting started guide].
746
746
747
747
Please follow the Cluster API Provider for [Cloud Director Getting Started Guide](https://github.com/vmware/cluster-api-provider-cloud-director/blob/main/README.md)
0 commit comments