Skip to content

Conversation

@manusa
Copy link
Member

@manusa manusa commented Nov 27, 2025

Trying to speed up the test cases that require additional
kubernetes APIs.

Each time a test suite or test case requires an additional
API (like OpenShift Routes or Kiali CRDs), provided by
k8s.io/apiextensions, a fixed 2 seconds delay is introduced.

There's no way to reduce that delay by using envtest features
or APIServer CLI flags.

The delays are introduced by kube-aggregator, apiextensions, and others:

https://github.com/kubernetes/kube-aggregator/blob/a00232cf7e758c2771b3542033bec19e69e6451a/pkg/controllers/openapiv3/controller.go#L34

https://github.com/kubernetes/apiextensions-apiserver/blob/8db5ab628dd026827c1c9677944432db70c065c3/pkg/apiserver/customresource_handler.go#L381-L394

To mitigate this, we're going to declare all CRDs used in the test in
the common_test.go TestMain function.

This will make sure we only have a single delay at the beginning of
the entire test suite instead of per test suite or test case.

The CRDs are NOT served by default.

For each test suite we'll be able to enable them or disable them
by using the EnvTestEnableCRD and EnvTestDisableCRD functions.
These will also ensure that the API server lists the new APIs or not.

@manusa manusa added this to the 0.1.0 milestone Nov 27, 2025
Trying to speed up the test cases that require additional
kubernetes APIs.

Each time a test suite or test case requires an additional
API (like OpenShift Routes or Kiali CRDs), provided by
k8s.io/apiextensions, a fixed 2 seconds delay is introduced.

There's no way to reduce that delay by using envtest features
or APIServer CLI flags.

The delays are introduced by kube-aggregator, apiextensions, and others:

https://github.com/kubernetes/kube-aggregator/blob/a00232cf7e758c2771b3542033bec19e69e6451a/pkg/controllers/openapiv3/controller.go#L34

https://github.com/kubernetes/apiextensions-apiserver/blob/8db5ab628dd026827c1c9677944432db70c065c3/pkg/apiserver/customresource_handler.go#L381-L394

To mitigate this, we're going to declare all CRDs used in the test in
the common_test.go TestMain function.

This will make sure we only have a single delay at the beginning of
the entire test suite instead of per test suite or test case.

The CRDs are NOT served by default.

For each test suite we'll be able to enable them or disable them
by using the EnvTestEnableCRD and EnvTestDisableCRD functions.
These will also ensure that the API server lists the new APIs or not.

Signed-off-by: Marc Nuri <marc@marcnuri.com>
@manusa manusa requested a review from Cali0707 November 27, 2025 10:11
@manusa
Copy link
Member Author

manusa commented Nov 27, 2025

Merging, I need this as a prereq to complete #386 test improvements.

@manusa manusa merged commit 6491561 into containers:main Nov 27, 2025
10 of 11 checks passed
@manusa manusa deleted the test/envtest-crds branch November 27, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant