Skip to content

CNTRLPLANE-3890: Add product-cli unit tests for HCP create cluster#9107

Open
mehabhalodiya wants to merge 1 commit into
openshift:mainfrom
mehabhalodiya:unittest_create
Open

CNTRLPLANE-3890: Add product-cli unit tests for HCP create cluster#9107
mehabhalodiya wants to merge 1 commit into
openshift:mainfrom
mehabhalodiya:unittest_create

Conversation

@mehabhalodiya

@mehabhalodiya mehabhalodiya commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The four platforms — AWS, KubeVirt, OpenStack, and Agent — have no product-cli cluster creation tests at all.

What this PR does / why we need it:

File Subtests What's Tested
aws/create_test.go 10 Use field, release stream, region/volume/endpoint defaults, product credential flags, developer-only flag exclusion, pull-secret required, exact 25-flag enumeration
kubevirt/create_test.go 5 Use field, infra-kubeconfig-file, nodepool flags, developer-only flag exclusion, exact 17-flag enumeration
openstack/create_test.go 5 Use field, credential flags, cloud config flags, nodepool flags, exact 10-flag enumeration
agent/create_test.go 4 Use field, agent-namespace required, pull-secret required (with parent command), exact 3-flag enumeration

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/CNTRLPLANE-3890

Special notes for your reviewer:

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

  • Tests
    • Added unit test coverage for cluster creation commands across agent, AWS, KubeVirt, and OpenStack.
    • Verified command identity and key flag defaults (including release stream–related behavior).
    • Confirmed inheritance/required behavior for shared options such as pull-secret, and validated required flag annotations.
    • Ensured developer-only flags are excluded and that each environment exposes only the expected set of user-facing configuration flags.

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

openshift-ci-robot commented Jul 24, 2026

Copy link
Copy Markdown

@mehabhalodiya: This pull request references CNTRLPLANE-3890 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 task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

The four platforms — AWS, KubeVirt, OpenStack, and Agent — have no product-cli cluster creation tests at all.

What this PR does / why we need it:

File Subtests What's Tested
aws/create_test.go 10 Use field, release stream, region/volume/endpoint defaults, product credential flags, developer-only flag exclusion, pull-secret required, exact 25-flag enumeration
kubevirt/create_test.go 5 Use field, infra-kubeconfig-file, nodepool flags, developer-only flag exclusion, exact 17-flag enumeration
openstack/create_test.go 5 Use field, credential flags, cloud config flags, nodepool flags, exact 10-flag enumeration
agent/create_test.go 4 Use field, agent-namespace required, pull-secret required (with parent command), exact 3-flag enumeration

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/CNTRLPLANE-3890

Special notes for your reviewer:

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-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 do-not-merge/needs-area area/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform labels Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 3a111dc2-e655-40b7-9587-d223bd8be811

📥 Commits

Reviewing files that changed from the base of the PR and between 1b8806c and de0d041.

📒 Files selected for processing (4)
  • product-cli/cmd/cluster/agent/create_test.go
  • product-cli/cmd/cluster/aws/create_test.go
  • product-cli/cmd/cluster/kubevirt/create_test.go
  • product-cli/cmd/cluster/openstack/create_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • product-cli/cmd/cluster/kubevirt/create_test.go
  • product-cli/cmd/cluster/openstack/create_test.go

📝 Walkthrough

Walkthrough

Adds parallelized Go tests for the agent, AWS, KubeVirt, and OpenStack cluster create commands. The tests verify command names, expected flag registration, default values, required-flag annotations, developer-only flag exclusions, and exact flag sets. AWS coverage also validates release stream defaults and credential flags.

Suggested reviewers: cblecker, nirshal

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding product-cli unit tests for HCP cluster creation.
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 added test titles are static t.Run strings; no dynamic values, timestamps, UUIDs, or generated names appear.
Test Structure And Quality ✅ Passed These are isolated unit tests with no cluster resources or waits, and their table-driven Gomega style matches nearby cmd tests.
Topology-Aware Scheduling Compatibility ✅ Passed Only test files changed; no deployment manifests, controllers, or scheduling logic were modified.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed These are standard Cobra unit tests, not Ginkgo e2e specs; they only inspect flags and use no hardcoded IPs or external connectivity.
No-Weak-Crypto ✅ Passed Only new tests were added; they contain no crypto primitives, weak ciphers, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed PR only adds Go tests; no changed file contains privileged pod/container settings or related manifest fields.
No-Sensitive-Data-In-Logs ✅ Passed New files are unit tests only; no loggers/Printf calls or logging of secrets/PII were added in the diff.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot added area/platform/openstack PR/issue for OpenStack (OpenStackPlatform) platform and removed do-not-merge/needs-area labels Jul 24, 2026
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mehabhalodiya
Once this PR has been reviewed and has the lgtm label, please assign devguyio, mandre, orenc1 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 requested review from Nirshal and cblecker July 24, 2026 17:38
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.56%. Comparing base (144cca9) to head (de0d041).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9107      +/-   ##
==========================================
+ Coverage   44.51%   44.56%   +0.04%     
==========================================
  Files         774      774              
  Lines       96997    96997              
==========================================
+ Hits        43179    43225      +46     
+ Misses      50830    50780      -50     
- Partials     2988     2992       +4     

see 4 files with indirect coverage changes

Flag Coverage Δ
cmd-support 38.39% <ø> (ø)
cpo-hostedcontrolplane 47.22% <ø> (ø)
cpo-other 45.25% <ø> (ø)
hypershift-operator 54.45% <ø> (ø)
other 33.10% <ø> (+0.46%) ⬆️

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
product-cli/cmd/cluster/openstack/create_test.go (1)

17-93: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding a developer-only flag exclusion subtest for consistency.

Agent, AWS, and KubeVirt sibling test files each assert specific developer-only flags are absent; this file doesn't. Optional for consistency across the cohort, not blocking.

🤖 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 `@product-cli/cmd/cluster/openstack/create_test.go` around lines 17 - 93,
Optionally add a developer-only flag exclusion subtest alongside the existing
NewCreateCommand flag tests, asserting the relevant developer-only flags are
absent for the OpenStack create command. Follow the corresponding exclusion
assertions in the Agent, AWS, and KubeVirt sibling tests while keeping the
existing expected-flags coverage unchanged.
🤖 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 `@product-cli/cmd/cluster/agent/create_test.go`:
- Around line 44-62: The required-flag tests are vacuous because they mark
pull-secret on a synthetic parent instead of verifying command wiring. In
product-cli/cmd/cluster/agent/create_test.go lines 44-62 and
product-cli/cmd/cluster/aws/create_test.go lines 99-117, add each command to the
actual cluster parent setup, remove the test’s manual MarkPersistentFlagRequired
call, and assert the inherited pull-secret flag on the resulting command tree.

---

Nitpick comments:
In `@product-cli/cmd/cluster/openstack/create_test.go`:
- Around line 17-93: Optionally add a developer-only flag exclusion subtest
alongside the existing NewCreateCommand flag tests, asserting the relevant
developer-only flags are absent for the OpenStack create command. Follow the
corresponding exclusion assertions in the Agent, AWS, and KubeVirt sibling tests
while keeping the existing expected-flags coverage unchanged.
🪄 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: 090e068f-c65a-4316-a888-5edb8e0ee03f

📥 Commits

Reviewing files that changed from the base of the PR and between 144cca9 and c494b6b.

📒 Files selected for processing (4)
  • product-cli/cmd/cluster/agent/create_test.go
  • product-cli/cmd/cluster/aws/create_test.go
  • product-cli/cmd/cluster/kubevirt/create_test.go
  • product-cli/cmd/cluster/openstack/create_test.go

Comment thread product-cli/cmd/cluster/agent/create_test.go
The four platforms — AWS, KubeVirt, OpenStack, and
Agent — have no product-cli cluster creation tests
at all.

Signed-off-by: mehabhalodiya <mehabhalodiya@gmail.com>
@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@mehabhalodiya: all tests passed!

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

area/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/platform/openstack PR/issue for OpenStack (OpenStackPlatform) platform 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