Skip to content

fix(ho): make e2e HostedCluster interactions platform-aware#7724

Open
devguyio wants to merge 2 commits intoopenshift:mainfrom
devguyio:e2e-hardcoded-aws-platform
Open

fix(ho): make e2e HostedCluster interactions platform-aware#7724
devguyio wants to merge 2 commits intoopenshift:mainfrom
devguyio:e2e-hardcoded-aws-platform

Conversation

@devguyio
Copy link
Contributor

@devguyio devguyio commented Feb 13, 2026

What this PR does / why we need it:

Removes hardcoded AWS platform assumptions from e2e tests so they can run correctly on non-AWS platforms (GCP, Azure, etc.).

  • Add a platformType field to each test case group in TestOnCreateAPIUX so platform intent is explicit. GCP and Azure groups declare their platform; platform-agnostic groups fall back to globalOpts.Platform.
  • Remove redundant Platform.Type assignments from individual mutateInput functions.
  • The GCP skip condition now checks tc.platformType instead of hostedCluster.Spec.Platform.Type, preventing platform-agnostic tests from being incorrectly skipped on GCP environments.
  • Add numExpectedNodes helper that computes node count based on platform instead of always multiplying by AWSPlatform.Zones.
  • Add nil guard for Platform.AWS in the metrics collector to prevent nil pointer dereference on non-AWS hosted clusters.
  • Fix pre-existing nil-pointer warning in sts_test.go.

Why:

When running e2e tests on non-AWS environments (e.g. e2e-aks), the test framework was creating HostedCluster objects with platform.type: AWS hardcoded in the YAML template. The HO would then receive these HostedClusters with an AWS platform type but no Platform.AWS spec populated. This triggered unexpected code paths in the metrics collector, which assumed Platform.AWS was non-nil whenever Platform.Type == AWS, causing a nil pointer dereference. Additionally, the test harness unconditionally multiplied node counts by AWSPlatform.Zones and checked AWSPlatform.EndpointAccess regardless of the actual platform, leading to incorrect node expectations and wrong cluster validation paths on non-AWS runs.

Which issue(s) this PR fixes:

Fixes

Special notes for your reviewer:

The hostedcluster-base.yaml asset still has type: AWS — this is intentional since our loop always overrides it, and changing the asset would affect test/e2e/v2/tests/api_ux_validation_test.go which is out of scope.## Checklist:

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

Summary by CodeRabbit

Release Notes

  • Tests
    • Improved test assertions for credential parsing validation.
    • Enhanced platform-specific test case handling for cluster creation scenarios.
    • Added helper utilities for consistent node count calculations across different cloud platforms.
    • Refined test setup to ensure accurate platform-specific configuration validation.

@openshift-ci-robot
Copy link

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 Feb 13, 2026
@openshift-ci-robot
Copy link

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

Details

In response to this:

What this PR does / why we need it:

Removes hardcoded AWS platform assumptions from e2e tests so they can run correctly on non-AWS platforms (GCP, Azure, etc.).

  • Add a platformType field to each test case group in TestOnCreateAPIUX so platform intent is explicit. GCP and Azure groups declare their platform; platform-agnostic groups fall back to globalOpts.Platform.
  • Remove redundant Platform.Type assignments from individual mutateInput functions.
  • The GCP skip condition now checks tc.platformType instead of hostedCluster.Spec.Platform.Type, preventing platform-agnostic tests from being incorrectly skipped on GCP environments.
  • Add numExpectedNodes helper that computes node count based on platform instead of always multiplying by AWSPlatform.Zones.
  • Add nil guard for Platform.AWS in the metrics collector to prevent nil pointer dereference on non-AWS hosted clusters.
  • Fix pre-existing nil-pointer warning in sts_test.go.

Why:

When running e2e tests on non-AWS environments (e.g. e2e-aks), the test framework was creating HostedCluster objects with platform.type: AWS hardcoded in the YAML template. The HO would then receive these HostedClusters with an AWS platform type but no Platform.AWS spec populated. This triggered unexpected code paths in the metrics collector, which assumed Platform.AWS was non-nil whenever Platform.Type == AWS, causing a nil pointer dereference. Additionally, the test harness unconditionally multiplied node counts by AWSPlatform.Zones and checked AWSPlatform.EndpointAccess regardless of the actual platform, leading to incorrect node expectations and wrong cluster validation paths on non-AWS runs.

Which issue(s) this PR fixes:

Fixes

Special notes for your reviewer:

The hostedcluster-base.yaml asset still has type: AWS — this is intentional since our loop always overrides it, and changing the asset would affect test/e2e/v2/tests/api_ux_validation_test.go which is out of scope.## 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 Feb 13, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 13, 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Walkthrough

The changes introduce platform-specific test configuration handling in e2e tests by adding a per-test-case platformType field to override global platform selection, while centralizing node count calculations through a new helper function that considers platform and zone configurations.

Changes

Cohort / File(s) Summary
Test Assertion Simplification
cmd/infra/aws/util/sts_test.go
Combined separate error and nil checks into a single unified assertion in TestParseSTSCredentialsFileV2_RealWorldFormat.
Platform-Specific Test Configuration
test/e2e/create_cluster_test.go
Introduced per-test-case platformType field to override global platform selection. Adjusted test execution flow to set HostedCluster platform from per-case field with fallback to global options. Modified GCP-specific test skipping logic and refined zone availability check to apply only for AWSPlatform.
Node Count Calculation Helper
test/e2e/util/hypershift_framework.go
Added new helper function numExpectedNodes() to centralize node count calculation based on platform and zone configuration. Replaced direct calculations and simplified private/public cluster determination logic in framework setup.
Helper Function Adoption
test/e2e/util/util.go
Updated ValidatePublicCluster and ValidatePrivateCluster to use the new numExpectedNodes() helper function instead of direct node count calculations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: making e2e HostedCluster interactions platform-aware instead of AWS-specific.
Stable And Deterministic Test Names ✅ Passed PR changes test assertions and helper functions without modifying test names to include dynamic information like timestamps, UUIDs, or runtime-generated values.
Test Structure And Quality ✅ Passed Test code changes demonstrate strong adherence to quality requirements with proper single responsibility, setup/cleanup patterns, timeout handling, meaningful assertions, and consistency with existing patterns.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot added area/cli Indicates the PR includes changes for CLI area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Feb 13, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: devguyio

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 Feb 13, 2026
@devguyio devguyio changed the title NO-JIRA: fix(ho): make e2e HostedCluster interactions platform-aware fix(ho): make e2e HostedCluster interactions platform-aware Feb 13, 2026
@devguyio devguyio force-pushed the e2e-hardcoded-aws-platform branch from 7264156 to 4c3c5d3 Compare February 13, 2026 16:24
@devguyio
Copy link
Contributor Author

/test e2e-aks

@devguyio devguyio force-pushed the e2e-hardcoded-aws-platform branch from 4c3c5d3 to e68bdff Compare February 18, 2026 14:20
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":401,"request":{"method":"PATCH","url":"https://api.github.com/repos/openshift/hypershift/issues/comments/3898047652","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- This is an auto-generated comment: skip review by coderabbit.ai -->\n\n> [!IMPORTANT]\n> ## Review skipped\n> \n> Auto reviews are limited based on label configuration.\n> \n> <details>\n> <summary>:no_entry_sign: Excluded labels (none allowed) (1)</summary>\n> \n> * do-not-merge/work-in-progress\n> \n> </details>\n> \n> 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.\n> \n> You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file.\n> \n> Use the checkbox below for a quick retry:\n> - [ ] <!-- {\"checkboxId\": \"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe\"} --> 🔍 Trigger review\n\n<!-- end of auto-generated comment: skip review by coderabbit.ai -->\n\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"07f1e7d6-8a8e-4e23-9900-8731c2c87f58\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Post copyable unit tests in a comment\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n\n<!-- announcements_start -->\n\n> [!TIP]\n> [Issue Planner](https://www.coderabbit.ai/issue-planner) is now in beta. Read the [docs](https://docs.coderabbit.ai/issues/planning) and try it out! Share your feedback on [Discord](https://discord.com/invite/coderabbit).\n\n<!-- announcements_end -->\n\n<!-- tips_start -->\n\n---\n\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":1}},"response":{"url":"https://api.github.com/repos/openshift/hypershift/issues/comments/3898047652","status":401,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Wed, 18 Feb 2026 14:20:14 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"4066:3D5034:58EA048:1867BA44:6995CA9E","x-xss-protection":"0"},"data":{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}}}

devguyio and others added 2 commits February 27, 2026 10:20
Add a platformType field to each test case group so platform intent
is explicit rather than overriding all cases with globalOpts.Platform.
GCP and Azure groups set their platformType; platform-agnostic groups
fall back to globalOpts.Platform. Remove redundant Platform.Type
assignments from individual mutateInput functions. Add a nil guard
for Platform.AWS in the metrics collector to prevent nil dereference
on non-AWS environments.

Generated-with: Claude Code
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Add numExpectedNodes helper that computes node count based on platform
instead of always multiplying by AWSPlatform.Zones. Guard EndpointAccess
routing and multi-zone zone override with AWS platform checks. Fix
pre-existing staticcheck nil-pointer warning in sts_test.go.

Generated with Claude Code (Opus 4.6)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
@devguyio devguyio force-pushed the e2e-hardcoded-aws-platform branch from e68bdff to af0e870 Compare February 27, 2026 09:24
Copy link
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.

🧹 Nitpick comments (1)
test/e2e/create_cluster_test.go (1)

322-366: Redundant Platform.Type assignments in mutateInput functions.

These GCP test groups correctly set platformType: hyperv1.GCPPlatform at the test case level. However, the individual mutateInput functions (e.g., lines 334, 344, 354, 375, etc.) still explicitly set hc.Spec.Platform.Type = hyperv1.GCPPlatform.

Since the test loop at lines 1638-1642 already sets hostedCluster.Spec.Platform.Type from tc.platformType before calling mutateInput, these assignments are redundant. Consider removing them to align with the PR's stated goal of removing redundant Platform.Type assignments from mutateInput functions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/create_cluster_test.go` around lines 322 - 366, Remove redundant
assignments to hc.Spec.Platform.Type inside the various mutateInput closures
(e.g., the functions in the GCP validation test cases) because the test harness
already sets hostedCluster.Spec.Platform.Type from tc.platformType before
invoking mutateInput; locate the mutateInput lambdas that set
hc.Spec.Platform.Type = hyperv1.GCPPlatform (in the GCP test group) and delete
those lines so the closures only mutate the platform-specific fields (like
hc.Spec.Platform.GCP) without reassigning Platform.Type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/e2e/create_cluster_test.go`:
- Around line 322-366: Remove redundant assignments to hc.Spec.Platform.Type
inside the various mutateInput closures (e.g., the functions in the GCP
validation test cases) because the test harness already sets
hostedCluster.Spec.Platform.Type from tc.platformType before invoking
mutateInput; locate the mutateInput lambdas that set hc.Spec.Platform.Type =
hyperv1.GCPPlatform (in the GCP test group) and delete those lines so the
closures only mutate the platform-specific fields (like hc.Spec.Platform.GCP)
without reassigning Platform.Type.

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f8ef696 and af0e870.

📒 Files selected for processing (4)
  • cmd/infra/aws/util/sts_test.go
  • test/e2e/create_cluster_test.go
  • test/e2e/util/hypershift_framework.go
  • test/e2e/util/util.go

@devguyio
Copy link
Contributor Author

/auto-cc

@openshift-ci openshift-ci bot requested review from enxebre and muraee February 27, 2026 09:58
@muraee
Copy link
Contributor

muraee commented Feb 27, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2026
@openshift-ci-robot
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aks-4-21
/test e2e-aws-4-21
/test e2e-aks
/test e2e-aws
/test e2e-aws-upgrade-hypershift-operator
/test e2e-kubevirt-aws-ovn-reduced
/test e2e-v2-aws

@devguyio devguyio marked this pull request as ready for review February 27, 2026 10:26
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 27, 2026
@openshift-ci openshift-ci bot requested a review from bryan-cox February 27, 2026 10:28
@bryan-cox
Copy link
Member

/verified by e2e

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Feb 27, 2026
@openshift-ci-robot
Copy link

@bryan-cox: This PR has been marked as verified by e2e.

Details

In response to this:

/verified by e2e

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

openshift-ci bot commented Feb 27, 2026

@devguyio: The following tests 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-aks-4-21 af0e870 link true /test e2e-aks-4-21
ci/prow/e2e-aws-4-21 af0e870 link true /test e2e-aws-4-21
ci/prow/e2e-aks af0e870 link true /test e2e-aks

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/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform 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. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants