Skip to content

GCP-688: Port v1 E2E validations to envtest, unit tests, and v2 Ginkgo specs#8511

Open
cblecker wants to merge 7 commits into
openshift:mainfrom
cblecker:worktree-smooth-hatching-thompson
Open

GCP-688: Port v1 E2E validations to envtest, unit tests, and v2 Ginkgo specs#8511
cblecker wants to merge 7 commits into
openshift:mainfrom
cblecker:worktree-smooth-hatching-thompson

Conversation

@cblecker
Copy link
Copy Markdown
Member

@cblecker cblecker commented May 14, 2026

Summary

  • Phase 1 (envtest + unit tests): Add onUpdate immutability tests for Services, ControllerAvailabilityPolicy, and Capabilities fields; unit tests for toleration propagation, PayloadArch/ConfigurationStatus controller integration, hcpstatus Authentication propagation, and guest webhook URL allowlist validation
  • Phase 2 (framework): Extend the v2 e2e framework with RunCommandInPod/GetMetricsFromPod pod exec helpers, GetHostedClusterRESTConfig() on TestContext, and E2E_SERVICE_DOMAIN env var registration
  • Phase 2 (specs): Port 14 v1 TestCreateCluster validations to v2 Ginkgo specs across 5 new test files (health, security, compliance, metrics, DNS); promote WorkloadRegistryValidationTest from Informing to blocking

Test plan

  • make test-envtest-ocp — validates onUpdate immutability cases in Phase 1A
  • go test ./support/controlplane-component/... -run TestReconcile — Phase 1B toleration test
  • go test ./hypershift-operator/controllers/hostedcluster/... -run "TestPayloadArch|TestConfigurationStatus" — Phase 1C/1D controller tests
  • go test ./control-plane-operator/hostedclusterconfigoperator/controllers/hcpstatus/... — Phase 1D hcpstatus test
  • go test github.com/openshift/hypershift/control-plane-operator/hostedclusterconfigoperator/controllers/resources -run "TestIsAllowedWebhookUrl|TestEnsureGuestAdmissionWebhooksAreValid" — Phase 1E webhook tests
  • make e2ev2 — validates Phase 2 compiles cleanly
  • CI e2e-v2-gke job must pass with Phase 2 changes

Summary by CodeRabbit

  • Tests

    • Added unit tests for control-plane status, webhook URL validation, payload architecture and tolerations; added extensive e2e v2 suites for hosted-cluster health, compliance, DNS, metrics, and security; removed an informing label from one workload registry test.
  • Chores

    • Added optional E2E_SERVICE_DOMAIN env var; updated e2e test utilities for in-pod exec/metrics and added lazy hosted-cluster REST config access.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

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 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 May 14, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 14, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

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

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 14, 2026

@cblecker: This pull request references GCP-688 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 "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Phase 1 (envtest + unit tests): Add onUpdate immutability tests for Services, ControllerAvailabilityPolicy, and Capabilities fields; unit tests for toleration propagation, PayloadArch/ConfigurationStatus controller integration, hcpstatus Authentication propagation, and guest webhook URL allowlist validation
  • Phase 2 (framework): Extend the v2 e2e framework with RunCommandInPod/GetMetricsFromPod pod exec helpers, GetHostedClusterRESTConfig() on TestContext, and E2E_SERVICE_DOMAIN env var registration
  • Phase 2 (specs): Port 14 v1 TestCreateCluster validations to v2 Ginkgo specs across 5 new test files (health, security, compliance, metrics, DNS); promote WorkloadRegistryValidationTest from Informing to blocking

Test plan

  • make test-envtest-ocp — validates onUpdate immutability cases in Phase 1A
  • go test ./support/controlplane-component/... -run TestReconcile — Phase 1B toleration test
  • go test ./hypershift-operator/controllers/hostedcluster/... -run "TestPayloadArch|TestConfigurationStatus" — Phase 1C/1D controller tests
  • go test ./control-plane-operator/hostedclusterconfigoperator/controllers/hcpstatus/... — Phase 1D hcpstatus test
  • go test github.com/openshift/hypershift/control-plane-operator/hostedclusterconfigoperator/controllers/resources -run "TestIsAllowedWebhookUrl|TestEnsureGuestAdmissionWebhooksAreValid" — Phase 1E webhook tests
  • make e2ev2 — validates Phase 2 compiles cleanly
  • CI e2e-v2-gke job must pass with Phase 2 changes

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR adds multiple new unit and e2e-v2 tests and test utilities across the repository. Unit tests added/extended: HCP status reconciliation, webhook URL validation and guest webhook cleanup, payload architecture determination, and control-plane component toleration propagation. E2E v2 test infra changes: pod exec helpers (RunCommandInPod, GetMetricsFromPod) switched to panic-based returns, a cached hosted-cluster REST config accessor, and a new optional E2E_SERVICE_DOMAIN env var. Five new e2e-v2 test suites registered: hosted-cluster compliance, DNS, health, metrics, and security.

Suggested reviewers

  • bryan-cox
  • clebs
🚥 Pre-merge checks | ✅ 9 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning Review comments unaddressed: missing test label, vacuous empty-list assertion, weak nil check in compliance test. Weak assertion in security test. Panic-based error handling in pod_exec. Add label to route test. Assert routeList.Items not empty. Expect(hostedCluster).NotTo(BeNil()). Assert podList.Items not empty in security test. Replace panics with error returns in pod_exec.
Microshift Test Compatibility ⚠️ Warning Tests use config.openshift.io APIs unavailable on MicroShift without guards: EnsureFeatureGateStatusTest (ClusterVersion, FeatureGate) and ValidateConfigurationStatusTest (Authentication). Add [apigroup:config.openshift.io] tags to test names or add MicroShift skip checks with exutil.IsMicroShiftCluster().
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main objective of the pull request, which is to port v1 E2E validations to envtest, unit tests, and v2 Ginkgo specs, matching the substantial changes across multiple test files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All test names are stable and deterministic. No dynamic values such as pod names, timestamps, UUIDs, node names, or IP addresses are present in test titles. All names use static descriptive strings.
Single Node Openshift (Sno) Test Compatibility ✅ Passed EnsureNodeTuningOperatorMetricsEndpointTest gracefully skips when NTO service is absent. Other tests have no multi-node assumptions or use skips appropriately. SNO-compatible.
Topology-Aware Scheduling Compatibility ✅ Passed PR contains only test and e2e framework changes. No production deployment manifests or scheduling constraints are added.
Ote Binary Stdout Contract ✅ Passed The PR respects OTE Binary Stdout Contract: all stdout writes use os.Stderr; zap logs to stderr by default; test code uses GinkgoWriter; no direct stdout writes in process-level code paths.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New e2e tests contain no IPv4-only assumptions, hardcoded external connectivity, or external registries. Tests handle both IPv4 and IPv6 and work in disconnected environments.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cblecker

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2026
@cblecker cblecker marked this pull request as ready for review May 14, 2026 01:03
@openshift-ci openshift-ci Bot added area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-area labels May 14, 2026
@openshift-ci openshift-ci Bot requested review from bryan-cox and muraee May 14, 2026 01:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go`:
- Around line 6824-6830: The test currently bypasses production logic by
directly assigning hcluster.Status.Configuration = hcp.Status.Configuration;
instead invoke the controller's real reconciliation path (call the HostedCluster
reconciler's Reconcile method or the helper used by hostedcluster_controller.go
that performs the "Copy the configuration status from the hostedcontrolplane"
logic) so the same code path is exercised; remove the inline assignment, run the
reconcile/helper, then assert hcluster.Status.Configuration equals
tc.hcpConfiguration.

In `@test/e2e/v2/internal/pod_exec.go`:
- Around line 35-68: The function RunCommandInPod currently returns errors;
change it to panic on failures per framework guidelines: replace the error
return after kubernetes.NewForConfig with a panic that includes a clear
diagnostic message containing namespace and podName and the wrapped error;
likewise panic if remotecommand.NewSPDYExecutor fails with a message including
namespace/podName/containerName; and panic if exec.StreamWithContext returns an
error, including namespace/podName/containerName and stderr output in the panic
text; keep the successful return of stdout.String() as-is.
- Around line 72-80: GetMetricsFromPod currently returns an error on failure;
update it to follow the framework panic-on-failure pattern used by
RunCommandInPod: call RunCommandInPod with the same args, and if err != nil
panic with a diagnostic message including namespace/podName/containerName/port
and the error; otherwise return []byte(output). Ensure the function signature
stays the same but remove the error return path and panic on failures so the
framework behavior is consistent.

In `@test/e2e/v2/internal/test_context.go`:
- Around line 130-134: Replace the silent early return in the
tc.hostedClusterRESTConfigOnce.Do closure with a panic that includes a clear
diagnostic message; specifically, in the closure that calls
tc.GetHostedCluster() and checks hc == nil || hc.Status.KubeConfig == nil, panic
(do not assign or cache nil to tc.hostedClusterRESTConfig) with a message
describing whether the HostedCluster is missing or its kubeconfig is nil so
callers fail loudly and the sync.Once does not cache a nil result.

In `@test/e2e/v2/tests/control_plane_workloads_test.go`:
- Around line 695-696: The inline comment before the test that reads
'Label("Informing"): failures skip (non-blocking) until registry is complete' is
stale because the test starting with It("all pods should belong to predefined
workloads") is now a blocking test; update or remove that comment so it reflects
the current gating behavior—either delete the "Informing/non-blocking" note or
replace it with a brief accurate comment about this being a blocking/required
test for pod workload validation, referencing the It("all pods should belong to
predefined workloads") test to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 5d1857a4-dbd4-49da-87c1-4d11b0b3371e

📥 Commits

Reviewing files that changed from the base of the PR and between 5a61e14 and 9d54baa.

⛔ Files ignored due to path filters (3)
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.capabilities.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.services.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.validation.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
📒 Files selected for processing (13)
  • control-plane-operator/hostedclusterconfigoperator/controllers/hcpstatus/hcpstatus_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go
  • support/controlplane-component/controlplane-component_test.go
  • test/e2e/v2/internal/env_vars.go
  • test/e2e/v2/internal/pod_exec.go
  • test/e2e/v2/internal/test_context.go
  • test/e2e/v2/tests/control_plane_workloads_test.go
  • test/e2e/v2/tests/hosted_cluster_compliance_test.go
  • test/e2e/v2/tests/hosted_cluster_dns_test.go
  • test/e2e/v2/tests/hosted_cluster_health_test.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
  • test/e2e/v2/tests/hosted_cluster_security_test.go

Comment thread hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go Outdated
Comment thread test/e2e/v2/internal/pod_exec.go Outdated
Comment thread test/e2e/v2/internal/pod_exec.go Outdated
Comment thread test/e2e/v2/internal/test_context.go
Comment thread test/e2e/v2/tests/control_plane_workloads_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.09%. Comparing base (674d92a) to head (64758af).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8511      +/-   ##
==========================================
+ Coverage   40.00%   40.09%   +0.09%     
==========================================
  Files         751      751              
  Lines       92838    92838              
==========================================
+ Hits        37137    37227      +90     
+ Misses      53014    52921      -93     
- Partials     2687     2690       +3     

see 3 files with indirect coverage changes

Flag Coverage Δ
cmd-support 34.10% <ø> (+<0.01%) ⬆️
cpo-hostedcontrolplane 40.56% <ø> (ø)
cpo-other 40.86% <ø> (+0.71%) ⬆️
hypershift-operator 50.53% <ø> (ø)
other 31.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cblecker cblecker force-pushed the worktree-smooth-hatching-thompson branch from 9d54baa to 3748c05 Compare May 14, 2026 01:18
cblecker added 7 commits May 13, 2026 18:54
Add onUpdate test cases to three existing envtest suites verifying
that Services, ControllerAvailabilityPolicy, and Capabilities fields
are immutable after HostedCluster creation.

Assisted-by: Claude:claude-sonnet-4-6[1m]
…pod template

Add toleration to HCP spec in TestReconcile and assert it appears in
the pod template, exercising the defaults.go propagation path.

Assisted-by: Claude:claude-sonnet-4-6[1m]
Add unit test for the hcpStatusReconciler confirming that the guest
cluster Authentication resource is propagated to HCP.Status.Configuration.

Assisted-by: Claude:claude-sonnet-4-6[1m]
Add TestPayloadArch verifying DetermineHostedClusterPayloadArch integration
and TestConfigurationStatus verifying HCP-to-HC configuration status copy.

Assisted-by: Claude:claude-sonnet-4-6[1m]
Add TestIsAllowedWebhookUrl (4 table-driven cases) and
TestEnsureGuestAdmissionWebhooksAreValid (4 cases) covering
webhook deletion for CP service targets and preservation of allowed URLs.

Assisted-by: Claude:claude-sonnet-4-6[1m]
…e domain

Add RunCommandInPod/GetMetricsFromPod helpers in pod_exec.go,
GetHostedClusterRESTConfig() to TestContext, and E2E_SERVICE_DOMAIN
env var registration for custom DNS endpoint testing.

Assisted-by: Claude:claude-sonnet-4-6[1m]
Add hosted_cluster_health_test.go (conditions, crashing pods, CAPI
finalizers, feature gate, payload arch, config status), security_test.go
(guest webhooks, admission policies, network policies), compliance_test.go
(custom labels, tolerations, HCP router routes), metrics_test.go (HO
metrics, forwarder, NTO endpoint), and dns_test.go (custom DNS cert stub).

Promote WorkloadRegistryValidationTest from Informing to blocking.

Assisted-by: Claude:claude-sonnet-4-6[1m]
@cblecker cblecker force-pushed the worktree-smooth-hatching-thompson branch from 3748c05 to 64758af Compare May 14, 2026 01:54
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/v2/tests/hosted_cluster_compliance_test.go`:
- Line 106: The It block "When routes are created in the control plane
namespace, it should label all routes for the per-HCP router" is missing an
explicit Label; modify that It declaration to include a Label(...) argument
(e.g., Label("Compliance") or the same label used by other It blocks in this
file) so the test can be filtered consistently—update the It(...) signature to
It("When routes...", Label("..."), func() { ... }) preserving the existing
description and test body.
- Around line 123-132: The test currently allows a vacuous pass when no routes
exist; after fetching routeList with
tc.MgmtClient.List(namespace=tc.ControlPlaneNamespace), assert that
routeList.Items is non-empty (e.g.,
Expect(len(routeList.Items)).To(BeNumerically(">", 0))) before iterating, then
continue to iterate each route (route := &routeList.Items[i]) and use
netutil.AddHCPRouteLabel and the existing Expect comparing route.Labels to
original.Labels so the test fails when there are zero routes instead of passing
silently.
- Around line 108-121: The test currently proceeds when tc.GetHostedCluster()
returns nil, which hides a missing precondition; update the code after calling
tc.GetHostedCluster() to fail fast if hostedCluster is nil (e.g., call t.Fatalf
or require.NotNil on the hostedCluster) so the test stops with a clear error
instead of continuing into the Route gating logic that uses
hostedCluster.Spec.Services; keep the existing APIServer/Route check and Skip()
only for the non-nil hostedCluster branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: bf3b2881-c543-4a73-ab34-21aff8e58c03

📥 Commits

Reviewing files that changed from the base of the PR and between 3748c05 and 64758af.

⛔ Files ignored due to path filters (3)
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.capabilities.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.services.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.validation.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
📒 Files selected for processing (13)
  • control-plane-operator/hostedclusterconfigoperator/controllers/hcpstatus/hcpstatus_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go
  • support/controlplane-component/controlplane-component_test.go
  • test/e2e/v2/internal/env_vars.go
  • test/e2e/v2/internal/pod_exec.go
  • test/e2e/v2/internal/test_context.go
  • test/e2e/v2/tests/control_plane_workloads_test.go
  • test/e2e/v2/tests/hosted_cluster_compliance_test.go
  • test/e2e/v2/tests/hosted_cluster_dns_test.go
  • test/e2e/v2/tests/hosted_cluster_health_test.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
  • test/e2e/v2/tests/hosted_cluster_security_test.go
🚧 Files skipped from review as they are similar to previous changes (9)
  • control-plane-operator/hostedclusterconfigoperator/controllers/hcpstatus/hcpstatus_test.go
  • test/e2e/v2/tests/control_plane_workloads_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • support/controlplane-component/controlplane-component_test.go
  • test/e2e/v2/tests/hosted_cluster_dns_test.go
  • test/e2e/v2/internal/test_context.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
  • test/e2e/v2/tests/hosted_cluster_security_test.go
  • test/e2e/v2/tests/hosted_cluster_health_test.go

// have the per-HCP router label applied. This test is skipped when the APIServer is not
// exposed via a Route service publishing strategy.
func EnsureAllRoutesUseHCPRouterTest(getTestCtx internal.TestContextGetter) {
It("When routes are created in the control plane namespace, it should label all routes for the per-HCP router", func() {
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add an explicit label to this It block.

This test is currently unlabeled while other It blocks in the same file are labeled, which makes filtering less consistent.

Suggested change
-	It("When routes are created in the control plane namespace, it should label all routes for the per-HCP router", func() {
+	It("When routes are created in the control plane namespace, it should label all routes for the per-HCP router", Label("hosted-cluster-compliance"), func() {

As per coding guidelines, "Apply labels to Describe and It blocks for test filtering; only apply labels to Context blocks when you have explicit filtering intent (e.g., Label("Informing") for non-blocking tests)".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
It("When routes are created in the control plane namespace, it should label all routes for the per-HCP router", func() {
It("When routes are created in the control plane namespace, it should label all routes for the per-HCP router", Label("hosted-cluster-compliance"), func() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/v2/tests/hosted_cluster_compliance_test.go` at line 106, The It
block "When routes are created in the control plane namespace, it should label
all routes for the per-HCP router" is missing an explicit Label; modify that It
declaration to include a Label(...) argument (e.g., Label("Compliance") or the
same label used by other It blocks in this file) so the test can be filtered
consistently—update the It(...) signature to It("When routes...", Label("..."),
func() { ... }) preserving the existing description and test body.

Comment on lines +108 to +121
hostedCluster := tc.GetHostedCluster()

if hostedCluster != nil {
isRoute := false
for _, svc := range hostedCluster.Spec.Services {
if svc.Service == hyperv1.APIServer && svc.Type == hyperv1.Route {
isRoute = true
break
}
}
if !isRoute {
Skip("route test only applies when APIServer is exposed via Route")
}
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fail fast if hosted-cluster context is unexpectedly missing.

If tc.GetHostedCluster() returns nil, this test bypasses service-strategy gating and can produce misleading outcomes instead of a clear precondition failure.

Suggested change
 		tc := getTestCtx()
 		hostedCluster := tc.GetHostedCluster()
+		Expect(hostedCluster).NotTo(BeNil(),
+			"hosted cluster must be available for route compliance validation in namespace %s",
+			tc.ControlPlaneNamespace)
 
-		if hostedCluster != nil {
-			isRoute := false
-			for _, svc := range hostedCluster.Spec.Services {
-				if svc.Service == hyperv1.APIServer && svc.Type == hyperv1.Route {
-					isRoute = true
-					break
-				}
+		isRoute := false
+		for _, svc := range hostedCluster.Spec.Services {
+			if svc.Service == hyperv1.APIServer && svc.Type == hyperv1.Route {
+				isRoute = true
+				break
 			}
-			if !isRoute {
-				Skip("route test only applies when APIServer is exposed via Route")
-			}
+		}
+		if !isRoute {
+			Skip("route test only applies when APIServer is exposed via Route")
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/v2/tests/hosted_cluster_compliance_test.go` around lines 108 - 121,
The test currently proceeds when tc.GetHostedCluster() returns nil, which hides
a missing precondition; update the code after calling tc.GetHostedCluster() to
fail fast if hostedCluster is nil (e.g., call t.Fatalf or require.NotNil on the
hostedCluster) so the test stops with a clear error instead of continuing into
the Route gating logic that uses hostedCluster.Spec.Services; keep the existing
APIServer/Route check and Skip() only for the non-nil hostedCluster branch.

Comment on lines +123 to +132
routeList := &routev1.RouteList{}
Expect(tc.MgmtClient.List(tc.Context, routeList, crclient.InNamespace(tc.ControlPlaneNamespace))).To(Succeed())

for i := range routeList.Items {
route := &routeList.Items[i]
original := route.DeepCopy()
netutil.AddHCPRouteLabel(route)
Expect(route.Labels).To(Equal(original.Labels),
"route %s is missing the label to use the per-HCP router", route.Name)
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard against vacuous pass when no routes are present.

The per-route label assertion passes trivially on an empty list, which can hide regressions in route creation/visibility for this namespace.

Suggested change
 		routeList := &routev1.RouteList{}
 		Expect(tc.MgmtClient.List(tc.Context, routeList, crclient.InNamespace(tc.ControlPlaneNamespace))).To(Succeed())
+		Expect(routeList.Items).NotTo(BeEmpty(),
+			"expected at least one route in control plane namespace %s for router-label compliance check",
+			tc.ControlPlaneNamespace)
 
 		for i := range routeList.Items {
 			route := &routeList.Items[i]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
routeList := &routev1.RouteList{}
Expect(tc.MgmtClient.List(tc.Context, routeList, crclient.InNamespace(tc.ControlPlaneNamespace))).To(Succeed())
for i := range routeList.Items {
route := &routeList.Items[i]
original := route.DeepCopy()
netutil.AddHCPRouteLabel(route)
Expect(route.Labels).To(Equal(original.Labels),
"route %s is missing the label to use the per-HCP router", route.Name)
}
routeList := &routev1.RouteList{}
Expect(tc.MgmtClient.List(tc.Context, routeList, crclient.InNamespace(tc.ControlPlaneNamespace))).To(Succeed())
Expect(routeList.Items).NotTo(BeEmpty(),
"expected at least one route in control plane namespace %s for router-label compliance check",
tc.ControlPlaneNamespace)
for i := range routeList.Items {
route := &routeList.Items[i]
original := route.DeepCopy()
netutil.AddHCPRouteLabel(route)
Expect(route.Labels).To(Equal(original.Labels),
"route %s is missing the label to use the per-HCP router", route.Name)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/v2/tests/hosted_cluster_compliance_test.go` around lines 123 - 132,
The test currently allows a vacuous pass when no routes exist; after fetching
routeList with tc.MgmtClient.List(namespace=tc.ControlPlaneNamespace), assert
that routeList.Items is non-empty (e.g.,
Expect(len(routeList.Items)).To(BeNumerically(">", 0))) before iterating, then
continue to iterate each route (route := &routeList.Items[i]) and use
netutil.AddHCPRouteLabel and the existing Expect comparing route.Labels to
original.Labels so the test fails when there are zero routes instead of passing
silently.

@cblecker
Copy link
Copy Markdown
Member Author

/test e2e-v2-gke

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

@cblecker: 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/e2e-v2-gke 64758af link true /test e2e-v2-gke

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants