[Main] Storage: Change Cirros images for RHEL from DataSource into upgrade tests#5003
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughReplace CirrOS-based snapshot-upgrade VMs with RHEL10 fixtures, add shared upgrade-file constants, refactor VM creation to accept data-source-backed volumes and inject files via SSH, update three snapshot/restore tests to use RHEL VMs and generic SSH-based command helpers, and remove the CirrOS console-based helper while adding disk-serial assertion. ChangesStorage Upgrade Test Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsLinked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped 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. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5003 +/- ##
==========================================
+ Coverage 98.67% 98.87% +0.20%
==========================================
Files 25 42 +17
Lines 2487 2578 +91
==========================================
+ Hits 2454 2549 +95
+ Misses 33 29 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/storage/upgrade/utils.py (1)
20-27: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winHIGH: Add explicit type hints to updated public helpers.
Both context-manager helpers are public and changed in this PR, but they remain untyped. Please add full parameter and return annotations to keep these utilities strict and self-documenting.
💡 Proposed typing shape
from contextlib import contextmanager +from collections.abc import Generator +from typing import Any `@contextmanager` def create_vm_for_snapshot_upgrade_tests( - vm_name, - namespace, - client, - storage_class_for_snapshot, - cpu_model, - data_source, -): + vm_name: str, + namespace: str, + client: Any, + storage_class_for_snapshot: str, + cpu_model: str, + data_source: Any, +) -> Generator[VirtualMachineForTests]: @@ `@contextmanager` -def create_snapshot_for_upgrade(vm, client): +def create_snapshot_for_upgrade(vm: VirtualMachineForTests, client: Any) -> Generator[VirtualMachineSnapshot]:As per coding guidelines: "Type hints are MANDATORY."
Also applies to: 52-53
🤖 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/storage/upgrade/utils.py` around lines 20 - 27, The public context-manager helpers (notably create_vm_for_snapshot_upgrade_tests and the other context-manager helper in this module) lack type hints; add explicit annotations for all params and returns using typing (e.g., import Any, Dict, Optional, Generator) and annotate parameters as vm_name: str, namespace: str, client: Any, storage_class_for_snapshot: str, cpu_model: str, data_source: Optional[Dict[str, Any]] (or a more precise dict type if known), and change the return type to a context-manager generator like Generator[Any, None, None] or Generator[Dict[str, Any], None, None] (use the precise VM type if available) and apply the same full-parameter/return annotations to the other helper mentioned.
🤖 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 `@tests/storage/upgrade/conftest.py`:
- Around line 59-61: The test fixture calls update_scratch_space_sc but that
symbol is not defined or imported, causing a NameError at runtime; fix by
importing update_scratch_space_sc from its module (or add a local definition)
and ensure the import is added to tests/storage/upgrade/conftest.py so the
with-statement using update_scratch_space_sc (and the variable
edited_cdi_config) resolves correctly at runtime.
- Line 27: Rename the verb-named fixtures to noun-style names: change
skip_if_less_than_two_storage_classes to two_storage_classes_required and
skip_if_not_override_cdiconfig_scratch_space to
cdiconfig_scratch_space_override_required (leave
storage_class_for_updating_cdiconfig_scratch as-is); update the fixture
definitions accordingly and then update every test, conftest import or parameter
that references skip_if_less_than_two_storage_classes or
skip_if_not_override_cdiconfig_scratch_space to use the new names
two_storage_classes_required and cdiconfig_scratch_space_override_required so
all usages match the renamed fixtures.
In `@tests/storage/upgrade/test_upgrade_storage.py`:
- Around line 55-61: Remove the duplicated client keyword argument passed to the
VirtualMachineRestore constructor calls; each invocation (e.g., the one creating
vm_restore with name=f"restore-snapshot-{rhel_vm_for_upgrade_a.name}" and
namespace=snapshots_for_upgrade_a.namespace and the other similar invocation
later) currently contains client=admin_client twice — keep a single
client=admin_client and remove the redundant one so the
VirtualMachineRestore(...) calls (and variables like vm_restore,
rhel_vm_for_upgrade_a, snapshots_for_upgrade_a) use only one client kwarg.
---
Outside diff comments:
In `@tests/storage/upgrade/utils.py`:
- Around line 20-27: The public context-manager helpers (notably
create_vm_for_snapshot_upgrade_tests and the other context-manager helper in
this module) lack type hints; add explicit annotations for all params and
returns using typing (e.g., import Any, Dict, Optional, Generator) and annotate
parameters as vm_name: str, namespace: str, client: Any,
storage_class_for_snapshot: str, cpu_model: str, data_source: Optional[Dict[str,
Any]] (or a more precise dict type if known), and change the return type to a
context-manager generator like Generator[Any, None, None] or Generator[Dict[str,
Any], None, None] (use the precise VM type if available) and apply the same
full-parameter/return annotations to the other helper mentioned.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 687c7ce5-f291-469c-852b-658c127810ca
📒 Files selected for processing (5)
tests/storage/upgrade/conftest.pytests/storage/upgrade/constants.pytests/storage/upgrade/test_upgrade_storage.pytests/storage/upgrade/utils.pyutilities/storage.py
💤 Files with no reviewable changes (1)
- utilities/storage.py
|
/approve |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5003 published |
|
Verification failed for PR #5003. Execution details |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5535. Overlapping filesutilities/storage.py |
|
Clean rebase detected — no code changes compared to previous head ( |
|
/lgtm |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5003 published |
|
Verification failed for PR #5003. Execution details |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5003 published |
|
Verification failed for PR #5003. Execution details |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5003 published |
|
Verification failed for PR #5003. Execution details |
|
/approve (I see only |
|
/verified That's right, only |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
echo "== callers of removed function =="
rg -n 'run_command_on_cirros_vm_and_check_output' --type py
echo "== callers of new function =="
rg -n 'assert_disk_serial' --type py
echo "== markers in tests/storage/upgrade =="
rg -n '`@pytest.mark`.(smoke|gating)' tests/storage/upgrade -A1 -B3
echo "== conftest hierarchy for tests/storage/upgrade =="
fd conftest.py tests/storage
echo "== check for smoke/gating markers referencing HOTPLUG_DISK_SERIAL or hotplug =="
rg -n 'HOTPLUG_DISK_SERIAL' --type py
echo "== check callers of create_vm_for_snapshot_upgrade_tests / create_snapshot_for_upgrade =="
rg -n 'create_vm_for_snapshot_upgrade_tests|create_snapshot_for_upgrade' tests/storage/upgradeLength of output: 1103 🏁 Script executed: #!/bin/bash
echo "== callers of removed function =="
rg -n 'run_command_on_cirros_vm_and_check_output' --type py || true
echo "== callers of new function =="
rg -n 'assert_disk_serial' --type py || true
echo "== markers in tests/storage/upgrade =="
rg -n '`@pytest.mark`.(smoke|gating)' tests/storage/upgrade -A1 -B3 || true
echo "== conftest hierarchy for tests/storage/upgrade =="
fd conftest.py tests/storage || true
echo "== check for HOTPLUG_DISK_SERIAL usage =="
rg -n 'HOTPLUG_DISK_SERIAL' --type py || true
echo "== check callers of create_vm_for_snapshot_upgrade_tests / create_snapshot_for_upgrade =="
rg -n 'create_vm_for_snapshot_upgrade_tests|create_snapshot_for_upgrade' tests/storage/upgrade || true
echo "== callers of write_file_via_ssh =="
rg -n 'def write_file_via_ssh' --type py || true
echo "== root conftest markers config =="
rg -n 'markers' pytest.ini setup.cfg pyproject.toml 2>/dev/null | head -30 || trueLength of output: 1154 🏁 Script executed: #!/bin/bash
echo "== verify file exists =="
fd storage.py utilities || true
echo "== grep disk_serial in storage.py =="
grep -n "disk_serial\|DISK_SERIAL\|cirros" utilities/storage.py || true
echo "== grep across repo for cirros_vm usage in tests/storage/upgrade =="
grep -rn "cirros" tests/storage/upgrade || true
echo "== grep write_file_via_ssh definition =="
grep -rn "def write_file_via_ssh" -r . --include=*.py || true
echo "== markers config =="
grep -rn "smoke\|gating" pytest.ini 2>/dev/null || true
find . -maxdepth 1 -iname "pytest.ini" -o -iname "setup.cfg" -o -iname "pyproject.toml" || true
echo "== list tests/storage/upgrade dir =="
ls -la tests/storage/upgrade || trueLength of output: 2245 🏁 Script executed: #!/bin/bash
echo "== callers of assert_disk_serial across repo =="
grep -rn "assert_disk_serial" --include=*.py . || true
echo "== check smoke/gating markers in hotplug/storage test dirs =="
grep -rln "`@pytest.mark.smoke`" tests/storage || true
grep -rln "`@pytest.mark.gating`" tests/storage || true
echo "== check conftest imports in tests/storage/upgrade =="
sed -n '1,40p' tests/storage/upgrade/conftest.pyLength of output: 3283 🏁 Script executed: #!/bin/bash
echo "== markers around assert_disk_serial calls in test_hotplug.py =="
sed -n '200,290p' tests/storage/test_hotplug.pyLength of output: 3796 🏁 Script executed: #!/bin/bash
grep -n "`@pytest.mark.smoke`" tests/storage/test_hotplug.py -A5 -B10Length of output: 439 🏁 Script executed: #!/bin/bash
echo "== SMOKE FILES =="
grep -rln "`@pytest.mark.smoke`" tests/storage
echo "== GATING FILES =="
grep -rln "`@pytest.mark.gating`" tests/storageLength of output: 1036
Test Execution Plan
Affected tests to run
Real tests (cluster required) Since Gating path (hotplug serial persistence): Upgrade snapshot-restore path (RHEL VM swap): ✅ Action performedReview finished.
|
…tests. (RedHatQE#2917) Change use of Cirros images coming from artifactory to RHEL coming from DataSource into upgrade tests. `tests/storage/upgrade`. We are refactoring tests by using RHEL images from DataSource, for this I have changed all the Cirros resources into upgrade tests as well as RHEL utilities and config functions I have added a function called `write_file_via_ssh` that writes a file using `run_ssh_commands` function. It has an internal import to avoid circular import errors I was facing. Programmatically I think is not a very good practice so I appreciate some comments specially in there (perhaps `utilities/storage.py` is not the best place to locate it, and other place might avoid those errors). https://issues.redhat.com/browse/CNV-69123 --------- Signed-off-by: Jose Manuel Castano <joscasta@redhat.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
for more information, see https://pre-commit.ci
Remove unused fixtures that reference non-existent update_scratch_space_sc function (removed in fbda8ef). Fix duplicate client keyword arguments in VirtualMachineRestore constructor calls. Signed-off-by: Jose Manuel Castano <joscasta@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes B008 ruff violation by using _DEFAULT_DISK_SERIAL_COMMAND instead of calling shlex.split() in function argument default. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Jose Manuel Castano <joscasta@redhat.com>
Signed-off-by: Jose Manuel Castano <joscasta@redhat.com>
|
Clean rebase detected — no code changes compared to previous head ( |
|
/approve |
|
Successfully removed PR tag: quay.io/openshift-cnv/openshift-virtualization-tests:pr-5003. |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:latest published |
Short description:
Forwardport: #2917
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:
Summary by CodeRabbit
Tests
Refactor