Skip to content

fix: Handle same-name resources with different kinds in HCO related objects test#4037

Open
rlobillo wants to merge 1 commit intoRedHatQE:mainfrom
rlobillo:CNV-81032
Open

fix: Handle same-name resources with different kinds in HCO related objects test#4037
rlobillo wants to merge 1 commit intoRedHatQE:mainfrom
rlobillo:CNV-81032

Conversation

@rlobillo
Copy link
Contributor

@rlobillo rlobillo commented Mar 2, 2026

Short description:

The test_no_new_hco_related_objects comparison used a dict {name: kind}, which silently dropped entries when multiple resources shared the same name but had different kinds (e.g., Deployment and ServiceAccount for kubevirt-console-plugin). Switching to a set of (name, kind) tuples preserves all entries and correctly detects mismatches.

Also adds the two new ServiceAccount entries (kubevirt-console-plugin, kubevirt-apiserver-proxy) introduced by HCO PR #3953 for security hardening.

More details:

N/A

What this PR does / why we need it:

N/A

Which issue(s) this PR fixes:

N/A

Special notes for reviewer:

N/A

jira-ticket:

https://issues.redhat.com/browse/CNV-81032

Summary by CodeRabbit

  • Tests

    • Updated validation logic for related object comparisons to improve accuracy and clarity.
  • Chores

    • Updated resource mappings to properly track ServiceAccount resources for KubeVirt components.

…bjects test

The test_no_new_hco_related_objects comparison used a dict {name: kind},
which silently dropped entries when multiple resources shared the same
name but had different kinds (e.g., Deployment and ServiceAccount for
kubevirt-console-plugin). Switching to a set of (name, kind) tuples
preserves all entries and correctly detects mismatches.

Also adds the two new ServiceAccount entries (kubevirt-console-plugin,
kubevirt-apiserver-proxy) introduced by HCO PR RedHatQE#3953 for security
hardening.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rlobillo rlobillo marked this pull request as draft March 2, 2026 14:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8474300 and 01d19c0.

📒 Files selected for processing (2)
  • tests/install_upgrade_operators/strict_reconciliation/test_hco_related_objects.py
  • utilities/constants.py

📝 Walkthrough

Walkthrough

The PR refactors HCO-related object comparison logic from DeepDiff-based to set-based diffs and updates the data structure to use (name, kind) tuples as keys instead of single names. Additionally, a new SERVICEACCOUNT_STR constant is introduced and mappings in ALL_HCO_RELATED_OBJECTS are adjusted for kubevirt console plugin and API server proxy resources.

Changes

Cohort / File(s) Summary
Test Comparison Logic
tests/install_upgrade_operators/strict_reconciliation/test_hco_related_objects.py
Replaces DeepDiff comparison with explicit set-based diffs (missing_objects, new_objects). Updates data structure to use (name, kind) tuples as keys instead of single object names. Refactors assertion messaging to report missing versus new objects.
Constants and Resource Mappings
utilities/constants.py
Adds new public constant SERVICEACCOUNT_STR. Updates ALL_HCO_RELATED_OBJECTS mappings: changes KUBEVIRT_CONSOLE_PLUGIN from SERVICE_STR to SERVICEACCOUNT_STR; adds KUBEVIRT_APISERVER_PROXY mapping to SERVICEACCOUNT_STR while retaining existing DEPLOYMENT_STR entry, creating duplicate entries for the same key.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing how the test handles same-name resources with different kinds in HCO related objects.
Description check ✅ Passed The description covers all required template sections with substantive content, explaining the data structure change, new entries, and the underlying issue that motivated the fix.

✏️ 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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.60%. Comparing base (84584c3) to head (01d19c0).
⚠️ Report is 47 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4037      +/-   ##
==========================================
+ Coverage   98.56%   98.60%   +0.04%     
==========================================
  Files          25       25              
  Lines        2297     2369      +72     
==========================================
+ Hits         2264     2336      +72     
  Misses         33       33              
Flag Coverage Δ
utilities 98.60% <100.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@rlobillo rlobillo marked this pull request as ready for review March 2, 2026 14:42
@rlobillo
Copy link
Contributor Author

rlobillo commented Mar 2, 2026

/build-and-push-container

@openshift-virtualization-qe-bot-5

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: Enabled categories: branch, can-be-merged, cherry-pick, has-conflicts, hold, needs-rebase, size, verified, wip

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest verify-bugs-are-open - verify-bugs-are-open
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 2 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No WIP, hold, conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • OhadRevah
  • RoniKishner
  • albarker-rh
  • dshchedr
  • geetikakay
  • hmeir
  • rlobillo
  • rnetser
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@rlobillo
Copy link
Contributor Author

rlobillo commented Mar 2, 2026

/cherry-pick cnv-4.21

@openshift-virtualization-qe-bot

Cherry-pick requested for PR: fix: Handle same-name resources with different kinds in HCO related objects test by user rlobillo
Adding label/s cherry-pick-cnv-4.21 for automatic cheery-pick once the PR is merged

@rlobillo
Copy link
Contributor Author

rlobillo commented Mar 2, 2026

/build-and-push-container

@rlobillo
Copy link
Contributor Author

rlobillo commented Mar 2, 2026

/retest build-container

@openshift-virtualization-qe-bot

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4037 published

1 similar comment
@openshift-virtualization-qe-bot

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4037 published

@rlobillo
Copy link
Contributor Author

rlobillo commented Mar 3, 2026

/verified
openshift-virtualization-tests-runner/4600

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants