Skip to content

fix(storage): pass client to openshift-python-wrapper resources in storage tests - #5871

Open
davmarro wants to merge 5 commits into
RedHatQE:mainfrom
davmarro:add-client-to-openshift-wrapper-resources
Open

fix(storage): pass client to openshift-python-wrapper resources in storage tests#5871
davmarro wants to merge 5 commits into
RedHatQE:mainfrom
davmarro:add-client-to-openshift-wrapper-resources

Conversation

@davmarro

@davmarro davmarro commented Aug 3, 2026

Copy link
Copy Markdown
What this PR does / why we need it:

Pass an explicit DynamicClient to all ocp_resources constructors in tests/storage/, utilities/storage.py, and tests/data_protection/oadp/ so resource creation does not fall back to implicit get_client().

The client is selected based following these criteria:

  • admin_client for cluster-scoped resources and admin operations
  • unprivileged_client for test resources that verify RBAC
  • resource.client when a parent resource already has the correct client
Which issue(s) this PR fixes:

Not issue at all.
In the next major release, all the openshift wrapper constructor will have a mandatory client arg. So in this PR we're fixing all the methods where the client is not passed.

Special notes for reviewer:

The PR is quite big (19 files modified) but the changes are really simple, most of them are just adding a client to method signatures, so nothing complex.

jira-ticket:

https://redhat.atlassian.net/browse/CNV-68536

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of storage, snapshot, upload, migration, restore, and volume-resize validation.
    • Corrected resource access handling across administrative and restricted-namespace scenarios.
    • Improved volume binding behavior for cloning, importing, and test provisioning workflows.
  • Tests

    • Expanded coverage for storage-class selection, cached snapshots, hostpath provisioning, data protection, CDI configuration, and concurrent uploads.
    • Added stronger validation for resource cleanup, readiness, garbage collection, and missing storage configurations.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b852d62f-5e49-44bc-8b79-cc0dff4c1075

📥 Commits

Reviewing files that changed from the base of the PR and between 56d89b9 and 0e698a3.

📒 Files selected for processing (4)
  • tests/conftest.py
  • tests/storage/test_data_import_cron.py
  • tests/storage/test_hotplug.py
  • utilities/storage.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • RedHatQE/openshift-virtualization-tests-design-docs (manual)

📝 Walkthrough

Walkthrough

Changes

Storage utilities, fixtures, and storage tests now pass explicit Kubernetes clients to resource constructors, lookups, polling helpers, and cleanup checks. Several DataVolume workflows also disable WFFC consumption and apply immediate-binding annotations.

Storage client configuration

Layer / File(s) Summary
Storage utility client contracts
utilities/storage.py
Storage helpers now require explicit clients, validate dummy consumer pod inputs, and return None when no matching storage class exists.
Fixture resource client wiring
tests/conftest.py, tests/data_protection/oadp/conftest.py, tests/storage/**
Storage fixtures now pass admin, namespace, VM, or unprivileged clients to constructed Kubernetes resources.
Storage workflow propagation
tests/storage/test_data_import_cron.py, tests/storage/test_hotplug.py, tests/storage/test_wffc.py, tests/storage/storage_migration/*, tests/storage/vm_export/*
Import, migration, WFFC, VM export, and hotplug workflows now use explicit clients for resource operations and checks.
Immediate binding and restore workflows
tests/storage/online_resize/utils.py, tests/storage/restricted_namespace_cloning/conftest.py, tests/storage/test_cdi_certificate.py, tests/storage/general/test_storage_behavior.py
Selected DataVolume and PVC workflows now configure immediate binding and explicit client propagation.
CDI upload client propagation
tests/storage/cdi_config/*, tests/storage/cdi_upload/*, tests/storage/conftest.py
Upload route, storage-class, PV, PVC, and consumer-pod operations now receive explicit clients.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 0e698

This change makes storage tests pass explicit clients to resource constructors without introducing an evidenced production behavior change; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title is under 120 characters and clearly describes passing explicit clients to OpenShift Python wrapper resources in storage tests.
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.
Pr Template Sections ✅ Passed The current PR body contains all four required headings, and the first section has meaningful explanatory text about explicit DynamicClient arguments and the upcoming mandatory client API.
Stp Link Required ✅ Passed The diff adds no test files and AST comparison against main finds zero new def test_* functions; all touched test functions only change existing signatures or calls.
Stp Scenario Coverage ✅ Passed The PR modifies test_*.py files with Jira links, but both affected links remain valid and unchanged; no changed test file contains an STP or RFE link.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@openshift-virtualization-qe-bot-4

Copy link
Copy Markdown

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 (PR author or approvers)
  • /hold cancel - Unblock PR merging (PR author or approvers)
  • /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
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

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
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

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, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • jpeimer
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Acedus
  • Ahmad-Hafe
  • Dsanatar
  • RoniKishner
  • acinko-rh
  • akalenyu
  • awels
  • dalia-frank
  • dshchedr
  • ema-aka-young
  • geetikakay
  • josemacassan
  • jpeimer
  • kgoldbla
  • kshvaika
  • rnetser
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6-1m)
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • 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

📌 Additional Information

Custom Commands:

  • /test-plan — Triggers CodeRabbit to analyze the PR's changed files and post a test execution plan
  • /rerun-smoke — Adds retest-smoke label on the PR to trigger smoke tests execution

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

@jpeimer

jpeimer commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@davmarro

Copy link
Copy Markdown
Author

/check-can-merge

@davmarro

Copy link
Copy Markdown
Author

hey @rnetser @josemacassan @jpeimer, also the smoke tests passed.
Seems to be ok to merge.
Waiting for your approve.

Thanks

@ema-aka-young

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

Auto-triggered: Files in this PR were modified by merged PR #5672.

Overlapping files

tests/conftest.py

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/conftest.py (1)

56-56: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

MEDIUM: Replace the bare module import.

import utilities.hco violates the repository import rule. Use from utilities import hco and update qualified references to use hco. This rule keeps module dependencies explicit and consistent.

Proposed change
-import utilities.hco
+from utilities import hco

As per coding guidelines, “Use absolute imports, prefer specific imports, and do not use bare import module without a from clause.”

🤖 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/conftest.py` at line 56, Replace the bare utilities.hco import with a
specific from utilities import hco import, then update all references in the
affected test configuration to use hco instead of utilities.hco.

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.

Outside diff comments:
In `@tests/conftest.py`:
- Line 56: Replace the bare utilities.hco import with a specific from utilities
import hco import, then update all references in the affected test configuration
to use hco instead of utilities.hco.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4a309171-7459-4c08-a1d5-f26a41377a4b

📥 Commits

Reviewing files that changed from the base of the PR and between 709d12f and 56d89b9.

📒 Files selected for processing (1)
  • tests/conftest.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • RedHatQE/openshift-virtualization-tests-design-docs (manual)

@openshift-virtualization-qe-bot-5

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (56d89b9).
The following labels were preserved: verified, approved-jpeimer, lgtm-jpeimer, commented-rnetser, commented-coderabbitai[bot], lgtm-coderabbitai[bot], commented-openshift-virtualization-qe-bot-3, lgtm-ema-aka-young, commented-davmarro.

@davmarro

Copy link
Copy Markdown
Author

/verified openshift-virtualization-tests-runner/6129 -s -o log_cli=true -rsx --jira -m 'tier2 and storage and gating' --latest-rhel tests/storage --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization

openshift-virtualization-tests-runner/6133
-s -o log_cli=true -rsx --jira tests/storage/restricted_namespace_cloning --storage-class-matrix=hostpath-csi-pvc-block

@rnetser

rnetser commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Missing client= in second_object_cleanup

tests/storage/test_data_import_cron.py — the second_object_cleanup fixture (line 196) constructs resource_class(namespace=namespace.name, name=second_object_name) without client=. Every other constructor in this file now receives an explicit client (admin_client). This cleanup fixture should get admin_client too — same pattern as test_data_import_cron_garbage_collection below it.

Suggested fix:

@pytest.fixture()
def second_object_cleanup(
    admin_client,
    namespace,
    second_object_name,
    storage_with_import_cron_source_snapshot,
):
    yield
    LOGGER.info(
        f"Cleanup the remaining second_object '{second_object_name}' "
        f"(DV/PVC or VolumeSnapshot) that was created by the DataImportCron"
    )
    resource_class = VolumeSnapshot if storage_with_import_cron_source_snapshot else DataVolume
    resource_class(namespace=namespace.name, name=second_object_name, client=admin_client).clean_up()

Assisted-by: PI (claude-opus-4-6-1m)

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

Clean rebase detected — no code changes compared to previous head (ba11ab7).
The following labels were preserved: verified, approved-jpeimer, lgtm-jpeimer, commented-rnetser, commented-coderabbitai[bot], lgtm-coderabbitai[bot], commented-openshift-virtualization-qe-bot-3, lgtm-ema-aka-young, commented-davmarro.

@davmarro

Copy link
Copy Markdown
Author

Missing client= in second_object_cleanup

tests/storage/test_data_import_cron.py — the second_object_cleanup fixture (line 196) constructs resource_class(namespace=namespace.name, name=second_object_name) without client=. Every other constructor in this file now receives an explicit client (admin_client). This cleanup fixture should get admin_client too — same pattern as test_data_import_cron_garbage_collection below it.

Suggested fix:

@pytest.fixture()
def second_object_cleanup(
    admin_client,
    namespace,
    second_object_name,
    storage_with_import_cron_source_snapshot,
):
    yield
    LOGGER.info(
        f"Cleanup the remaining second_object '{second_object_name}' "
        f"(DV/PVC or VolumeSnapshot) that was created by the DataImportCron"
    )
    resource_class = VolumeSnapshot if storage_with_import_cron_source_snapshot else DataVolume
    resource_class(namespace=namespace.name, name=second_object_name, client=admin_client).clean_up()

Assisted-by: PI (claude-opus-4-6-1m)

@rnetser thanks for spotting it.
Fixed.

@openshift-virtualization-qe-bot-5

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (bf182ed).
The following labels were preserved: verified, approved-jpeimer, lgtm-jpeimer, commented-rnetser, commented-coderabbitai[bot], lgtm-coderabbitai[bot], commented-openshift-virtualization-qe-bot-3, lgtm-ema-aka-young, commented-davmarro.

@jpeimer

jpeimer commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@josemacassan

Copy link
Copy Markdown
Contributor

/lgtm

@davmarro

Copy link
Copy Markdown
Author

/verified

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the full Test Execution Plan (smoke decision, gating decision, and specific affected tests).
Do NOT submit a blocking review event (REQUEST_CHANGES/APPROVE).
Post a single inline PR comment on Files Changed (non-blocking COMMENT flow).

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file

  2. Identify affected code paths, functions, and classes

  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes

  4. Trace test dependencies through imports, shared utilities, fixture inheritance, fixture teardown, and yield from cleanup in conftest

  5. Detect new tests introduced in the PR

  6. Utilities and libs impact (when utilities/ or libs/ changes):
    You MUST use shell scripts (rg, git diff) to trace the full impact.
    Follow these sub-steps in order:

    6a. Identify modified symbols: For each changed file under utilities/ or libs/,
    list every modified function or method.
    Example: git diff HEAD~1 --unified=0 -- utilities/hco.py | grep '^[+-]def '

    6b. Find direct callers: Search tests and conftest for each symbol from 6a.
    Example: rg -l 'get_hco_version' tests/

    6c. Trace fixture teardown and cleanup: Find fixtures that reach
    the modified symbol through yield from or context-manager wrappers.
    Example: rg -l 'yield from.*enable_common_boot|def.*enable_common_boot' tests/

    6d. Trace same-file callers: In each changed file, find other functions
    whose body calls a modified symbol (including code after yield
    in @contextmanager helpers).
    Example: rg 'get_hco_version|enable_common_boot' utilities/hco.py

    6e. Expand transitively: If function A calls modified B, then
    tests/fixtures that call A are affected — even when the test body
    never imports B directly.

    Do NOT limit impact to tests that import the modified symbol only.

  7. Smoke test impact: Intersect the affected set from step 6 with smoke-marked tests.
    Run: rg -l '@pytest.mark.smoke' tests/
    VERIFY the above command returned actual file paths before concluding False.
    Set True if either condition is met:

    • a smoke-marked file appears in the affected set from 6b-6e, OR
    • any conftest.py in the smoke test's parent-directory hierarchy (up to repo root)
      imports or calls a modified utilities/libs symbol — including autouse fixtures
      that depend on modified functions. ALL tests in that directory and below are affected.
      Example check: for each smoke_file, scan dirname(smoke_file)/conftest.py,
      dirname(dirname(smoke_file))/conftest.py, etc. for modified symbol imports
      and autouse fixtures that depend on modified symbols.
  8. Gating test impact: Intersect the affected set from step 6 with gating-marked tests.
    Run: rg -l '@pytest.mark.gating' tests/
    Set True if a gating-marked file also appears in the affected set from 6b-6e.
    Utilities/libs changes often affect gating tests without affecting smoke tests.
    Do NOT stop analysis after concluding Run smoke tests: False.

Output rules:
Do NOT include analysis step numbers (1-8) in your visible output.

Your deliverable:
Your inline informational comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False — If True, state the dependency path (test → fixture → changed symbol). True ONLY with a verified path.
  • Run gating tests: True / False — If True, state the dependency path. True if any gating-marked test is in the affected set.
  • Affected tests to run (required when utilities/, libs/, or shared conftest changes — list concrete paths even when smoke is False)

Use these formats:

  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When a marker covers multiple affected tests (e.g. -m gating only if ALL gating tests in scope need run)
  • Tag each listed test or group with its marker when not obvious, e.g. (gating) or (smoke)

Real test commands (MANDATORY when changes affect session/runtime code):

When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
config hooks, session-scoped setup) or modifies runtime behavior that unit tests mock away,
you MUST include concrete pytest commands the PR author must run on a real cluster
to verify the change works end-to-end. Include:

  • A command for the error/fix path (the scenario the PR fixes)
  • A command for the happy path (regression: the normal case still works)
  • Use lightweight tests (e.g., --collect-only for startup failures,
    a single small test for runtime behavior)
    If the PR only changes test logic (not utilities/libs/conftest), the affected test
    paths themselves serve as the real test commands — no separate section needed.

Example output for a session-startup fix:

**Real tests (cluster required)**
Error path (the fix):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=nonexistent-sc --collect-only`
Expected: ValueError with clear message, not IndexError

Happy path (regression):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=<valid-sc> -k test_bar`
Expected: session starts normally

Guidelines:

  • Include tests affected directly OR via fixture setup/teardown, yield from cleanup, or transitive utility call chains (caller calls modified helper)
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name when only specific tests use an affected fixture or utility wrapper (preferred for partial file impact)
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Example: if leaf helper foo() changes, include tests whose fixture teardown calls wrapper bar() where bar() calls foo(), even when the test body only imports an unrelated symbol from the same utilities module

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post one non-blocking inline comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If inline comment API calls fail after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL — Verification rules for smoke and gating decisions:
- For each True decision, you must have traced a concrete path: test file → fixture → utility function → modified symbol.
- Do NOT assume impact based on scope, file proximity, or infrastructure-sounding names.
Only set True when you trace a concrete path through steps 6a-6e, then 7 or 8.
WRONG: "utilities/hco.py changed → run smoke" (no traced dependency path)
WRONG: "Run smoke tests: False" with no affected-test list when gating tests use the changed utility
RIGHT: "Run smoke tests: False, Run gating tests: True" plus tests/.../test_foo.py::TestBar::test_baz (gating)
RIGHT: "Smoke test X uses fixture Y → wrapper Z → changed function W in utilities/hco.py"

Comment thread tests/conftest.py
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 13, 2026
@davmarro

Copy link
Copy Markdown
Author

Hi @rnetser do you think it can be merged ?

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

Auto-triggered: Files in this PR were modified by merged PR #5708.

Overlapping files

tests/storage/test_hotplug.py
utilities/storage.py

…orage tests

Pass an explicit DynamicClient to all ocp_resources constructors in
tests/storage/, utilities/storage.py, and tests/data_protection/oadp/
so resource creation does not fall back to implicit get_client().
jira-ticket: https://redhat.atlassian.net/browse/CNV-68536

Signed-off-by: davmarro <dmarro@redhat.com>
…hods

Signed-off-by: davmarro <dmarro@redhat.com>
…rInstancetype and VirtualMachineClusterPreference

Signed-off-by: davmarro <dmarro@redhat.com>
Signed-off-by: davmarro <dmarro@redhat.com>
Signed-off-by: davmarro <dmarro@redhat.com>
@davmarro

Copy link
Copy Markdown
Author

/verified

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the full Test Execution Plan (smoke decision, gating decision, and specific affected tests).
Do NOT submit a blocking review event (REQUEST_CHANGES/APPROVE).
Post a single inline PR comment on Files Changed (non-blocking COMMENT flow).

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file

  2. Identify affected code paths, functions, and classes

  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes

  4. Trace test dependencies through imports, shared utilities, fixture inheritance, fixture teardown, and yield from cleanup in conftest

  5. Detect new tests introduced in the PR

  6. Utilities and libs impact (when utilities/ or libs/ changes):
    You MUST use shell scripts (rg, git diff) to trace the full impact.
    Follow these sub-steps in order:

    6a. Identify modified symbols: For each changed file under utilities/ or libs/,
    list every modified function or method.
    Example: git diff HEAD~1 --unified=0 -- utilities/hco.py | grep '^[+-]def '

    6b. Find direct callers: Search tests and conftest for each symbol from 6a.
    Example: rg -l 'get_hco_version' tests/

    6c. Trace fixture teardown and cleanup: Find fixtures that reach
    the modified symbol through yield from or context-manager wrappers.
    Example: rg -l 'yield from.*enable_common_boot|def.*enable_common_boot' tests/

    6d. Trace same-file callers: In each changed file, find other functions
    whose body calls a modified symbol (including code after yield
    in @contextmanager helpers).
    Example: rg 'get_hco_version|enable_common_boot' utilities/hco.py

    6e. Expand transitively: If function A calls modified B, then
    tests/fixtures that call A are affected — even when the test body
    never imports B directly.

    Do NOT limit impact to tests that import the modified symbol only.

  7. Smoke test impact: Intersect the affected set from step 6 with smoke-marked tests.
    Run: rg -l '@pytest.mark.smoke' tests/
    VERIFY the above command returned actual file paths before concluding False.
    Set True if either condition is met:

    • a smoke-marked file appears in the affected set from 6b-6e, OR
    • any conftest.py in the smoke test's parent-directory hierarchy (up to repo root)
      imports or calls a modified utilities/libs symbol — including autouse fixtures
      that depend on modified functions. ALL tests in that directory and below are affected.
      Example check: for each smoke_file, scan dirname(smoke_file)/conftest.py,
      dirname(dirname(smoke_file))/conftest.py, etc. for modified symbol imports
      and autouse fixtures that depend on modified symbols.
  8. Gating test impact: Intersect the affected set from step 6 with gating-marked tests.
    Run: rg -l '@pytest.mark.gating' tests/
    Set True if a gating-marked file also appears in the affected set from 6b-6e.
    Utilities/libs changes often affect gating tests without affecting smoke tests.
    Do NOT stop analysis after concluding Run smoke tests: False.

Output rules:
Do NOT include analysis step numbers (1-8) in your visible output.

Your deliverable:
Your inline informational comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False — If True, state the dependency path (test → fixture → changed symbol). True ONLY with a verified path.
  • Run gating tests: True / False — If True, state the dependency path. True if any gating-marked test is in the affected set.
  • Affected tests to run (required when utilities/, libs/, or shared conftest changes — list concrete paths even when smoke is False)

Use these formats:

  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When a marker covers multiple affected tests (e.g. -m gating only if ALL gating tests in scope need run)
  • Tag each listed test or group with its marker when not obvious, e.g. (gating) or (smoke)

Real test commands (MANDATORY when changes affect session/runtime code):

When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
config hooks, session-scoped setup) or modifies runtime behavior that unit tests mock away,
you MUST include concrete pytest commands the PR author must run on a real cluster
to verify the change works end-to-end. Include:

  • A command for the error/fix path (the scenario the PR fixes)
  • A command for the happy path (regression: the normal case still works)
  • Use lightweight tests (e.g., --collect-only for startup failures,
    a single small test for runtime behavior)
    If the PR only changes test logic (not utilities/libs/conftest), the affected test
    paths themselves serve as the real test commands — no separate section needed.

Example output for a session-startup fix:

**Real tests (cluster required)**
Error path (the fix):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=nonexistent-sc --collect-only`
Expected: ValueError with clear message, not IndexError

Happy path (regression):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=<valid-sc> -k test_bar`
Expected: session starts normally

Guidelines:

  • Include tests affected directly OR via fixture setup/teardown, yield from cleanup, or transitive utility call chains (caller calls modified helper)
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name when only specific tests use an affected fixture or utility wrapper (preferred for partial file impact)
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Example: if leaf helper foo() changes, include tests whose fixture teardown calls wrapper bar() where bar() calls foo(), even when the test body only imports an unrelated symbol from the same utilities module

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post one non-blocking inline comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If inline comment API calls fail after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL — Verification rules for smoke and gating decisions:
- For each True decision, you must have traced a concrete path: test file → fixture → utility function → modified symbol.
- Do NOT assume impact based on scope, file proximity, or infrastructure-sounding names.
Only set True when you trace a concrete path through steps 6a-6e, then 7 or 8.
WRONG: "utilities/hco.py changed → run smoke" (no traced dependency path)
WRONG: "Run smoke tests: False" with no affected-test list when gating tests use the changed utility
RIGHT: "Run smoke tests: False, Run gating tests: True" plus tests/.../test_foo.py::TestBar::test_baz (gating)
RIGHT: "Smoke test X uses fixture Y → wrapper Z → changed function W in utilities/hco.py"

Comment thread tests/conftest.py

@pytest.fixture(scope="session")
def storage_class_with_filesystem_volume_mode(available_storage_classes_names):
def storage_class_with_filesystem_volume_mode(admin_client, available_storage_classes_names):

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.

Test Execution Plan

Run smoke tests: Truetests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_templatefedora_dv_with_block_volume_mode and storage_class_with_filesystem_volume_modeget_storage_class_with_specified_volume_mode(..., client=admin_client). This validates explicit client propagation in the shared session fixture.

Run gating tests: Truetests/storage/cdi_clone/test_clone.py::test_clone_from_fs_to_block_using_dv_template → the shared block and filesystem storage-class fixtures → get_storage_class_with_specified_volume_mode(..., client=admin_client). tests/storage/test_hotplug.py migration tests → is_dv_migratable(..., client=admin_client)StorageProfile. tests/storage/restricted_namespace_cloning/test_restricted_namespace_cloning_vms.py::test_create_vm_with_cloned_data_volume_permissions_for_pods_positivedata_volume_clone_settings(..., unprivileged_client).

Affected tests to run

  • tests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_template (smoke)
  • tests/storage/cdi_clone/test_clone.py::test_successful_vm_restart_with_cloned_dv (gating)
  • tests/storage/cdi_clone/test_clone.py::test_clone_from_fs_to_block_using_dv_template (gating)
  • tests/storage/test_hotplug.py::TestHotPlugWithPersist::test_hotplug_volume_with_bus_and_persist_migrate (gating)
  • tests/storage/test_hotplug.py::TestHotPlugWithSerialPersist::test_hotplug_volume_with_serial_and_persist_migrate (gating)
  • tests/storage/restricted_namespace_cloning/test_restricted_namespace_cloning_vms.py::test_create_vm_with_cloned_data_volume_permissions_for_pods_positive (gating)
  • tests/storage/cdi_config/test_cdi_config.py::test_cdi_spec_reconciled_by_hco
  • tests/storage/cdi_config/test_cdi_config.py::test_different_route_for_upload_proxy
  • tests/storage/cdi_upload/test_upload.py::test_cdi_uploadproxy_route_owner_references
  • tests/storage/cdi_upload/test_upload.py::test_successful_concurrent_uploads
  • tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_with_exist_dv_image
  • tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_pvc (gating)
  • tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_with_exist_pvc_image
  • tests/storage/fs_overhead/test_fs_overhead.py
  • tests/storage/golden_image/test_cached_snapshots.py
  • tests/storage/data_import_cron/test_data_import_cron_pvc_source.py
  • tests/storage/test_data_import_cron.py::test_data_import_cron_garbage_collection
  • tests/storage/hpp/test_hpp_node_placement.py
  • tests/storage/hpp/test_hostpath.py
  • tests/storage/snapshots/test_snapshots.py::test_online_windows_vm_successful_restore
  • tests/storage/snapshots/test_snapshots.py::test_write_to_file_while_snapshot
  • tests/storage/test_cdi_certificate.py::test_upload_after_validate_aggregated_api_cert
  • tests/storage/test_wffc.py::test_wffc_vm_with_two_data_volume_templates

Real tests (cluster required)

Error path (explicit client propagation):
pytest tests/storage/test_hotplug.py -m gating -k 'persist_migrate'
Expected: StorageProfile uses admin_client. The migration tests complete without a missing-client constructor error.

Happy path (shared storage-class fixtures):
pytest tests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_template
Expected: filesystem and block StorageProfile lookups use admin_client, and the clone completes.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="RedHatQE/openshift-virtualization-tests"
pr="5871"

echo '=== PR metadata and changed files ==='
gh pr view "$pr" --repo "$repo" --json headRefOid,baseRefName,files \
  --jq '{head: .headRefOid, base: .baseRefName, files: [.files[].path]}'

base_ref="$(gh pr view "$pr" --repo "$repo" --json baseRefName --jq '.baseRefName')"
base="$(git merge-base HEAD "origin/$base_ref" 2>/dev/null || true)"
if [ -n "$base" ]; then
  echo "=== Diff base: $base ==="
  git diff --name-only "$base" HEAD
  echo '=== First changed-file patch ==='
  first_file="$(git diff --name-only "$base" HEAD | head -n1)"
  printf '%s\n' "$first_file"
  git diff --unified=2 "$base" HEAD -- "$first_file"
  echo '=== Changed utility definitions ==='
  git diff --unified=0 "$base" HEAD -- utilities/storage.py |
    grep -E '^[+-][[:space:]]*(async[[:space:]]+)?def[[:space:]]+' || true
else
  echo '=== PR patches from GitHub ==='
  gh api "repos/$repo/pulls/$pr/files?per_page=100" --paginate \
    --jq '.[] | "FILE: \(.filename)\n\(.patch // "")"'
fi

echo '=== Modified storage helper callers ==='
for symbol in \
  create_dummy_first_consumer_pod \
  cdi_feature_gate_list_with_added_feature \
  get_storage_class_with_specified_volume_mode \
  verify_dv_and_pvc_does_not_exist \
  wait_for_volume_snapshot_ready_to_use \
  wait_for_succeeded_dv
do
  echo "--- $symbol ---"
  rg -n -C2 "\b${symbol}\s*\(" tests utilities --glob '*.py' || true
done

echo '=== Changed fixture and local helper consumers ==='
rg -n -C2 \
'\b(storage_class_with_filesystem_volume_mode|storage_class_with_block_volume_mode|uploadproxy_route_deleted|new_route_created|imported_data_source|rhel9_cached_snapshot|cirros_pv_on_hpp|data_volume_clone_settings|windows_snapshot|blank_dv_template_wffc_scope_function|is_dv_migratable|wait_for_succeeded_imported_object|assert_first_imported_object_was_deleted)\b' \
tests --glob '*.py' || true

echo '=== Fixture teardown paths and utility wrappers ==='
rg -n -C3 'yield from|^[[:space:]]*yield\b|`@contextmanager`' tests utilities/storage.py --glob '*.py' || true

echo '=== Smoke and gating test declarations ==='
rg -n -C2 '`@pytest`\.mark\.(smoke|gating)' tests --glob '*.py' || true

Length of output: 162561


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="RedHatQE/openshift-virtualization-tests"
pr="5871"

echo '=== Current head and changed-file order ==='
gh pr view "$pr" --repo "$repo" --json headRefOid,files \
  --jq '"HEAD=" + .headRefOid, (.files[] | .path)'

echo '=== First changed-file patch from GitHub ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" --paginate \
  --jq '.[] | select(.filename == "tests/conftest.py") | .patch'

echo '=== utilities/storage.py patch ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" --paginate \
  --jq '.[] | select(.filename == "utilities/storage.py") | .patch'

echo '=== Exact changed-fixture/helper consumers in storage tests ==='
rg -n -C2 \
'\b(storage_class_with_filesystem_volume_mode|storage_class_with_block_volume_mode|uploadproxy_route_deleted|new_route_created|imported_data_source|rhel9_cached_snapshot|cirros_pv_on_hpp|data_volume_clone_settings|windows_snapshot|blank_dv_template_wffc_scope_function|is_dv_migratable|wait_for_succeeded_imported_object|assert_first_imported_object_was_deleted|create_dummy_first_consumer_pod|cdi_feature_gate_list_with_added_feature|get_storage_class_with_specified_volume_mode|verify_dv_and_pvc_does_not_exist|wait_for_volume_snapshot_ready_to_use|wait_for_succeeded_dv)\b' \
tests/storage tests/conftest.py utilities/storage.py --glob '*.py'

echo '=== Relevant marked test definitions ==='
rg -n -C4 \
'`@pytest`\.mark\.(smoke|gating)|^(class TestHotPlugWithPersist|class TestHotPlugWithSerialPersist|def test_(clone_from_block_to_fs_using_dv_template|successful_vm_restart_with_cloned_dv|clone_from_fs_to_block_using_dv_template|create_vm_with_cloned_data_volume_permissions_for_pods_positive|cdi_spec_reconciled_by_hco|different_route_for_upload_proxy|cdi_uploadproxy_route_owner_references|successful_concurrent_uploads|virtctl_image_upload_with_exist_dv_image|virtctl_image_upload_pvc|virtctl_image_upload_with_exist_pvc_image|data_import_cron_garbage_collection|wffc_vm_with_two_data_volume_templates))' \
tests/storage/cdi_clone/test_clone.py \
tests/storage/cdi_config/test_cdi_config.py \
tests/storage/cdi_upload/test_upload.py \
tests/storage/cdi_upload/test_upload_virtctl.py \
tests/storage/test_hotplug.py \
tests/storage/restricted_namespace_cloning/test_restricted_namespace_cloning_vms.py \
tests/storage/test_data_import_cron.py \
tests/storage/test_wffc.py

echo '=== Fixture definitions in directly affected conftest files ==='
rg -n -C2 \
'^(def (storage_class_with_filesystem_volume_mode|storage_class_with_block_volume_mode|uploadproxy_route_deleted|new_route_created|imported_data_source|rhel9_cached_snapshot|cirros_pv_on_hpp|data_volume_clone_settings|windows_snapshot)|`@pytest`\.fixture)' \
tests/conftest.py tests/storage/conftest.py tests/storage/data_import_cron/conftest.py \
tests/storage/hpp/conftest.py tests/storage/restricted_namespace_cloning/conftest.py \
tests/storage/snapshots/conftest.py

Length of output: 119605


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="RedHatQE/openshift-virtualization-tests"
pr="5871"
head_sha="0e698a3561d483fb549aa54a71e9742ff42fadb8"
body_file="$(mktemp)"

cat >"$body_file" <<'EOF'
## Test Execution Plan

**Run smoke tests: True** — `tests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_template` → `fedora_dv_with_block_volume_mode` and `storage_class_with_filesystem_volume_mode` → `get_storage_class_with_specified_volume_mode(..., client=admin_client)`. This validates explicit client propagation in the shared session fixture.

**Run gating tests: True** — `tests/storage/cdi_clone/test_clone.py::test_clone_from_fs_to_block_using_dv_template` → the shared block and filesystem storage-class fixtures → `get_storage_class_with_specified_volume_mode(..., client=admin_client)`. `tests/storage/test_hotplug.py` migration tests → `is_dv_migratable(..., client=admin_client)` → `StorageProfile`. `tests/storage/restricted_namespace_cloning/test_restricted_namespace_cloning_vms.py::test_create_vm_with_cloned_data_volume_permissions_for_pods_positive` → `data_volume_clone_settings(..., unprivileged_client)`.

**Affected tests to run**
- `tests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_template` (smoke)
- `tests/storage/cdi_clone/test_clone.py::test_successful_vm_restart_with_cloned_dv` (gating)
- `tests/storage/cdi_clone/test_clone.py::test_clone_from_fs_to_block_using_dv_template` (gating)
- `tests/storage/test_hotplug.py::TestHotPlugWithPersist::test_hotplug_volume_with_bus_and_persist_migrate` (gating)
- `tests/storage/test_hotplug.py::TestHotPlugWithSerialPersist::test_hotplug_volume_with_serial_and_persist_migrate` (gating)
- `tests/storage/restricted_namespace_cloning/test_restricted_namespace_cloning_vms.py::test_create_vm_with_cloned_data_volume_permissions_for_pods_positive` (gating)
- `tests/storage/cdi_config/test_cdi_config.py::test_cdi_spec_reconciled_by_hco`
- `tests/storage/cdi_config/test_cdi_config.py::test_different_route_for_upload_proxy`
- `tests/storage/cdi_upload/test_upload.py::test_cdi_uploadproxy_route_owner_references`
- `tests/storage/cdi_upload/test_upload.py::test_successful_concurrent_uploads`
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_with_exist_dv_image`
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_pvc` (gating)
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_with_exist_pvc_image`
- `tests/storage/fs_overhead/test_fs_overhead.py`
- `tests/storage/golden_image/test_cached_snapshots.py`
- `tests/storage/data_import_cron/test_data_import_cron_pvc_source.py`
- `tests/storage/test_data_import_cron.py::test_data_import_cron_garbage_collection`
- `tests/storage/hpp/test_hpp_node_placement.py`
- `tests/storage/hpp/test_hostpath.py`
- `tests/storage/snapshots/test_snapshots.py::test_online_windows_vm_successful_restore`
- `tests/storage/snapshots/test_snapshots.py::test_write_to_file_while_snapshot`
- `tests/storage/test_cdi_certificate.py::test_upload_after_validate_aggregated_api_cert`
- `tests/storage/test_wffc.py::test_wffc_vm_with_two_data_volume_templates`

**Real tests (cluster required)**

Error path (explicit client propagation):
`pytest tests/storage/test_hotplug.py -m gating -k 'persist_migrate'`
Expected: `StorageProfile` uses `admin_client`. The migration tests complete without a missing-client constructor error.

Happy path (shared storage-class fixtures):
`pytest tests/storage/cdi_clone/test_clone.py::test_clone_from_block_to_fs_using_dv_template`
Expected: filesystem and block `StorageProfile` lookups use `admin_client`, and the clone completes.
EOF

gh api --method POST "repos/$repo/pulls/$pr/comments" \
  -f body="$(cat "$body_file")" \
  -f commit_id="$head_sha" \
  -f path="tests/conftest.py" \
  -F line=1275 \
  -f side="RIGHT" \
  >/dev/null

rm -f "$body_file"

Length of output: 4107


@openshift-virtualization-qe-bot-3: The inline test execution plan was posted.

You are interacting with an AI system.

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.