Skip to content

CNTRLPLANE-3897: Add product-cli unit tests for create nodepool - #9121

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

CNTRLPLANE-3897: Add product-cli unit tests for create nodepool#9121
mehabhalodiya wants to merge 1 commit into
openshift:mainfrom
mehabhalodiya:unittest_nodepool

Conversation

@mehabhalodiya

@mehabhalodiya mehabhalodiya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

None of the 5 platforms - Agent, AWS, Azure, KubeVirt, and OpenStack had nodepool create commands.

What this PR does / why we need it:

File Subtests What's Tested
aws/create_test.go 4 Use field, root-volume-type default (gp3), root-volume-size default (120), exact 8-flag enumeration
azure/create_test.go 4 Use field, root-disk-size default (120), disk-storage-account-type default (Premium_LRS), exact 15-flag enumeration
kubevirt/create_test.go 9 Use field, memory default (4Gi), cores default (2), root-volume-size default (32), qos-class default (Burstable), network-multiqueue default (Enable), attach-default-network default (true), developer-only flag exclusion (containerdisk), exact 13-flag enumeration
openstack/create_test.go 3 Use field, nodepool flags registered, exact 4-flag enumeration
agent/create_test.go 3 Use field, agentLabelSelector flag registered, exact 1-flag enumeration

Which issue(s) this PR fixes:

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

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 provider-specific coverage for nodepool “create” commands (Agent, AWS, Azure, KubeVirt, OpenStack).
    • Verified each command’s identity, exact CLI flag sets, provider defaults, and correct parsing for minimal/full argument sets.
    • Added end-to-end validations that parsed flags flow through validation/completion into node pool platform updates, matching expected fixtures (including Agent label-selector empty/single/multi cases).
    • For OpenStack, added negative coverage to confirm invalid inputs fail validation; for KubeVirt, confirmed developer-only options are not exposed.

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

openshift-ci-robot commented Jul 27, 2026

Copy link
Copy Markdown

@mehabhalodiya: This pull request references CNTRLPLANE-3897 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:

None of the 5 platforms - Agent, AWS, Azure, KubeVirt, and OpenStack had nodepool create commands.

What this PR does / why we need it:

File Subtests What's Tested
aws/create_test.go 4 Use field, root-volume-type default (gp3), root-volume-size default (120), exact 8-flag enumeration
azure/create_test.go 4 Use field, root-disk-size default (120), disk-storage-account-type default (Premium_LRS), exact 15-flag enumeration
kubevirt/create_test.go 9 Use field, memory default (4Gi), cores default (2), root-volume-size default (32), qos-class default (Burstable), network-multiqueue default (Enable), attach-default-network default (true), developer-only flag exclusion (containerdisk), exact 13-flag enumeration
openstack/create_test.go 3 Use field, nodepool flags registered, exact 4-flag enumeration
agent/create_test.go 3 Use field, agentLabelSelector flag registered, exact 1-flag enumeration

Which issue(s) this PR fixes:

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

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.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds unit tests for agent, AWS, Azure, KubeVirt, and OpenStack nodepool create commands. The tests verify command names, registered flags, provider-specific defaults, flag parsing, option validation and completion, nodepool platform specification updates, fixture comparisons, agent label selectors, and KubeVirt’s excluded containerdisk flag.

Suggested reviewers: jparrill

🚥 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 accurately summarizes the main change: adding product-cli unit tests for nodepool create commands.
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 strings; no timestamps, random IDs, node/namespace names, or other dynamic values were found.
Test Structure And Quality ✅ Passed These are table-driven unit tests, not Ginkgo; each subtest targets one behavior, with no cluster resources/waits, and they match repo fixture-test patterns.
Topology-Aware Scheduling Compatibility ✅ Passed Only nodepool CLI tests and fixture YAMLs changed; no runtime scheduling code, manifests, or controllers were modified.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; these are unit tests only, and they contain no IPv4-only logic or external network access.
No-Weak-Crypto ✅ Passed The PR only adds nodepool CLI tests; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons were added.
Container-Privileges ✅ Passed No modified file introduces privileged containers, host namespaces, SYS_ADMIN, or allowPrivilegeEscalation; changes are tests and nodepool fixtures only.
No-Sensitive-Data-In-Logs ✅ Passed Changed files are tests only; no fmt/log/t.Log calls or sensitive-term matches were found in code or fixtures.
✨ 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 requested review from bryan-cox and jparrill July 27, 2026 13:14
@openshift-ci openshift-ci Bot added area/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/azure PR/issue for Azure (AzurePlatform) platform area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/platform/openstack PR/issue for OpenStack (OpenStackPlatform) platform and removed do-not-merge/needs-area labels Jul 27, 2026
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.65%. Comparing base (02c0659) to head (e63d35b).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9121      +/-   ##
==========================================
+ Coverage   44.51%   44.65%   +0.13%     
==========================================
  Files         774      774              
  Lines       97003    97059      +56     
==========================================
+ Hits        43185    43340     +155     
+ Misses      50830    50720     -110     
- Partials     2988     2999      +11     

see 12 files with indirect coverage changes

Flag Coverage Δ
cmd-support 38.39% <ø> (ø)
cpo-hostedcontrolplane 47.22% <ø> (ø)
cpo-other 45.25% <ø> (ø)
hypershift-operator 54.55% <ø> (+0.08%) ⬆️
other 33.66% <ø> (+1.02%) ⬆️

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.

@redhat-chai-bot

Copy link
Copy Markdown
Contributor

Summary

This PR adds unit tests for the product-cli nodepool create commands across all 5 platforms (Agent, AWS, Azure, KubeVirt, OpenStack). The tests verify:

  • The Use field on each command (e.g. "aws", "kubevirt")
  • Provider-specific flag registration and default values (e.g. root-volume-type defaults to gp3 for AWS)
  • Exact flag enumeration per platform
  • Developer-only flag exclusion (e.g. containerdisk is not registered for KubeVirt)

Feedback

The current approach validates flag registration and defaults, but it doesn't test the actual behavior of the create commands — i.e. what the commands produce when invoked.

The existing cluster create commands in cmd/cluster/aws/ follow a different, more comprehensive testing pattern:

  1. They have testdata/ directories with golden fixture YAML files (e.g. zz_fixture_TestCreateCluster_default_creation_flags_for_cesar.yaml).
  2. The tests actually invoke the create command with specific flag combinations and compare the rendered output (the generated manifests) against these fixture files using testutil.CompareWithFixture(t, manifests).

This fixture-based approach has key advantages:

  • It tests the end-to-end behavior of the command, not just that flags are wired up.
  • It catches regressions in the generated output (e.g. if a default value propagates incorrectly into the rendered manifest).
  • It documents the expected output for reviewers in a human-readable YAML format.

Suggestion: Consider aligning these nodepool create tests with the existing cluster create test pattern — using fixture YAML files to validate the rendered output of each platform's create command, similar to what's done in cmd/cluster/aws/create_test.go.

— Summary generated from Slack discussion by Chai Bot

@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.

🧹 Nitpick comments (5)
product-cli/cmd/nodepool/agent/create_test.go (2)

57-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

These cases exercise the upstream options struct, not the product-cli command wiring.

NewAgentPlatformCreateOptions(&cobra.Command{}) plus a direct field assignment skips NewCreateCommand's flag registration, so a product-cli wiring regression (e.g. flag renamed or unbound) wouldn't fail here. Consider parsing through cmd.Flags() instead.

🤖 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/nodepool/agent/create_test.go` around lines 57 - 58, Update
the test setup around NewAgentPlatformCreateOptions to exercise the product-cli
command wiring by creating the command through NewCreateCommand and parsing the
relevant value from cmd.Flags(), rather than assigning AgentLabelSelector
directly. Preserve the existing test cases while ensuring flag registration,
naming, and binding regressions are covered.

53-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Collapse the three selector cases into a data-driven table.

These three entries differ only by the selector string; the verify func(t *testing.T) shape forces the whole body to be duplicated. A small struct field (selector string) with a shared body would keep them parameterized.

As per coding guidelines, "Use table-driven tests where possible".

♻️ Sketch
-		"When flags are parsed with empty label selector, it should generate correct nodepool": {
-			verify: func(t *testing.T) {
-				ctx := t.Context()
-				platformOpts := hypershiftagent.NewAgentPlatformCreateOptions(&cobra.Command{})
-				platformOpts.AgentLabelSelector = ""
-				...
+		// tests map[string]struct{ selector string; verify func(t *testing.T, selector string) }
+		"When flags are parsed with empty label selector, it should generate correct nodepool": {
+			selector: "",
+		},
+		"When flags are parsed with single label selector, it should generate correct nodepool": {
+			selector: "size=large",
+		},
+		"When flags are parsed with multi label selector, it should generate correct nodepool": {
+			selector: "size=large,zone notin (az1,az2)",
+		},
🤖 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/nodepool/agent/create_test.go` around lines 53 - 121,
Refactor the three selector-specific cases in the test table into a data-driven
form using a selector field, with one shared verification function that applies
the field to AgentLabelSelector and performs the existing node pool update and
fixture comparison. Preserve the empty, single, and multi-selector values as
separate table entries.

Source: Coding guidelines

product-cli/cmd/nodepool/aws/create_test.go (2)

212-214: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer ptr.To over a local strPtr helper.

k8s.io/utils/ptr is already used elsewhere in the repo (e.g. cmd/nodepool/kubevirt/create.go), and a package-level strPtr risks colliding with other helpers in this package.

♻️ Proposed change
-func strPtr(s string) *string {
-	return &s
-}

Then replace call sites:

ID: ptr.To("subnet-default"),
🤖 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/nodepool/aws/create_test.go` around lines 212 - 214, Remove
the package-level strPtr helper and use k8s.io/utils/ptr.To at every affected
call site, including the ID assignment in the node pool test. Add or reuse the
existing ptr import without introducing another local pointer helper.

66-201: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Minimal and full cases are ~90% identical.

Everything except args is duplicated between the two blocks. Extracting a helper that takes args and a fixture-relevant name would cut this in half and keep future flag additions in one place.

🤖 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/nodepool/aws/create_test.go` around lines 66 - 201, Refactor
the duplicated test setup in the minimal and full configuration cases into a
shared helper that accepts the argument list and fixture-relevant test name.
Move the common flag parsing, option validation/completion, nodepool and
hosted-cluster construction, update via UpdateNodePool, and fixture comparison
into that helper; keep each test case focused on supplying its distinct args and
name.
product-cli/cmd/nodepool/azure/create_test.go (1)

141-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

"Full configuration" cases parse only a subset of the flags each command registers. Each provider asserts an exact registered-flag set, then exercises a "full" case that skips several of those flags, so conditional branches in the spec builders never appear in any fixture. Keeping the full case in sync with the asserted flag list closes the gap.

  • product-cli/cmd/nodepool/azure/create_test.go#L141-L157: add --disk-encryption-set-id, --diagnostics-storage-account-type, and --diagnostics-storage-account-uri to cover the Diagnostics/UserManaged branch.
  • product-cli/cmd/nodepool/kubevirt/create_test.go#L156-L170: add --root-volume-cache-strategy, --vm-node-selector, and --host-device-name to cover the corresponding NodePoolPlatform branches.
  • product-cli/cmd/nodepool/openstack/create_test.go#L106-L113: add --openstack-node-additional-port so AdditionalPorts is non-empty in at least one fixture.

As per coding guidelines, "Unit test any code changes and additions."

🤖 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/nodepool/azure/create_test.go` around lines 141 - 157, Update
the full-configuration fixtures so they exercise every relevant registered flag:
in product-cli/cmd/nodepool/azure/create_test.go:141-157 add the disk encryption
set ID and both diagnostics storage account flags; in
product-cli/cmd/nodepool/kubevirt/create_test.go:156-170 add the root volume
cache strategy, VM node selector, and host device name flags; and in
product-cli/cmd/nodepool/openstack/create_test.go:106-113 add the openstack
additional port flag. Use the existing test symbols and valid values so the
Azure Diagnostics/UserManaged, KubeVirt NodePoolPlatform, and OpenStack
AdditionalPorts branches are covered, then update or add unit assertions as
needed.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@product-cli/cmd/nodepool/agent/create_test.go`:
- Around line 57-58: Update the test setup around NewAgentPlatformCreateOptions
to exercise the product-cli command wiring by creating the command through
NewCreateCommand and parsing the relevant value from cmd.Flags(), rather than
assigning AgentLabelSelector directly. Preserve the existing test cases while
ensuring flag registration, naming, and binding regressions are covered.
- Around line 53-121: Refactor the three selector-specific cases in the test
table into a data-driven form using a selector field, with one shared
verification function that applies the field to AgentLabelSelector and performs
the existing node pool update and fixture comparison. Preserve the empty,
single, and multi-selector values as separate table entries.

In `@product-cli/cmd/nodepool/aws/create_test.go`:
- Around line 212-214: Remove the package-level strPtr helper and use
k8s.io/utils/ptr.To at every affected call site, including the ID assignment in
the node pool test. Add or reuse the existing ptr import without introducing
another local pointer helper.
- Around line 66-201: Refactor the duplicated test setup in the minimal and full
configuration cases into a shared helper that accepts the argument list and
fixture-relevant test name. Move the common flag parsing, option
validation/completion, nodepool and hosted-cluster construction, update via
UpdateNodePool, and fixture comparison into that helper; keep each test case
focused on supplying its distinct args and name.

In `@product-cli/cmd/nodepool/azure/create_test.go`:
- Around line 141-157: Update the full-configuration fixtures so they exercise
every relevant registered flag: in
product-cli/cmd/nodepool/azure/create_test.go:141-157 add the disk encryption
set ID and both diagnostics storage account flags; in
product-cli/cmd/nodepool/kubevirt/create_test.go:156-170 add the root volume
cache strategy, VM node selector, and host device name flags; and in
product-cli/cmd/nodepool/openstack/create_test.go:106-113 add the openstack
additional port flag. Use the existing test symbols and valid values so the
Azure Diagnostics/UserManaged, KubeVirt NodePoolPlatform, and OpenStack
AdditionalPorts branches are covered, then update or add unit assertions as
needed.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 66434799-aae6-4614-afbd-dc5fec827f2f

📥 Commits

Reviewing files that changed from the base of the PR and between f4d2fe2 and 260d2f2.

⛔ Files ignored due to path filters (11)
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_empty_label_selector__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_multi_label_selector__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_single_label_selector__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_full_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_minimal_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_full_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_minimal_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_full_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_minimal_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_full_configuration_including_availability_zone__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestNewCreateCommand_When_flags_are_parsed_with_minimal_configuration__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
📒 Files selected for processing (5)
  • product-cli/cmd/nodepool/agent/create_test.go
  • product-cli/cmd/nodepool/aws/create_test.go
  • product-cli/cmd/nodepool/azure/create_test.go
  • product-cli/cmd/nodepool/kubevirt/create_test.go
  • product-cli/cmd/nodepool/openstack/create_test.go

@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.

🧹 Nitpick comments (3)
product-cli/cmd/nodepool/aws/create_test.go (1)

140-154: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Default-subnet fallback path is never exercised.

hcluster sets a default subnet-default, but both cases pass --subnet-id explicitly, so the fallback-to-cluster-default logic in UpdateNodePool isn't covered by these fixtures. Consider adding a case that omits --subnet-id to verify the default is picked up correctly.

🤖 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/nodepool/aws/create_test.go` around lines 140 - 154, Add a
test case for UpdateNodePool that omits the --subnet-id argument while using the
existing hcluster fixture with subnet-default, and assert the node pool uses
that cluster-default subnet. Keep the existing explicit-subnet cases unchanged.
product-cli/cmd/nodepool/openstack/create_test.go (1)

89-133: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider a negative test for the required flavor field.

Validate returns an error when Flavor is empty, but no case here exercises that path.

🤖 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/nodepool/openstack/create_test.go` around lines 89 - 133, Add
a negative test case to the table-driven tests around openstackOpts.Validate
that leaves the required Flavor option empty, and assert validation returns an
error instead of proceeding to completion or fixture comparison. Reuse the
existing test setup and identify the new case through the testCase structure.
product-cli/cmd/nodepool/agent/create_test.go (1)

68-79: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test-case names don't follow the repo's "When ... it should ..." convention. In each file, TestNewCreateCommand correctly uses "When ... it should ..." case names, but the sibling TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool table uses plain descriptive names instead, the same root cause repeated across all four providers.

  • product-cli/cmd/nodepool/agent/create_test.go#L68-L79: rename "empty label selector" / "single label selector" / "multi label selector" to "When ... it should ..." form.
  • product-cli/cmd/nodepool/aws/create_test.go#L82-L101: rename "minimal configuration" / "full configuration" to "When ... it should ..." form.
  • product-cli/cmd/nodepool/azure/create_test.go#L103-L133: rename "minimal configuration" / "full configuration" to "When ... it should ..." form.
  • product-cli/cmd/nodepool/openstack/create_test.go#L72-L87: rename "minimal configuration" / "full configuration with availability zone" to "When ... it should ..." form.

As per coding guidelines: "Always use "When ... it should ..." format for describing test cases when creating unit tests".

🤖 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/nodepool/agent/create_test.go` around lines 68 - 79, Rename
the table-driven test cases in
TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool to
follow the “When ... it should ...” convention: update the three selector cases
in product-cli/cmd/nodepool/agent/create_test.go (lines 68-79), the minimal and
full configuration cases in product-cli/cmd/nodepool/aws/create_test.go (lines
82-101), the corresponding cases in
product-cli/cmd/nodepool/azure/create_test.go (lines 103-133), and the minimal
and availability-zone cases in product-cli/cmd/nodepool/openstack/create_test.go
(lines 72-87); change names only and preserve test behavior.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@product-cli/cmd/nodepool/agent/create_test.go`:
- Around line 68-79: Rename the table-driven test cases in
TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool to
follow the “When ... it should ...” convention: update the three selector cases
in product-cli/cmd/nodepool/agent/create_test.go (lines 68-79), the minimal and
full configuration cases in product-cli/cmd/nodepool/aws/create_test.go (lines
82-101), the corresponding cases in
product-cli/cmd/nodepool/azure/create_test.go (lines 103-133), and the minimal
and availability-zone cases in product-cli/cmd/nodepool/openstack/create_test.go
(lines 72-87); change names only and preserve test behavior.

In `@product-cli/cmd/nodepool/aws/create_test.go`:
- Around line 140-154: Add a test case for UpdateNodePool that omits the
--subnet-id argument while using the existing hcluster fixture with
subnet-default, and assert the node pool uses that cluster-default subnet. Keep
the existing explicit-subnet cases unchanged.

In `@product-cli/cmd/nodepool/openstack/create_test.go`:
- Around line 89-133: Add a negative test case to the table-driven tests around
openstackOpts.Validate that leaves the required Flavor option empty, and assert
validation returns an error instead of proceeding to completion or fixture
comparison. Reuse the existing test setup and identify the new case through the
testCase structure.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 4809255c-76e2-4a87-a0fd-f72a9ca36b71

📥 Commits

Reviewing files that changed from the base of the PR and between 260d2f2 and 185db27.

⛔ Files ignored due to path filters (11)
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_empty_label_selector.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_multi_label_selector.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_single_label_selector.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_full_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_minimal_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_full_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_minimal_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_full_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_minimal_configuration.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_full_configuration_with_availability_zone.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestCreateNodePool_When_flags_are_parsed_it_should_generate_correct_nodepool_minimal_configuration.yaml is excluded by !**/testdata/**
📒 Files selected for processing (5)
  • product-cli/cmd/nodepool/agent/create_test.go
  • product-cli/cmd/nodepool/aws/create_test.go
  • product-cli/cmd/nodepool/azure/create_test.go
  • product-cli/cmd/nodepool/kubevirt/create_test.go
  • product-cli/cmd/nodepool/openstack/create_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • product-cli/cmd/nodepool/kubevirt/create_test.go

@bryan-cox bryan-cox left a comment

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.

Good coverage — all 5 platforms are present with Use field, flag registration, and flag default assertions matching the Jira acceptance criteria.

The fixture-driven UpdateNodePool pipeline tests go beyond the spec's scope (beneficial scope creep — they verify flags actually flow to the NodePool struct), but the ~30-line scaffold is nearly identical across all 5 files. If these tests are kept, consider extracting a shared test helper parameterized by platform to reduce the duplication.

Comment thread product-cli/cmd/nodepool/kubevirt/create_test.go Outdated
Comment thread product-cli/cmd/nodepool/agent/create_test.go Outdated
Comment thread product-cli/cmd/nodepool/azure/create_test.go Outdated

@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

🤖 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/nodepool/openstack/create_test.go`:
- Around line 128-141: Update the test setup around UpdateNodePool to leave
nodePool.Spec.Platform.Type unset, then explicitly assert after the update that
it equals hyperv1.OpenStackPlatform. Keep the existing fixture comparison for
the OpenStack platform fields.
🪄 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: 0ff4db90-14df-46d9-990a-c3a116d9e699

📥 Commits

Reviewing files that changed from the base of the PR and between 877b017 and 9a0b20f.

⛔ Files ignored due to path filters (12)
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestUpdateNodePool_When_empty_label_selector_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestUpdateNodePool_When_multi_label_selector_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/agent/testdata/zz_fixture_TestUpdateNodePool_When_single_label_selector_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestUpdateNodePool_When_full_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestUpdateNodePool_When_minimal_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/aws/testdata/zz_fixture_TestUpdateNodePool_When_subnet_id_is_omitted__it_should_use_the_hosted_cluster_default_subnet.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestUpdateNodePool_When_full_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/azure/testdata/zz_fixture_TestUpdateNodePool_When_minimal_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestUpdateNodePool_When_full_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/kubevirt/testdata/zz_fixture_TestUpdateNodePool_When_minimal_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestUpdateNodePool_When_full_configuration_with_availability_zone_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
  • product-cli/cmd/nodepool/openstack/testdata/zz_fixture_TestUpdateNodePool_When_minimal_configuration_is_provided__it_should_generate_correct_nodepool.yaml is excluded by !**/testdata/**
📒 Files selected for processing (5)
  • product-cli/cmd/nodepool/agent/create_test.go
  • product-cli/cmd/nodepool/aws/create_test.go
  • product-cli/cmd/nodepool/azure/create_test.go
  • product-cli/cmd/nodepool/kubevirt/create_test.go
  • product-cli/cmd/nodepool/openstack/create_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • product-cli/cmd/nodepool/agent/create_test.go
  • product-cli/cmd/nodepool/aws/create_test.go
  • product-cli/cmd/nodepool/azure/create_test.go
  • product-cli/cmd/nodepool/kubevirt/create_test.go

Comment thread product-cli/cmd/nodepool/openstack/create_test.go
None of the 5 platform - Agent, AWS, Azure, KubeVirt and
OpenStack had nodepool create commands.

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

openshift-ci Bot commented Jul 28, 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.

@bryan-cox bryan-cox left a comment

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.

/approve

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, mehabhalodiya

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 Jul 28, 2026
@mehabhalodiya

Copy link
Copy Markdown
Contributor Author

/verified by unit tests

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 28, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@mehabhalodiya: This PR has been marked as verified by unit tests.

Details

In response to this:

/verified by 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 jparrill 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.

Dropped some comments. Thanks!

},
}

if err := platformOpts.UpdateNodePool(ctx, nodePool, nil, nil); err != nil {

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.

nit: Agent and AWS use the raw string "amd64" while Azure, KubeVirt and OpenStack use string(hyperv1.ArchitectureAMD64). Could you align these to use the typed constant for consistency? If the constant value ever changes, the literal would silently test the wrong arch.

Spec: hyperv1.NodePoolSpec{
Arch: "amd64",
Platform: hyperv1.NodePoolPlatform{
Type: hyperv1.AgentPlatform,

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.

I notice the Agent TestUpdateNodePool constructs options differently from the other 4 platforms — it creates a throwaway &cobra.Command{} and manually copies the flag value, while the others use DefaultOptions() → BindFlags() → Parse() → Validate() → Complete(). Is this because the Agent platform doesn't expose that pipeline yet? If so, could you add a brief comment explaining the difference? As-is, if a new flag is added to the Agent platform, the manual copy step could be silently missed.

Arch: string(hyperv1.ArchitectureAMD64),
}
openstackOpts := openstacknodepool.DefaultOptions()
openstacknodepool.BindOptions(openstackOpts, flags)

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.

Minor: all other platforms pre-set Platform.Type on the nodePool struct, but OpenStack omits it and then asserts it after UpdateNodePool. Is this intentional because OpenStack's UpdateNodePool sets the type itself? If so, a quick comment would help future readers understand the difference isn't a copy-paste oversight.

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/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/azure PR/issue for Azure (AzurePlatform) 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. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants