Skip to content

fix flaky functional test - #4325

Merged
kubevirt-prow[bot] merged 1 commit into
kubevirt:mainfrom
nunnatsa:fix-test
Jun 21, 2026
Merged

kubevirt-prow[bot] merged 1 commit into
kubevirt:mainfrom
nunnatsa:fix-test

Conversation

@nunnatsa

@nunnatsa nunnatsa commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

The "naively read HCO in v1beta1 format" test is flaky. if the featureGates is an empty array (rather than nil), the comparison between the the fetched and the converted CRs fails, because after the conversion, the array is nil. This is not a bug in the conversion!

To fix, we makes sure the array is nil before running the test.

In addition, the "should allow set fields in HyperConverged v1beta1" will break if we'll change the specific FGs we're using there. This commit also modified this test to dynamically choose the feature gates for the test.

Jira Ticket:

None

Release note:

None

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: aa17f772-ccdd-4f83-8da7-a4463fd976b2

📥 Commits

Reviewing files that changed from the base of the PR and between 60e2061 and a6aa6a9.

📒 Files selected for processing (3)
  • pkg/featuregatedetails/feature_gates.go
  • pkg/featuregatedetails/feature_gates_test.go
  • tests/func-tests/conversion_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/featuregatedetails/feature_gates.go
  • pkg/featuregatedetails/feature_gates_test.go
  • tests/func-tests/conversion_test.go

📝 Walkthrough

Walkthrough

Two new exported functions, ListBetaFeatureGates and ListAlphaFeatureGates, are added to pkg/featuregatedetails/feature_gates.go. They rely on a new unexported filterFGByPhase iterator to filter the featureGatesDetails map by phase and return sorted name slices. A comprehensive unit test suite is added in pkg/featuregatedetails/feature_gates_test.go using Ginkgo/Gomega to verify phase detection, enumeration correctness, and nil-handling edge cases. The v1beta1→v1 conversion functional test in tests/func-tests/conversion_test.go is refactored to use these helpers: hardcoded field mutations are replaced with dynamic patch construction using reflection-based helpers, deferred cleanup via restoreFGsToDefault, and spec equality validation via cmp.Diff. The nil-check in restoreFGsToDefault is also corrected, and BeforeEach is wired to accept context.Context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix flaky functional test' is vague and does not clearly summarize the main changes. While the PR does address test flakiness, it also introduces two new exported helper functions and dynamically refactored feature gate selection. The title fails to communicate the significant API additions and architectural changes. Use a more specific title such as 'Add feature gate listing helpers and refactor functional tests' or 'Extract feature gate helpers and fix flaky v1beta1 conversion test' to accurately reflect the primary changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

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

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 13 linked repositories, but your current plan allows 0. Analyzed ``, skipped kubevirt/kubevirt, `kubevirt/containerized-data-importer`, `kubevirt/ssp-operator`, `kubevirt/cluster-network-addons-operator`, `kubevirt/hostpath-provisioner-operator`, `kubevirt/application-aware-quota`, `kubevirt/managed-tenant-quota`, `kubevirt/hyperconverged-cluster-operator`, `kubevirt/monitoring`, `kubevirt/community`, `kubevirt/enhancements`, `kubevirt/project-infra`, `kubevirt/kubevirtci`.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/func-tests/conversion_test.go (1)

73-130: ⚡ Quick win

Make the patch always flip selected gates away from defaults.

Right now values are hardcoded (beta=false, alpha=true). If a selected gate already has that default (and only one gate is available), this can pass without proving mutation/conversion behavior. Consider deriving patch values as !default.

Suggested change
-		var patchFGs []string
+		var patchFGs []string
+		expectedFGs := map[string]bool{}
+		defaultFGs := featuregates.HyperConvergedFeatureGates{}

 		if betaFG != "" {
+			newVal := !defaultFGs.IsEnabled(betaFG)
 			GinkgoLogr.Info("found a beta feature gate with a field in v1beta1 API version", "name", betaFG)
-			patchFGs = []string{fmt.Sprintf(`%q: false`, betaFG)}
+			patchFGs = append(patchFGs, fmt.Sprintf(`%q: %t`, betaFG, newVal))
+			expectedFGs[betaFG] = newVal
 		} else {
 			GinkgoLogr.Info("no beta feature gate defined in v1beta1 API version")
 		}

 		if alphaFG != "" {
+			newVal := !defaultFGs.IsEnabled(alphaFG)
 			GinkgoLogr.Info("found an alpha feature gate with a field in v1beta1 API version", "name", alphaFG)
-			patchFGs = append(patchFGs, fmt.Sprintf(`%q: true`, alphaFG))
+			patchFGs = append(patchFGs, fmt.Sprintf(`%q: %t`, alphaFG, newVal))
+			expectedFGs[alphaFG] = newVal
 		} else {
 			GinkgoLogr.Info("no alpha feature gate defined in v1beta1 API version")
 		}
@@
-		if betaFG != "" {
-			Expect(hcv1.Spec.FeatureGates.IsEnabled(betaFG)).To(BeFalseBecause("the %q beta feature gate was disabled using v1beta1 API. it is expected to be 'false' in v1, but it's not", betaFG))
+		if betaFG != "" {
+			Expect(hcv1.Spec.FeatureGates.IsEnabled(betaFG)).
+				To(Equal(expectedFGs[betaFG]), "beta gate %q did not match patched value", betaFG)
 		}

-		if alphaFG != "" {
-			Expect(hcv1.Spec.FeatureGates.IsEnabled(alphaFG)).To(BeTrueBecause("the %q alpha feature gate was enabled using v1beta1 API. it is expected to be 'true' in v1, but it's not", alphaFG))
+		if alphaFG != "" {
+			Expect(hcv1.Spec.FeatureGates.IsEnabled(alphaFG)).
+				To(Equal(expectedFGs[alphaFG]), "alpha gate %q did not match patched value", alphaFG)
 		}
🤖 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 `@tests/func-tests/conversion_test.go` around lines 73 - 130, The patch values
for the feature gates are hardcoded (betaFG set to false and alphaFG set to
true) without checking their current default values. This means if a selected
gate already defaults to that value, the test could pass without actually
testing mutation behavior. Before building the patchFGs slice where the
fmt.Sprintf calls with hardcoded false and true values are made, first retrieve
the current values of the HyperConverged object to determine the default state
of each feature gate, then invert those values when constructing the patch
strings to ensure the test always flips the gates away from their defaults.
🤖 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 `@tests/func-tests/conversion_test.go`:
- Around line 73-130: The patch values for the feature gates are hardcoded
(betaFG set to false and alphaFG set to true) without checking their current
default values. This means if a selected gate already defaults to that value,
the test could pass without actually testing mutation behavior. Before building
the patchFGs slice where the fmt.Sprintf calls with hardcoded false and true
values are made, first retrieve the current values of the HyperConverged object
to determine the default state of each feature gate, then invert those values
when constructing the patch strings to ensure the test always flips the gates
away from their defaults.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e4467e4-c4d8-4ca6-a636-4a94f269ccb6

📥 Commits

Reviewing files that changed from the base of the PR and between fe6ee60 and 71bcfd9.

📒 Files selected for processing (2)
  • pkg/featuregatedetails/feature_gates.go
  • tests/func-tests/conversion_test.go

@coveralls

coveralls commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 27905282496

Coverage increased (+0.02%) to 80.452%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (11 of 13 lines covered, 84.62%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
pkg/featuregatedetails/feature_gates.go 13 11 84.62%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13040
Covered Lines: 10491
Line Coverage: 80.45%
Coverage Strength: 2.05 hits per line

💛 - Coveralls

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@pkg/featuregatedetails/feature_gates_test.go`:
- Around line 86-87: The Context block in the test has a mislabeled name that
does not match its actual test content. Rename the Context from
"ListBetaFeatureGates" to "ListAlphaFeatureGates" to accurately reflect that the
test block validates the ListAlphaFeatureGates functionality, not
ListBetaFeatureGates. This ensures the test output is clear and prevents
confusion for future developers reusing this test structure.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 409ca564-0013-4487-b014-b01c2cf2a4fb

📥 Commits

Reviewing files that changed from the base of the PR and between 71bcfd9 and 0b1f8a3.

📒 Files selected for processing (3)
  • pkg/featuregatedetails/feature_gates.go
  • pkg/featuregatedetails/feature_gates_test.go
  • tests/func-tests/conversion_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/featuregatedetails/feature_gates.go
  • tests/func-tests/conversion_test.go

Comment thread pkg/featuregatedetails/feature_gates_test.go Outdated
@hco-bot

hco-bot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

hco-e2e-upgrade-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-sno-azure
hco-e2e-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-aws
hco-e2e-consecutive-operator-sdk-upgrades-azure lane succeeded.
/override ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-aws
hco-e2e-operator-sdk-gcp, hco-e2e-operator-sdk-azure lanes succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws
hco-e2e-upgrade-prev-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-sno-aws

@kubevirt-bot

Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-aws, ci/prow/hco-e2e-operator-sdk-aws, ci/prow/hco-e2e-operator-sdk-sno-aws, ci/prow/hco-e2e-upgrade-operator-sdk-aws, ci/prow/hco-e2e-upgrade-operator-sdk-sno-azure, ci/prow/hco-e2e-upgrade-prev-operator-sdk-sno-aws

Details

In response to this:

hco-e2e-upgrade-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-sno-azure
hco-e2e-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-aws
hco-e2e-consecutive-operator-sdk-upgrades-azure lane succeeded.
/override ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-aws
hco-e2e-operator-sdk-gcp, hco-e2e-operator-sdk-azure lanes succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws
hco-e2e-upgrade-prev-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-sno-aws

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.

@nunnatsa

Copy link
Copy Markdown
Collaborator Author

/override-bot

@hco-bot

hco-bot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws
hco-e2e-operator-sdk-gcp, hco-e2e-operator-sdk-azure lanes succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws

@kubevirt-bot

Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-operator-sdk-aws, ci/prow/hco-e2e-upgrade-operator-sdk-aws

Details

In response to this:

hco-e2e-upgrade-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-aws
hco-e2e-operator-sdk-gcp, hco-e2e-operator-sdk-azure lanes succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws

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.

@nunnatsa

Copy link
Copy Markdown
Collaborator Author

/retest

@hco-bot

hco-bot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

hco-e2e-upgrade-prev-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-aws

@kubevirt-bot

Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-upgrade-prev-operator-sdk-aws

Details

In response to this:

hco-e2e-upgrade-prev-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-aws

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.

"fg6": {Name: "fg4", Phase: featuregates.PhaseDiscontinued},
"alpha2": {Name: "alpha2", Phase: featuregates.PhaseAlpha},
"beta2": {Name: "beta2", Phase: featuregates.PhaseBeta},
"beta3": {Name: "beta2", Phase: featuregates.PhaseBeta},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"beta3": {Name: "beta2", Phase: featuregates.PhaseBeta},
"beta3": {Name: "beta3", Phase: featuregates.PhaseBeta},

The "naively read HCO in v1beta1 format" test is flaky. if the
featureGates is an empty array (rather than nil), the comparison between
the the fetched and the converted CRs fails, because after the
conversion, the array is nil. This is not a bug in the conversion!

To fix, we makes sure the array is nil before running the test.

In addition, the "should allow set fields in HyperConverged v1beta1"
will break if we'll change the specific FGs we're using there. This
commit also modified this test to dynamically choose the feature gates
for the test.

Signed-off-by: Nahshon Unna Tsameret <nunnatsa@redhat.com>
@avlitman

Copy link
Copy Markdown
Collaborator

/approve
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 21, 2026
@kubevirt-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avlitman

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 21, 2026
@openshift-ci

openshift-ci Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

@nunnatsa: 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/hco-e2e-upgrade-operator-sdk-sno-aws a6aa6a9 link false /test hco-e2e-upgrade-operator-sdk-sno-aws
ci/prow/hco-e2e-operator-sdk-aws a6aa6a9 link true /test hco-e2e-operator-sdk-aws
ci/prow/hco-e2e-operator-sdk-gcp a6aa6a9 link true /test hco-e2e-operator-sdk-gcp
ci/prow/hco-e2e-operator-sdk-sno-azure a6aa6a9 link false /test hco-e2e-operator-sdk-sno-azure

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.

@hco-bot

hco-bot commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

hco-e2e-consecutive-operator-sdk-upgrades-aws lane succeeded.
/override ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-azure
hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-upgrade-prev-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure
hco-e2e-upgrade-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-sno-aws

@kubevirt-bot

Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-azure, ci/prow/hco-e2e-operator-sdk-aws, ci/prow/hco-e2e-operator-sdk-gcp, ci/prow/hco-e2e-operator-sdk-sno-azure, ci/prow/hco-e2e-upgrade-operator-sdk-sno-aws, ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure

Details

In response to this:

hco-e2e-consecutive-operator-sdk-upgrades-aws lane succeeded.
/override ci/prow/hco-e2e-consecutive-operator-sdk-upgrades-azure
hco-e2e-operator-sdk-sno-aws lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-sno-azure
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-gcp
hco-e2e-operator-sdk-azure lane succeeded.
/override ci/prow/hco-e2e-operator-sdk-aws
hco-e2e-upgrade-prev-operator-sdk-aws lane succeeded.
/override ci/prow/hco-e2e-upgrade-prev-operator-sdk-azure
hco-e2e-upgrade-operator-sdk-sno-azure lane succeeded.
/override ci/prow/hco-e2e-upgrade-operator-sdk-sno-aws

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.

@hco-bot

hco-bot commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

@kubevirt-bot

Copy link
Copy Markdown
Contributor

@hco-bot: Overrode contexts on behalf of hco-bot: ci/prow/hco-e2e-kv-smoke-azure

Details

In response to this:

hco-e2e-kv-smoke-gcp lane succeeded.
/override ci/prow/hco-e2e-kv-smoke-azure

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.

@kubevirt-prow
kubevirt-prow Bot merged commit 405bf45 into kubevirt:main Jun 21, 2026
31 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants