test(mcp): use envtest built-in features to apply CRDs#516
Merged
manusa merged 1 commit intocontainers:mainfrom Nov 27, 2025
Merged
test(mcp): use envtest built-in features to apply CRDs#516manusa merged 1 commit intocontainers:mainfrom
manusa merged 1 commit intocontainers:mainfrom
Conversation
7e45cf0 to
e254745
Compare
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>
e254745 to
fd8330c
Compare
Member
Author
|
Merging, I need this as a prereq to complete #386 test improvements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.