Skip to content

CNTRLPLANE-3037,OCPBUGS-78837: Introduce envtest for integration tests - #8016

Closed
clebs wants to merge 2 commits into
openshift:mainfrom
clebs:envtest-poc
Closed

CNTRLPLANE-3037,OCPBUGS-78837: Introduce envtest for integration tests#8016
clebs wants to merge 2 commits into
openshift:mainfrom
clebs:envtest-poc

Conversation

@clebs

@clebs clebs commented Mar 19, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it:

This PR introduces envtest and replicates the existing TestOnCreateAPIUX e2e test (but not replacing it yet).

Shifting part of the tests away from e2e into integration tests that do not require a full environment will help reduce the burden on our CI.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-ci-robot

Copy link
Copy Markdown

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 19, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@clebs: This pull request explicitly references no jira issue.

Details

In response to this:

What this PR does / why we need it:

This PR introduces envtest and replicates the existing TestOnCreateAPIUX e2e test (but not replacing it yet).

Shifting part of the tests away from e2e into integration tests that do not require a full environment will help reduce the burden on our CI.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2026
@openshift-ci

openshift-ci Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 42ad9f1e-04dd-4d56-9924-ec7a2ceef078

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci

openshift-ci Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: clebs
Once this PR has been reviewed and has the lgtm label, please assign enxebre for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added area/ci-tooling Indicates the PR includes changes for CI or tooling area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Mar 19, 2026
@clebs

clebs commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

/test all

@clebs

clebs commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

/test all

@enxebre enxebre changed the title NO-JIRA: Introduce envtest for integration tests CNTRLPLANE-3037: Introduce envtest for integration tests Mar 20, 2026
@openshift-ci-robot

openshift-ci-robot commented Mar 20, 2026

Copy link
Copy Markdown

@clebs: This pull request references CNTRLPLANE-3037 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

What this PR does / why we need it:

This PR introduces envtest and replicates the existing TestOnCreateAPIUX e2e test (but not replacing it yet).

Shifting part of the tests away from e2e into integration tests that do not require a full environment will help reduce the burden on our CI.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Comment thread test/envtest/create_cluster_test.go Outdated
// Start envtest with HyperShift CRDs
testEnv := &envtest.Environment{
CRDDirectoryPaths: []string{crdDir},
// Use TechPreviewNoUpgrade CRDs to include GCP validations

@enxebre enxebre Mar 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  // Use TechPreviewNoUpgrade CRDs to include GCP validations

where is this enforced? the path contains also default CRD version. I assume last one would win and it's circumstantially TechPreview? which is fragile.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll also want to install all the capi CRDs.
Basically what --install command with tech preview would apply.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the simplest approach here as first try. Now looking closer at the e2e I see I missed the whole filtering logic on assets.

I will use that package the same way the original test does when installing so we can select the feature set to test. Maybe for now with an env var defaulting to TechPreviewNoUpgrade.

Comment thread Makefile
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(SETUP_ENVTEST) sigs.k8s.io/controller-runtime/tools/setup-envtest

.PHONY: setup-envtest
setup-envtest: $(SETUP_ENVTEST) ## Setup envtest binaries (etcd, kube-apiserver)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll want to make this plumbing more flexible so we can test with different kas API versions

@enxebre enxebre Mar 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Alberto

I don't care too much about running individual validation tests on older API servers, but I do think we need to at least take all CRDs and install them on the oldest OCP KAS that managed services are currently using (4.15 to my knowledge) and then as we start to enforce a skew policy and they upgrade to newer releases, we can bump that and hopefully get to a point where it is N-3 consistently going forward

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need ability to test against oldest ocp (4.15) and oldest vanilla kube (to be confirmed).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently have 4.17+ OCP KAS in the index, shouldn't be too hard to push 4.15 and 4.16

Upstream goes back to 1.28 (which is equiv to 4.15) so hopefully the minimum vanilla is at least that

@enxebre

enxebre commented Mar 20, 2026

Copy link
Copy Markdown
Member

/area api
/assign @JoelSpeed

@openshift-ci openshift-ci Bot added the area/api Indicates the PR includes changes for the API label Mar 20, 2026
@JoelSpeed

Copy link
Copy Markdown
Contributor

In openshift/api we made the choice to leverage YAML based testing for our integration tests. With the structured testing you currently have, you have no visibility into the marshalled content that is actually being sent to the API server. This can mask issues in your APIs (e.g. not having omitempty on a required field) so you may want to either us unstructured or switch to YAML as we do

You'll also want to look at the possibility of testing ratcheting validations. Over time you may want to make validation tighter, and with that you need a way to install older, invalid schemas and check the ratcheting.

It might be worth looking over our test suite for inspiration

@enxebre

enxebre commented Mar 20, 2026

Copy link
Copy Markdown
Member

Let's adjust the PR to cover #8016 (comment)
Get that gating on CI.
Then follow up to address #8016 (comment)

clebs added 2 commits March 20, 2026 17:51
- Add an envtest setup goal on the Makefile
- Add a new unit test using envtest to cover the same as the create
  cluster e2e test.

Signed-off-by: Borja Clemente <bclement@redhat.com>
Introducing envtest requires adding new dependencies, which are being
vendored in a separate commit to ease review.

Signed-off-by: Borja Clemente <bclement@redhat.com>
Comment thread Makefile

# Setup envtest for running tests that require a Kubernetes API server
# SETUP_ENVTEST_VER is the version of setup-envtest to use, matching the version in hack/tools/go.mod
KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.34.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.22 is 1.35, pretty sure we have 1.35 binaries published that you can use

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did take 1.34 because that is what hypershift is currently built with. If I should follow OCP k8s version instead I will look into this as part of the above effort to make the setup parametric.

crdObjects := installassets.CustomResourceDefinitions(
func(path string, crd *apiextensionsv1.CustomResourceDefinition) bool {
if !strings.Contains(path, "hypershift-operator/") {
return false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this excludes all the API CRDs which we would want to include as well

@jparrill

jparrill commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

/retitle CNTRLPLANE-3037,OCPBUGS-78837: Introduce envtest for integration tests

@openshift-ci openshift-ci Bot changed the title CNTRLPLANE-3037: Introduce envtest for integration tests CNTRLPLANE-3037,OCPBUGS-78837: Introduce envtest for integration tests Mar 23, 2026
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Mar 23, 2026
@openshift-ci-robot

openshift-ci-robot commented Mar 23, 2026

Copy link
Copy Markdown

@clebs: This pull request references CNTRLPLANE-3037 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

This pull request references Jira Issue OCPBUGS-78837, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

What this PR does / why we need it:

This PR introduces envtest and replicates the existing TestOnCreateAPIUX e2e test (but not replacing it yet).

Shifting part of the tests away from e2e into integration tests that do not require a full environment will help reduce the burden on our CI.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jparrill

Copy link
Copy Markdown
Contributor

The jira above was created to track this issue OCPBUGS-78837. Discussed on slack that this would be detected using this testEnv.

@enxebre

enxebre commented Mar 23, 2026

Copy link
Copy Markdown
Member

superseded by #8034

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2026
@openshift-ci

openshift-ci Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

@clebs: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security e622b97 link true /test security

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@clebs

clebs commented Mar 31, 2026

Copy link
Copy Markdown
Member Author

/close

An alternative PR merged #8089

@openshift-ci openshift-ci Bot closed this Mar 31, 2026
@openshift-ci

openshift-ci Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

@clebs: Closed this PR.

Details

In response to this:

/close

An alternative PR merged #8089

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@clebs
clebs deleted the envtest-poc branch August 4, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Indicates the PR includes changes for the API area/ci-tooling Indicates the PR includes changes for CI or tooling area/testing Indicates the PR includes changes for e2e testing do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants