Skip to content

Remove duplicated T2 must-gather tests covered by T1 upstream#4013

Open
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:remove-duplicate-must-gather-tests
Open

Remove duplicated T2 must-gather tests covered by T1 upstream#4013
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:remove-duplicate-must-gather-tests

Conversation

@OhadRevah
Copy link
Contributor

@OhadRevah OhadRevah commented Mar 1, 2026

Short description:

Remove T2 tests that duplicate validation already performed by T1 tests in the upstream kubevirt/must-gather repo and duplicate tests.

T1 cluster-scoped-resources validation (lines 101-161) checks that each expected resource directory exists, opens the YAML file, fetches the same resource from the cluster, and does reflect.DeepEqual on the full spec. Our T2 tests only compared selected fields (uid/name or uid/name/spec), so T1 is strictly stricter.

T1 VM validation (lines 263-282) iterates VMs per namespace, builds the path at kubevirt.io/virtualmachines/{type}/{name}.yaml, then calls validateVmFile (lines 389-406) which does reflect.DeepEqual on the full spec. Our T2 test only compared uid/name/spec fields.

Additional changes:

  • Add pytest.mark.dependency between test_no_new_cnv_crds (CNV-8508) and test_crd_resources (CNV-2724), since an outdated CRD list means test_crd_resources validates an incomplete set.
  • Clean up unused imports (CDIConfig, NetworkAddonsConfig, ImageStreamTag, VirtualMachine).

assisted by: claude code claude-opus-4-6

More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:

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

Summary by CodeRabbit

  • Tests
    • Restructured must-gather test suite with improved test organization and dependencies for better validation ordering.
    • Consolidated image stream tag testing into a dedicated test method.
    • Removed obsolete resource validation tests for network add-ons, storage configurations, and virtual machine resources.

Remove T2 tests that duplicate validation already performed by T1 tests
in the upstream kubevirt/must-gather repo.

T1 cluster-scoped-resources validation (lines 101-161) checks that each
expected resource directory exists, opens the YAML file, fetches the
same resource from the cluster, and does reflect.DeepEqual on the full
spec. Our T2 tests only compared selected fields (uid/name or
uid/name/spec), so T1 is strictly stricter.

- CNV-3042 (NetworkAddonsConfig): T1 validates networkaddonsconfigs at
  cluster-scoped-resources/ with full spec DeepEqual.
  https://github.com/kubevirt/must-gather/blob/main/tests/validate_must_gather_test.go#L104
- CNV-3373 (CDIConfig): T1 validates cdiconfigs at
  cluster-scoped-resources/ with full spec DeepEqual.
  https://github.com/kubevirt/must-gather/blob/main/tests/validate_must_gather_test.go#L102

T1 VM validation (lines 263-282) iterates VMs per namespace, builds the
path at kubevirt.io/virtualmachines/{type}/{name}.yaml, then calls
validateVmFile (lines 389-406) which does reflect.DeepEqual on the full
spec. Our T2 test only compared uid/name/spec fields.

- CNV-3043 (VirtualMachine): T1 validates VM YAMLs with full spec
  DeepEqual via validateVmFile.
  https://github.com/kubevirt/must-gather/blob/main/tests/validate_must_gather_test.go#L263-L282
  https://github.com/kubevirt/must-gather/blob/main/tests/validate_must_gather_test.go#L389-L406

- CNV-2939 (ImageStreamTag count): Not a T1 duplicate. Consolidation
  within our test suite — CNV-9236 in test_must_gather_images.py already
  validates ImageStreamTag uid/name. The count validation from CNV-2939
  is merged into CNV-9236, so no coverage is lost.

Additional changes:
- Add pytest.mark.dependency between test_no_new_cnv_crds (CNV-8508) and
  test_crd_resources (CNV-2724), since an outdated CRD list means
  test_crd_resources validates an incomplete set.
- Clean up unused imports (CDIConfig, NetworkAddonsConfig, ImageStreamTag,
  VirtualMachine).

assisted by: claude code claude-opus-4-6
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

Restructures must-gather test suite: removes resource checks for NetworkAddonsConfig and CDIConfig; moves ImageStreamTag test to dedicated method; removes VirtualMachine test from parametrization; adds test dependency ordering for CNV CRD validation.

Changes

Cohort / File(s) Summary
Resource Check Removals
tests/install_upgrade_operators/must_gather/test_must_gather.py, tests/install_upgrade_operators/must_gather/test_must_gather_vms.py
Removed resource checks for NetworkAddonsConfig, CDIConfig, and VirtualMachine; eliminated corresponding test parametrizations and imports. Added test dependency marker for test_no_new_cnv_crds before test_crd_resources.
ImageStreamTag Test Extraction
tests/install_upgrade_operators/must_gather/test_must_gather_images.py
Converted inline parametrized ImageStreamTag test case to dedicated method test_image_stream_tag_gather that computes expected count dynamically by listing cluster resources and validates against must-gather output. Added os import for filesystem assertions.

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 accurately captures the main change: removing duplicated T2 must-gather tests that are already covered by stricter T1 upstream validations.
Description check ✅ Passed The description is comprehensive and well-structured. It clearly explains what T1 validations replace the removed T2 tests, provides specific issue references (CNV-3042, CNV-3373, CNV-3043, CNV-2939), links to upstream code, and documents additional changes (dependency markers, unused imports).

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

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

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/install_upgrade_operators/must_gather/test_must_gather_images.py`:
- Around line 49-63: The test_image_stream_tag_gather should defensively handle
a missing istag_dir: before calling os.listdir(istag_dir) check
os.path.exists(istag_dir) (or os.path.isdir) and assert with a clear message
like "must-gather did not produce ImageStreamTag directory at {istag_dir}" or
skip the test if that represents no data; then proceed to compare
len(os.listdir(istag_dir)) to list(ImageStreamTag.get(...)) as before and call
check_list_of_resources with the same parameters (resource_type=ImageStreamTag,
temp_dir=gathered_images, resource_path=f"{resource_path}/{{name}}.yaml",
checks=VALIDATE_UID_NAME, filter_resource="redhat").

ℹ️ 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 05a8bf6 and 12062dd.

📒 Files selected for processing (3)
  • tests/install_upgrade_operators/must_gather/test_must_gather.py
  • tests/install_upgrade_operators/must_gather/test_must_gather_images.py
  • tests/install_upgrade_operators/must_gather/test_must_gather_vms.py
💤 Files with no reviewable changes (1)
  • tests/install_upgrade_operators/must_gather/test_must_gather_vms.py

@OhadRevah
Copy link
Contributor Author

/build-and-push-container

@openshift-virtualization-qe-bot

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

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.

6 participants