Skip to content

Conversation

@kshvaika
Copy link
Contributor

@kshvaika kshvaika commented Dec 5, 2025

Short description:

Replaced the use of DVs with DataSources in the snapshot tests.

More details:

Updated the snapshot tests to use DataSources (RHEL VM) instead of DVs
https://issues.redhat.com/browse/CNV-69120

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

Summary by CodeRabbit

  • Tests

    • Refactored storage tests to use RHEL-based VMs and consolidated snapshot fixtures and parametrization.
    • Updated snapshot restoration and lifecycle tests to operate on the new VM variant and generic command helper.
  • Chores

    • Added new OS flavor and instance-size constants to support RHEL test scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Walkthrough

Replaces Cirros-based test fixtures and helpers with RHEL-based equivalents: renames fixtures and parameters (cirros_* → rhel_* and snapshots_with_content → snapshot_with_content), adds RHEL instance-type/preference imports and constants, and renames the storage helper run_command_on_cirros_vm_and_check_output → run_command_on_vm_and_check_output across tests.

Changes

Cohort / File(s) Summary
Fixture and constants
tests/storage/conftest.py
Added imports for VirtualMachineClusterInstancetype and VirtualMachineClusterPreference; introduced/used OS_FLAVOR_RHEL and U1_SMALL; renamed fixtures cirros_vm_namerhel_vm_name, cirros_vm_for_snapshotrhel_vm_for_snapshot, snapshots_with_contentsnapshot_with_content; removed cirros_dv_for_snapshot_dict; updated DV templates to use data_volume_template_with_source_ref_dict and rhel10 data source fixtures.
Constants
utilities/constants.py
Added constants OS_FLAVOR_RHEL and U1_SMALL.
Storage utility
utilities/storage.py
Renamed helper run_command_on_cirros_vm_and_check_outputrun_command_on_vm_and_check_output (body unchanged).
Snapshot tests
tests/storage/snapshots/test_snapshots.py
Replaced Cirros fixtures/params with RHEL variants in parametrization and signatures; updated internal references and VM lifecycle/command calls to use rhel_vm_for_snapshot and snapshot_with_content; replaced run_command_on_cirros_vm_and_check_output with run_command_on_vm_and_check_output.
Upgrade tests
tests/storage/upgrade/test_upgrade_storage.py
Updated import and call sites to use run_command_on_vm_and_check_output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Spot-check items:

  • tests/storage/conftest.py fixture implementations for correct RHEL instance-type/preference wiring and data-source usage.
  • Ensure no remaining references to removed cirros_dv_for_snapshot_dict.
  • Verify imports and renamed helper usages in all test files compile/run.

Possibly related PRs

Suggested reviewers

  • duyanyan
  • kgoldbla
  • geetikakay
  • dshchedr
  • rnetser
  • vsibirsk

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning Description includes short description and more details with a linked issue reference. However, critical template sections like 'What this PR does / why we need it', 'Which issue(s) this PR fixes', and 'jira-ticket' are incomplete or left empty. Complete all template sections: add explanation of why DataSources are needed, explicitly list the issue (CNV-69120) being fixed, and provide the full jira-ticket URL for automation to close the ticket on merge.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately summarizes the main change: replacing DVs with DataSources in snapshot tests, which aligns with the actual code modifications across multiple test files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 323b333 and 6199b70.

📒 Files selected for processing (4)
  • tests/storage/conftest.py (6 hunks)
  • tests/storage/snapshots/test_snapshots.py (13 hunks)
  • tests/storage/upgrade/test_upgrade_storage.py (4 hunks)
  • utilities/storage.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • utilities/storage.py
🧰 Additional context used
🧠 Learnings (28)
📓 Common learnings
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:0-0
Timestamp: 2025-09-10T13:25:59.799Z
Learning: In the openshift-virtualization-tests repository, when creating DataVolume objects using ocp_resources, use `api_name="storage"` rather than the default `api_name="pvc"`.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 2469
File: utilities/sanity.py:139-142
Timestamp: 2025-11-08T07:36:57.616Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers to keep refactoring PRs (like PR #2469) strictly focused on moving/organizing code into more granular modules without adding new functionality, error handling, or behavioral changes. Such improvements should be handled in separate PRs.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 2045
File: tests/virt/cluster/vm_lifecycle/conftest.py:46-47
Timestamp: 2025-09-15T06:49:53.478Z
Learning: In the openshift-virtualization-tests repo, large fixture refactoring efforts like the golden image data source migration are handled incrementally by directory/team ownership. The virt/cluster directory is handled separately from virt/node, tests/infra, tests/storage, etc., with each area managed by relevant teams in follow-up PRs.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1723
File: conftest.py:496-502
Timestamp: 2025-08-27T12:38:26.496Z
Learning: In PR #1723, the user rnetser clarified that updating downstream string comparisons to handle DataVolume enums from StorageClassConfig is not part of the current PR scope, which focuses only on adding conformance storage class support.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/conftest.py:289-297
Timestamp: 2025-08-09T01:52:26.683Z
Learning: When user dshchedr moves working code from one location to another in the openshift-virtualization-tests repository, they prefer not to modify it unless there's a real issue, maintaining the original implementation to avoid introducing unnecessary changes.
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:215-218
Timestamp: 2025-09-08T12:38:53.119Z
Learning: In OpenShift Virtualization tests, DataSource.source points to a PVC or VolumeSnapshot object, which means data_source.source.instance.to_dict()["spec"] is valid since both PVC and VolumeSnapshot objects contain spec sections.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 1729
File: tests/virt/cluster/common_templates/utils.py:655-661
Timestamp: 2025-08-11T05:58:04.127Z
Learning: In the OpenShift Virtualization test suite (tests/virt/cluster/common_templates/utils.py), DataSource objects are pre-deployed on the cluster and validated after deployment to ensure they have source in their spec. Therefore, `data_source.source` is guaranteed to exist when checking `data_source.source.exists` in the `get_matrix_os_golden_image_data_source` function, making null-checks unnecessary.
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds architecture-specific OS_FLAVOR attributes to the Images.Cirros class (OS_FLAVOR_CIRROS for x86_64/ARM64, OS_FLAVOR_FEDORA for s390x), enabling conditional logic based on the underlying OS flavor in tests.
Learnt from: josemacassan
Repo: RedHatQE/openshift-virtualization-tests PR: 2300
File: tests/storage/online_resize/conftest.py:94-96
Timestamp: 2025-10-30T10:43:48.886Z
Learning: In tests/storage/online_resize/conftest.py, the `running_rhel_vm` fixture is intentionally designed to only invoke `running_vm(vm=rhel_vm_for_online_resize)` without returning or yielding a value. It's used as a dependency fixture to ensure the VM is running before other fixtures/tests execute, while the actual VM object is accessed via the `rhel_vm_for_online_resize` fixture.
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1411
File: utilities/os_utils.py:246-279
Timestamp: 2025-07-22T17:13:59.166Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CentOS preferences follow the format "centos-stream<version>" (e.g., "centos-stream9", "centos-stream10"). The generate_instance_type_centos_os_matrix function correctly uses regex to extract numeric versions and constructs the latest version string in the same format as the input preferences for proper comparison.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/node/workload_density/test_swap.py:71-85
Timestamp: 2025-08-09T01:46:48.039Z
Learning: In the openshift-virtualization-tests repository, user dshchedr prefers that all test setup fixtures be explicitly declared as parameters in the test method itself rather than chaining fixtures through dependencies. This makes all setup steps visible in one place at the test method level, improving test readability and making dependencies explicit, even if a fixture isn't directly used within another fixture's implementation.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/test_mtc_storage_class_migration.py:165-176
Timestamp: 2025-06-17T07:45:37.776Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers explicit fixture parameters over composite fixtures in test methods, even when there are many parameters, as they find this approach more readable and maintainable for understanding test dependencies.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 2119
File: tests/network/localnet/conftest.py:352-366
Timestamp: 2025-10-31T13:05:24.570Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, tests run sequentially by default on the same cluster (with module-scoped fixtures properly cleaned up between modules), and parallel test runs use different machines/clusters. This means cluster-scoped resources (like ClusterUserDefinedNetwork or NodeNetworkConfigurationPolicy) can safely use the same names across different test modules without risk of collision.
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:21:34.315Z
Learning: In tests/observability/metrics/conftest.py, when creating fixtures that modify shared Windows VM state (like changing nodeSelector), prefer using function scope rather than class scope to ensure ResourceEditor context managers properly restore the VM state after each test, maintaining test isolation while still reusing expensive Windows VM fixtures.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 983
File: utilities/os_utils.py:171-176
Timestamp: 2025-06-06T09:35:42.476Z
Learning: In the OpenShift Virtualization tests codebase, the CentOS image class is named "Centos" (with capital C, lowercase rest), not "CentOS". The `os_name.title()` method correctly maps "centos" to "Centos" for this class name.
Learnt from: SamAlber
Repo: RedHatQE/openshift-virtualization-tests PR: 2507
File: tests/virt/node/general/test_vmi_reset.py:26-29
Timestamp: 2025-11-19T08:13:30.263Z
Learning: In the openshift-virtualization-tests repository, user SamAlber prefers not to define fixture dependencies by chaining fixtures (adding one fixture as a parameter to another). Instead, all fixture dependencies should be explicitly declared as parameters in the test method itself, relying on parameter order to control execution sequence.
📚 Learning: 2025-06-15T13:57:10.548Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/conftest.py:358-366
Timestamp: 2025-06-15T13:57:10.548Z
Learning: In the openshift-virtualization-tests codebase, prefer using `shlex.split()` with `run_ssh_commands` function, even for commands containing shell operators like pipes. The function handles split commands correctly and this is the established pattern throughout the codebase.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
📚 Learning: 2025-05-18T09:24:43.335Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 990
File: utilities/virt.py:1704-1710
Timestamp: 2025-05-18T09:24:43.335Z
Learning: The `migrate_vm_and_verify` function in utilities/virt.py has inconsistent return behavior - it returns a VirtualMachineInstanceMigration object when wait_for_migration_success=False and returns None when wait_for_migration_success=True. This has been properly typed but should be refactored in a future PR for better API design.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
📚 Learning: 2025-10-30T10:43:48.886Z
Learnt from: josemacassan
Repo: RedHatQE/openshift-virtualization-tests PR: 2300
File: tests/storage/online_resize/conftest.py:94-96
Timestamp: 2025-10-30T10:43:48.886Z
Learning: In tests/storage/online_resize/conftest.py, the `running_rhel_vm` fixture is intentionally designed to only invoke `running_vm(vm=rhel_vm_for_online_resize)` without returning or yielding a value. It's used as a dependency fixture to ensure the VM is running before other fixtures/tests execute, while the actual VM object is accessed via the `rhel_vm_for_online_resize` fixture.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-06-18T09:21:34.315Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:21:34.315Z
Learning: In tests/observability/metrics/conftest.py, when creating fixtures that modify shared Windows VM state (like changing nodeSelector), prefer using function scope rather than class scope to ensure ResourceEditor context managers properly restore the VM state after each test, maintaining test isolation while still reusing expensive Windows VM fixtures.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-06-23T19:24:28.327Z
Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/test_mass_machine_type_transition.py:97-104
Timestamp: 2025-06-23T19:24:28.327Z
Learning: In OpenShift Virtualization machine type transition tests, the test_machine_type_transition_without_restart method with restart_required=false parameter validates that VM machine types do NOT change when the lifecycle job runs with restart disabled, so the assertion should check against the original machine type rather than the target machine type.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-08-06T13:57:51.928Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1028
File: utilities/infra.py:1249-1254
Timestamp: 2025-08-06T13:57:51.928Z
Learning: User rnetser verified that all calls to get_infrastructure() function use the admin_client parameter, confirming that signature changes requiring this parameter don't cause breaking changes in the openshift-virtualization-tests codebase.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-23T19:18:12.275Z
Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/conftest.py:142-149
Timestamp: 2025-06-23T19:18:12.275Z
Learning: In OpenShift Virtualization machine type transition tests, the kubevirt_api_lifecycle_automation_job updates VM machine types to the latest version based on a MACHINE_TYPE_GLOB pattern, and subsequent fixtures may intentionally revert the machine type to test bidirectional transition behavior.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-09-15T06:49:53.478Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 2045
File: tests/virt/cluster/vm_lifecycle/conftest.py:46-47
Timestamp: 2025-09-15T06:49:53.478Z
Learning: In the openshift-virtualization-tests repo, large fixture refactoring efforts like the golden image data source migration are handled incrementally by directory/team ownership. The virt/cluster directory is handled separately from virt/node, tests/infra, tests/storage, etc., with each area managed by relevant teams in follow-up PRs.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-08-14T10:28:22.958Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 1785
File: tests/virt/cluster/common_templates/utils.py:65-66
Timestamp: 2025-08-14T10:28:22.958Z
Learning: The restart_qemu_guest_agent_service function in tests/virt/cluster/common_templates/utils.py is only called for RHEL7 VMs, with OS version checks handled by the calling test code, not within the function itself. Guest agent functionality is verified by subsequent tests in the test class.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-06-05T11:36:25.219Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 906
File: tests/observability/metrics/conftest.py:19-19
Timestamp: 2025-06-05T11:36:25.219Z
Learning: In the openshift-virtualization-tests repository, the pyhelper_utils package (specifically pyhelper_utils.shell with run_ssh_commands) is installed and available in the test execution environment where the tests are run.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-05-26T13:36:16.136Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 584
File: tests/observability/metrics/conftest.py:1136-1136
Timestamp: 2025-05-26T13:36:16.136Z
Learning: For Windows VM testing in metrics tests, the `verify_wsl2_guest_works(vm=vm)` call in the `windows_vm_for_test` fixture uses a 60-second timeout as a deliberate "fail fast" validation. This upfront check prevents more expensive failures later since Windows VM deployment is time-consuming, and WSL2 functionality is critical for the Windows VM tests to work properly.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-09-03T07:22:50.446Z
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1946
File: tests/infrastructure/instance_types/supported_os/test_windows_os.py:27-28
Timestamp: 2025-09-03T07:22:50.446Z
Learning: In tests/infrastructure/instance_types/supported_os/test_windows_os.py, Windows guest images are configured with SSH support (likely through WSL2), so running_vm() should keep the default check_ssh_connectivity=True to verify SSH connectivity is working properly in the Windows guest images.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-17T14:45:39.291Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1224
File: tests/storage/storage_migration/conftest.py:419-425
Timestamp: 2025-06-17T14:45:39.291Z
Learning: In tests/storage/storage_migration/conftest.py, the PowerShell command using shlex.split() with properly escaped quotes works correctly and does not break the command structure when passed to run_ssh_commands.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-18T09:31:06.311Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:31:06.311Z
Learning: In tests/observability/metrics/conftest.py, ResourceEditor context managers automatically restore VM configuration when the context exits, including nodeSelector patches. The fixture pattern with `with ResourceEditor(patches={vm: {...}})` followed by `yield` properly restores the VM to its original state without requiring manual teardown logic.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-05-28T10:50:56.122Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 954
File: tests/storage/storage_migration/conftest.py:264-269
Timestamp: 2025-05-28T10:50:56.122Z
Learning: In the openshift-virtualization-tests codebase, cleanup pytest fixtures like `deleted_old_dvs_of_stopped_vms`, `deleted_completed_virt_launcher_source_pod`, and `deleted_old_dvs_of_online_vms` do not require yield statements. These fixtures perform cleanup operations and work correctly without yielding values.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-09-03T07:23:37.045Z
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1946
File: tests/infrastructure/instance_types/supported_os/test_windows_os.py:30-31
Timestamp: 2025-09-03T07:23:37.045Z
Learning: In tests/infrastructure/instance_types/supported_os/test_windows_os.py, test_vm_deletion should depend on test_create_vm (not test_start_vm) to ensure resource cleanup happens even if the VM fails to start, preventing resource leaks in the test environment.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-05-27T11:44:14.859Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 584
File: tests/observability/metrics/test_network_metrics.py:62-76
Timestamp: 2025-05-27T11:44:14.859Z
Learning: The windows_vm_for_test fixture in tests/observability/metrics/conftest.py does not have a request argument, so it cannot be parametrized using pytest.mark.parametrize with indirect=True. This is different from vm_for_test fixture which accepts parameters through parametrization.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-10-16T12:47:04.521Z
Learnt from: rlobillo
Repo: RedHatQE/openshift-virtualization-tests PR: 2249
File: tests/install_upgrade_operators/must_gather/test_must_gather.py:428-441
Timestamp: 2025-10-16T12:47:04.521Z
Learning: In openshift-virtualization-tests repository, DataVolumes in the openshift-virtualization-os-images namespace are volatile resources managed by DataImportCron. They can be created/destroyed between must-gather collection listing and file retrieval, requiring FileNotFoundError exception handling in test_crd_resources to skip these volatile resources gracefully while still validating DataVolumes in other namespaces. There is no pytest_generate_tests hook that filters out datavolumes from test parametrization.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-09-29T20:33:51.007Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1932
File: tests/virt/node/migration_and_maintenance/conftest.py:65-72
Timestamp: 2025-09-29T20:33:51.007Z
Learning: In tests/virt/node/migration_and_maintenance/conftest.py, the added_vm_cpu_limit fixture doesn't require ResourceEditor as a context manager because it's the final test to modify the vm_for_multifd_test VM before teardown, so restoration of CPU limits is unnecessary overhead as confirmed by maintainer dshchedr.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-08-09T01:46:48.039Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/node/workload_density/test_swap.py:71-85
Timestamp: 2025-08-09T01:46:48.039Z
Learning: In the openshift-virtualization-tests repository, user dshchedr prefers that all test setup fixtures be explicitly declared as parameters in the test method itself rather than chaining fixtures through dependencies. This makes all setup steps visible in one place at the test method level, improving test readability and making dependencies explicit, even if a fixture isn't directly used within another fixture's implementation.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-10T13:25:59.799Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:0-0
Timestamp: 2025-09-10T13:25:59.799Z
Learning: In the openshift-virtualization-tests repository, when creating DataVolume objects using ocp_resources, use `api_name="storage"` rather than the default `api_name="pvc"`.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-06-17T07:45:37.776Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/test_mtc_storage_class_migration.py:165-176
Timestamp: 2025-06-17T07:45:37.776Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers explicit fixture parameters over composite fixtures in test methods, even when there are many parameters, as they find this approach more readable and maintainable for understanding test dependencies.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-28T14:43:07.181Z
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-06-18T09:19:05.769Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/test_vms_metrics.py:129-137
Timestamp: 2025-06-18T09:19:05.769Z
Learning: For Windows VM testing in tests/observability/metrics/test_vms_metrics.py, it's acceptable to have more fixture parameters than typical pylint recommendations when reusing expensive Windows VM fixtures for performance. Windows VMs take a long time to deploy, so reusing fixtures like windows_vm_for_test and adding labels via windows_vm_with_low_bandwidth_migration_policy is preferred over creating separate fixtures that would require additional VM deployments.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-05-21T09:41:46.532Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 954
File: tests/storage/storage_migration/conftest.py:156-176
Timestamp: 2025-05-21T09:41:46.532Z
Learning: In the RedHatQE/openshift-virtualization-tests codebase, the pattern of calling to_dict() on a DataVolume object and then accessing dv.res to populate data_volume_template is the preferred approach rather than building the template dict explicitly.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-17T14:02:24.619Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 1702
File: tests/chaos/oadp/conftest.py:23-45
Timestamp: 2025-09-17T14:02:24.619Z
Learning: In the openshift-virtualization-tests repository, VirtualMachineForTests class automatically generates unique VM names when generate_unique_name=True (default). It uses utilities.infra.unique_name() which appends a timestamp to create names like "vm-oadp-chaos-{timestamp}", so hardcoded VM names in fixtures don't cause collisions during parallel test execution.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-08-20T23:57:48.380Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1840
File: tests/virt/node/workload_density/test_swap.py:88-89
Timestamp: 2025-08-20T23:57:48.380Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CNV installation and health are verified by sanity tests before other tests run, so hco_namespace is guaranteed to exist in the testing environment. Defensive programming against nil hco_namespace scenarios is not needed in fixtures.

Applied to files:

  • tests/storage/conftest.py
🧬 Code graph analysis (3)
tests/storage/upgrade/test_upgrade_storage.py (1)
utilities/storage.py (1)
  • run_command_on_vm_and_check_output (637-640)
tests/storage/snapshots/test_snapshots.py (3)
utilities/storage.py (1)
  • run_command_on_vm_and_check_output (637-640)
tests/storage/conftest.py (1)
  • rhel_vm_for_snapshot (461-481)
tests/storage/snapshots/utils.py (2)
  • expected_output_after_restore (10-27)
  • fail_to_create_snapshot_no_permissions (30-41)
tests/storage/conftest.py (1)
utilities/storage.py (3)
  • data_volume_template_with_source_ref_dict (566-585)
  • vm_snapshot (1116-1125)
  • write_file (627-634)
🪛 Ruff (0.14.7)
tests/storage/snapshots/test_snapshots.py

375-375: Unused function argument: permissions_for_dv

(ARG001)

tests/storage/conftest.py

487-487: Unused function argument: namespace

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: build-container
  • GitHub Check: tox
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
🔇 Additional comments (21)
tests/storage/upgrade/test_upgrade_storage.py (4)

19-21: LGTM!

The import update to run_command_on_vm_and_check_output is consistent with the renamed function in utilities/storage.py. The function name change from Cirros-specific to generic is appropriate since it works with any VM type via console.


75-79: Consistent usage of renamed helper function.

The call site correctly uses the renamed run_command_on_vm_and_check_output function with unchanged parameters. Note that this test still uses cirros_vm_for_upgrade_a fixture which is separate from the snapshot-related fixtures being refactored in this PR.


150-154: Correct function call update.


176-180: Correct function call update.

tests/storage/conftest.py (6)

24-29: LGTM!

The imports for VirtualMachineClusterInstancetype and VirtualMachineClusterPreference are correctly added to support the RHEL VM configuration with instance types.


54-58: Appropriate constants for RHEL VM configuration.

OS_FLAVOR_RHEL and U1_SMALL are correctly imported to configure the RHEL-based VM fixtures.


70-74: Good transition to DataSource-based template.

Using data_volume_template_with_source_ref_dict aligns with the PR objective of using DataSources instead of DataVolumes directly.


429-431: Fixture renamed to reflect RHEL usage.

The rename from cirros_vm_name to rhel_vm_name is consistent with the overall refactoring.


460-481: Well-structured RHEL VM fixture.

The rhel_vm_for_snapshot fixture correctly:

  • Uses rhel10_data_source_scope_session as the data source
  • Configures instance type (U1_SMALL) and preference (rhel.10)
  • Uses data_volume_template_with_source_ref_dict for DataSource-based provisioning
  • Sets OS_FLAVOR_RHEL for proper OS identification

484-528: Remove this review comment—namespace parameter is intentionally declared for fixture dependency ordering.

This fixture parameter declaration is idiomatic in this repository for ensuring proper setup order, as confirmed by established patterns in similar fixtures throughout the codebase. Removing it would not improve code clarity and is not aligned with the repository's testing practices.

tests/storage/snapshots/test_snapshots.py (11)

29-29: LGTM!

Import correctly updated to use the renamed run_command_on_vm_and_check_output function.


50-113: Consistent parameter renaming across all test cases.

The parametrize decorator correctly updates:

  • cirros_vm_namerhel_vm_name
  • snapshots_with_contentsnapshot_with_content

All test parameter values and indirect references are properly updated.


115-137: Test body correctly updated for RHEL VM.

All references to cirros_vm_for_snapshot and snapshots_with_content are properly replaced with rhel_vm_for_snapshot and snapshot_with_content. The test logic remains unchanged.


139-183: Correctly refactored test_restore_snapshot_while_vm_is_running.

The fixture parameters and body references are consistently updated to use RHEL-based fixtures.


185-214: Correctly refactored test_fail_restore_vm_with_unprivileged_client.


216-253: Correctly refactored test_restore_same_snapshot_twice.


256-273: Correctly refactored test_remove_vm_with_snapshots.


276-306: Correctly refactored test_remove_snapshots_while_vm_is_running.


337-358: Correctly refactored test_fail_to_snapshot_with_unprivileged_client_no_permissions.


361-383: permissions_for_dv is a dependency fixture for side effects.

Static analysis flags permissions_for_dv as unused (ARG001), but this is a false positive. Based on repository patterns, this fixture is intentionally included to set up DV permissions before the test executes—it's used for its side effects, not its return value. This aligns with the established pattern where all setup fixtures are explicitly declared as parameters in the test method.


386-436: Windows VM tests correctly left unchanged.

The Windows-related snapshot tests (test_online_windows_vm_successful_restore and test_write_to_file_while_snapshot) appropriately remain unchanged as they use separate Windows-specific fixtures.


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-3
Copy link
Contributor

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
  • Pre-commit Checks: pre-commit runs automatically if .pre-commit-config.yaml exists
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified

📋 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)

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and 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 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, or conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • jpeimer
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Ahmad-Hafe
  • RoniKishner
  • dalia-frank
  • dshchedr
  • duyanyan
  • geetikakay
  • hmeir
  • josemacassan
  • jpeimer
  • kgoldbla
  • kshvaika
  • rlobillo
  • rnetser
  • stesrn
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

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

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (f0cfa42) to head (6199b70).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3011   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files          25       25           
  Lines        2157     2157           
=======================================
  Hits         2120     2120           
  Misses         37       37           
Flag Coverage Δ
utilities 98.28% <ø> (ø)

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.

Copy link

@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: 0

🧹 Nitpick comments (1)
tests/storage/conftest.py (1)

485-528: Consider removing unused namespace parameter.

The namespace parameter on line 487 is not used in the fixture body. The fixture accesses the namespace through rhel_vm_for_snapshot.namespace instead.

Apply this diff to remove the unused parameter:

 def snapshot_with_content(
     request,
-    namespace,
     admin_client,
     rhel_vm_for_snapshot,
 ):
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63f56dc and 323b333.

📒 Files selected for processing (4)
  • tests/storage/conftest.py (6 hunks)
  • tests/storage/snapshots/test_snapshots.py (13 hunks)
  • tests/storage/upgrade/test_upgrade_storage.py (4 hunks)
  • utilities/storage.py (1 hunks)
🧰 Additional context used
🧠 Learnings (28)
📓 Common learnings
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:0-0
Timestamp: 2025-09-10T13:25:59.799Z
Learning: In the openshift-virtualization-tests repository, when creating DataVolume objects using ocp_resources, use `api_name="storage"` rather than the default `api_name="pvc"`.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 2469
File: utilities/sanity.py:139-142
Timestamp: 2025-11-08T07:36:57.616Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers to keep refactoring PRs (like PR #2469) strictly focused on moving/organizing code into more granular modules without adding new functionality, error handling, or behavioral changes. Such improvements should be handled in separate PRs.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 2045
File: tests/virt/cluster/vm_lifecycle/conftest.py:46-47
Timestamp: 2025-09-15T06:49:53.478Z
Learning: In the openshift-virtualization-tests repo, large fixture refactoring efforts like the golden image data source migration are handled incrementally by directory/team ownership. The virt/cluster directory is handled separately from virt/node, tests/infra, tests/storage, etc., with each area managed by relevant teams in follow-up PRs.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:215-218
Timestamp: 2025-09-08T12:38:53.119Z
Learning: In OpenShift Virtualization tests, DataSource.source points to a PVC or VolumeSnapshot object, which means data_source.source.instance.to_dict()["spec"] is valid since both PVC and VolumeSnapshot objects contain spec sections.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 1729
File: tests/virt/cluster/common_templates/utils.py:655-661
Timestamp: 2025-08-11T05:58:04.127Z
Learning: In the OpenShift Virtualization test suite (tests/virt/cluster/common_templates/utils.py), DataSource objects are pre-deployed on the cluster and validated after deployment to ensure they have source in their spec. Therefore, `data_source.source` is guaranteed to exist when checking `data_source.source.exists` in the `get_matrix_os_golden_image_data_source` function, making null-checks unnecessary.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/conftest.py:289-297
Timestamp: 2025-08-09T01:52:26.683Z
Learning: When user dshchedr moves working code from one location to another in the openshift-virtualization-tests repository, they prefer not to modify it unless there's a real issue, maintaining the original implementation to avoid introducing unnecessary changes.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1723
File: conftest.py:496-502
Timestamp: 2025-08-27T12:38:26.496Z
Learning: In PR #1723, the user rnetser clarified that updating downstream string comparisons to handle DataVolume enums from StorageClassConfig is not part of the current PR scope, which focuses only on adding conformance storage class support.
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.
Learnt from: rlobillo
Repo: RedHatQE/openshift-virtualization-tests PR: 2249
File: tests/install_upgrade_operators/must_gather/test_must_gather.py:428-441
Timestamp: 2025-10-16T12:47:04.521Z
Learning: In openshift-virtualization-tests repository, DataVolumes in the openshift-virtualization-os-images namespace are volatile resources managed by DataImportCron. They can be created/destroyed between must-gather collection listing and file retrieval, requiring FileNotFoundError exception handling in test_crd_resources to skip these volatile resources gracefully while still validating DataVolumes in other namespaces. There is no pytest_generate_tests hook that filters out datavolumes from test parametrization.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/constants.py:4-5
Timestamp: 2025-06-08T08:05:46.691Z
Learning: In the openshift-virtualization-tests repository's storage migration tests, `/dev/sda` is the correct device path for hotplugged volumes in the VM testing environment, even though it might typically be associated with the root disk in other contexts.
Learnt from: josemacassan
Repo: RedHatQE/openshift-virtualization-tests PR: 2300
File: tests/storage/online_resize/conftest.py:94-96
Timestamp: 2025-10-30T10:43:48.886Z
Learning: In tests/storage/online_resize/conftest.py, the `running_rhel_vm` fixture is intentionally designed to only invoke `running_vm(vm=rhel_vm_for_online_resize)` without returning or yielding a value. It's used as a dependency fixture to ensure the VM is running before other fixtures/tests execute, while the actual VM object is accessed via the `rhel_vm_for_online_resize` fixture.
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds architecture-specific OS_FLAVOR attributes to the Images.Cirros class (OS_FLAVOR_CIRROS for x86_64/ARM64, OS_FLAVOR_FEDORA for s390x), enabling conditional logic based on the underlying OS flavor in tests.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1932
File: tests/virt/node/migration_and_maintenance/conftest.py:57-64
Timestamp: 2025-09-08T21:34:28.924Z
Learning: In OpenShift Virtualization tests, MigrationPolicy fixtures should use static names rather than unique suffixes to enable collision detection. If parallel test runs collide on cluster-scoped resource names like MigrationPolicy, it's better to know about the collision rather than hide it with unique naming, as confirmed by maintainer dshchedr.
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 2838
File: .github/workflows/net-utils-builder-staging.yml:37-37
Timestamp: 2025-11-25T01:56:54.902Z
Learning: In the openshift-virtualization-tests repository, when renaming container images that are built and used by GitHub Actions workflows, the changes must be done sequentially: first merge the workflow files (.github/workflows/) that update the image name in the CI/CD pipelines, then update the code references (like constants.py and manifest files) in a follow-up PR. This prevents the old workflow from running with mismatched image names during the transition.
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 1702
File: tests/chaos/oadp/conftest.py:23-45
Timestamp: 2025-09-17T14:02:24.619Z
Learning: In the openshift-virtualization-tests repository, VirtualMachineForTests class automatically generates unique VM names when generate_unique_name=True (default). It uses utilities.infra.unique_name() which appends a timestamp to create names like "vm-oadp-chaos-{timestamp}", so hardcoded VM names in fixtures don't cause collisions during parallel test execution.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/test_mtc_storage_class_migration.py:165-176
Timestamp: 2025-06-17T07:45:37.776Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers explicit fixture parameters over composite fixtures in test methods, even when there are many parameters, as they find this approach more readable and maintainable for understanding test dependencies.
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:21:34.315Z
Learning: In tests/observability/metrics/conftest.py, when creating fixtures that modify shared Windows VM state (like changing nodeSelector), prefer using function scope rather than class scope to ensure ResourceEditor context managers properly restore the VM state after each test, maintaining test isolation while still reusing expensive Windows VM fixtures.
📚 Learning: 2025-06-15T13:57:10.548Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/conftest.py:358-366
Timestamp: 2025-06-15T13:57:10.548Z
Learning: In the openshift-virtualization-tests codebase, prefer using `shlex.split()` with `run_ssh_commands` function, even for commands containing shell operators like pipes. The function handles split commands correctly and this is the established pattern throughout the codebase.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
📚 Learning: 2025-10-30T10:43:48.886Z
Learnt from: josemacassan
Repo: RedHatQE/openshift-virtualization-tests PR: 2300
File: tests/storage/online_resize/conftest.py:94-96
Timestamp: 2025-10-30T10:43:48.886Z
Learning: In tests/storage/online_resize/conftest.py, the `running_rhel_vm` fixture is intentionally designed to only invoke `running_vm(vm=rhel_vm_for_online_resize)` without returning or yielding a value. It's used as a dependency fixture to ensure the VM is running before other fixtures/tests execute, while the actual VM object is accessed via the `rhel_vm_for_online_resize` fixture.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-05-18T09:24:43.335Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 990
File: utilities/virt.py:1704-1710
Timestamp: 2025-05-18T09:24:43.335Z
Learning: The `migrate_vm_and_verify` function in utilities/virt.py has inconsistent return behavior - it returns a VirtualMachineInstanceMigration object when wait_for_migration_success=False and returns None when wait_for_migration_success=True. This has been properly typed but should be refactored in a future PR for better API design.

Applied to files:

  • tests/storage/upgrade/test_upgrade_storage.py
📚 Learning: 2025-08-06T13:57:51.928Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1028
File: utilities/infra.py:1249-1254
Timestamp: 2025-08-06T13:57:51.928Z
Learning: User rnetser verified that all calls to get_infrastructure() function use the admin_client parameter, confirming that signature changes requiring this parameter don't cause breaking changes in the openshift-virtualization-tests codebase.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-18T09:21:34.315Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:21:34.315Z
Learning: In tests/observability/metrics/conftest.py, when creating fixtures that modify shared Windows VM state (like changing nodeSelector), prefer using function scope rather than class scope to ensure ResourceEditor context managers properly restore the VM state after each test, maintaining test isolation while still reusing expensive Windows VM fixtures.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-06-23T19:24:28.327Z
Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/test_mass_machine_type_transition.py:97-104
Timestamp: 2025-06-23T19:24:28.327Z
Learning: In OpenShift Virtualization machine type transition tests, the test_machine_type_transition_without_restart method with restart_required=false parameter validates that VM machine types do NOT change when the lifecycle job runs with restart disabled, so the assertion should check against the original machine type rather than the target machine type.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-23T19:18:12.275Z
Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/conftest.py:142-149
Timestamp: 2025-06-23T19:18:12.275Z
Learning: In OpenShift Virtualization machine type transition tests, the kubevirt_api_lifecycle_automation_job updates VM machine types to the latest version based on a MACHINE_TYPE_GLOB pattern, and subsequent fixtures may intentionally revert the machine type to test bidirectional transition behavior.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-08-14T10:28:22.958Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 1785
File: tests/virt/cluster/common_templates/utils.py:65-66
Timestamp: 2025-08-14T10:28:22.958Z
Learning: The restart_qemu_guest_agent_service function in tests/virt/cluster/common_templates/utils.py is only called for RHEL7 VMs, with OS version checks handled by the calling test code, not within the function itself. Guest agent functionality is verified by subsequent tests in the test class.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-06-05T11:36:25.219Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 906
File: tests/observability/metrics/conftest.py:19-19
Timestamp: 2025-06-05T11:36:25.219Z
Learning: In the openshift-virtualization-tests repository, the pyhelper_utils package (specifically pyhelper_utils.shell with run_ssh_commands) is installed and available in the test execution environment where the tests are run.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-05-26T13:36:16.136Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 584
File: tests/observability/metrics/conftest.py:1136-1136
Timestamp: 2025-05-26T13:36:16.136Z
Learning: For Windows VM testing in metrics tests, the `verify_wsl2_guest_works(vm=vm)` call in the `windows_vm_for_test` fixture uses a 60-second timeout as a deliberate "fail fast" validation. This upfront check prevents more expensive failures later since Windows VM deployment is time-consuming, and WSL2 functionality is critical for the Windows VM tests to work properly.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-09-03T07:22:50.446Z
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1946
File: tests/infrastructure/instance_types/supported_os/test_windows_os.py:27-28
Timestamp: 2025-09-03T07:22:50.446Z
Learning: In tests/infrastructure/instance_types/supported_os/test_windows_os.py, Windows guest images are configured with SSH support (likely through WSL2), so running_vm() should keep the default check_ssh_connectivity=True to verify SSH connectivity is working properly in the Windows guest images.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-17T14:45:39.291Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1224
File: tests/storage/storage_migration/conftest.py:419-425
Timestamp: 2025-06-17T14:45:39.291Z
Learning: In tests/storage/storage_migration/conftest.py, the PowerShell command using shlex.split() with properly escaped quotes works correctly and does not break the command structure when passed to run_ssh_commands.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-06-18T09:31:06.311Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/conftest.py:1065-1077
Timestamp: 2025-06-18T09:31:06.311Z
Learning: In tests/observability/metrics/conftest.py, ResourceEditor context managers automatically restore VM configuration when the context exits, including nodeSelector patches. The fixture pattern with `with ResourceEditor(patches={vm: {...}})` followed by `yield` properly restores the VM to its original state without requiring manual teardown logic.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-05-28T10:50:56.122Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 954
File: tests/storage/storage_migration/conftest.py:264-269
Timestamp: 2025-05-28T10:50:56.122Z
Learning: In the openshift-virtualization-tests codebase, cleanup pytest fixtures like `deleted_old_dvs_of_stopped_vms`, `deleted_completed_virt_launcher_source_pod`, and `deleted_old_dvs_of_online_vms` do not require yield statements. These fixtures perform cleanup operations and work correctly without yielding values.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-09-03T07:23:37.045Z
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1946
File: tests/infrastructure/instance_types/supported_os/test_windows_os.py:30-31
Timestamp: 2025-09-03T07:23:37.045Z
Learning: In tests/infrastructure/instance_types/supported_os/test_windows_os.py, test_vm_deletion should depend on test_create_vm (not test_start_vm) to ensure resource cleanup happens even if the VM fails to start, preventing resource leaks in the test environment.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-05-27T11:44:14.859Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 584
File: tests/observability/metrics/test_network_metrics.py:62-76
Timestamp: 2025-05-27T11:44:14.859Z
Learning: The windows_vm_for_test fixture in tests/observability/metrics/conftest.py does not have a request argument, so it cannot be parametrized using pytest.mark.parametrize with indirect=True. This is different from vm_for_test fixture which accepts parameters through parametrization.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-10-16T12:47:04.521Z
Learnt from: rlobillo
Repo: RedHatQE/openshift-virtualization-tests PR: 2249
File: tests/install_upgrade_operators/must_gather/test_must_gather.py:428-441
Timestamp: 2025-10-16T12:47:04.521Z
Learning: In openshift-virtualization-tests repository, DataVolumes in the openshift-virtualization-os-images namespace are volatile resources managed by DataImportCron. They can be created/destroyed between must-gather collection listing and file retrieval, requiring FileNotFoundError exception handling in test_crd_resources to skip these volatile resources gracefully while still validating DataVolumes in other namespaces. There is no pytest_generate_tests hook that filters out datavolumes from test parametrization.

Applied to files:

  • tests/storage/snapshots/test_snapshots.py
  • tests/storage/conftest.py
📚 Learning: 2025-09-15T06:49:53.478Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 2045
File: tests/virt/cluster/vm_lifecycle/conftest.py:46-47
Timestamp: 2025-09-15T06:49:53.478Z
Learning: In the openshift-virtualization-tests repo, large fixture refactoring efforts like the golden image data source migration are handled incrementally by directory/team ownership. The virt/cluster directory is handled separately from virt/node, tests/infra, tests/storage, etc., with each area managed by relevant teams in follow-up PRs.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-28T14:43:07.181Z
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-10T13:25:59.799Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:0-0
Timestamp: 2025-09-10T13:25:59.799Z
Learning: In the openshift-virtualization-tests repository, when creating DataVolume objects using ocp_resources, use `api_name="storage"` rather than the default `api_name="pvc"`.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-29T20:33:51.007Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1932
File: tests/virt/node/migration_and_maintenance/conftest.py:65-72
Timestamp: 2025-09-29T20:33:51.007Z
Learning: In tests/virt/node/migration_and_maintenance/conftest.py, the added_vm_cpu_limit fixture doesn't require ResourceEditor as a context manager because it's the final test to modify the vm_for_multifd_test VM before teardown, so restoration of CPU limits is unnecessary overhead as confirmed by maintainer dshchedr.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-08-09T01:46:48.039Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/node/workload_density/test_swap.py:71-85
Timestamp: 2025-08-09T01:46:48.039Z
Learning: In the openshift-virtualization-tests repository, user dshchedr prefers that all test setup fixtures be explicitly declared as parameters in the test method itself rather than chaining fixtures through dependencies. This makes all setup steps visible in one place at the test method level, improving test readability and making dependencies explicit, even if a fixture isn't directly used within another fixture's implementation.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-28T14:43:07.181Z
Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds architecture-specific OS_FLAVOR attributes to the Images.Cirros class (OS_FLAVOR_CIRROS for x86_64/ARM64, OS_FLAVOR_FEDORA for s390x), enabling conditional logic based on the underlying OS flavor in tests.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-06-18T09:19:05.769Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 1166
File: tests/observability/metrics/test_vms_metrics.py:129-137
Timestamp: 2025-06-18T09:19:05.769Z
Learning: For Windows VM testing in tests/observability/metrics/test_vms_metrics.py, it's acceptable to have more fixture parameters than typical pylint recommendations when reusing expensive Windows VM fixtures for performance. Windows VMs take a long time to deploy, so reusing fixtures like windows_vm_for_test and adding labels via windows_vm_with_low_bandwidth_migration_policy is preferred over creating separate fixtures that would require additional VM deployments.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-05-21T09:41:46.532Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 954
File: tests/storage/storage_migration/conftest.py:156-176
Timestamp: 2025-05-21T09:41:46.532Z
Learning: In the RedHatQE/openshift-virtualization-tests codebase, the pattern of calling to_dict() on a DataVolume object and then accessing dv.res to populate data_volume_template is the preferred approach rather than building the template dict explicitly.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-09-17T14:02:24.619Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 1702
File: tests/chaos/oadp/conftest.py:23-45
Timestamp: 2025-09-17T14:02:24.619Z
Learning: In the openshift-virtualization-tests repository, VirtualMachineForTests class automatically generates unique VM names when generate_unique_name=True (default). It uses utilities.infra.unique_name() which appends a timestamp to create names like "vm-oadp-chaos-{timestamp}", so hardcoded VM names in fixtures don't cause collisions during parallel test execution.

Applied to files:

  • tests/storage/conftest.py
📚 Learning: 2025-08-20T23:57:48.380Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1840
File: tests/virt/node/workload_density/test_swap.py:88-89
Timestamp: 2025-08-20T23:57:48.380Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CNV installation and health are verified by sanity tests before other tests run, so hco_namespace is guaranteed to exist in the testing environment. Defensive programming against nil hco_namespace scenarios is not needed in fixtures.

Applied to files:

  • tests/storage/conftest.py
🧬 Code graph analysis (3)
tests/storage/upgrade/test_upgrade_storage.py (1)
utilities/storage.py (1)
  • run_command_on_vm_and_check_output (637-640)
tests/storage/snapshots/test_snapshots.py (3)
utilities/storage.py (1)
  • run_command_on_vm_and_check_output (637-640)
tests/storage/conftest.py (2)
  • rhel_vm_for_snapshot (461-481)
  • snapshot_with_content (485-528)
tests/storage/snapshots/utils.py (2)
  • expected_output_after_restore (10-27)
  • fail_to_create_snapshot_no_permissions (30-41)
tests/storage/conftest.py (2)
utilities/storage.py (2)
  • data_volume_template_with_source_ref_dict (566-585)
  • write_file (627-634)
tests/conftest.py (3)
  • namespace (661-674)
  • rhel10_data_source_scope_session (885-891)
  • snapshot_storage_class_name_scope_module (2475-2478)
🪛 Ruff (0.14.7)
tests/storage/snapshots/test_snapshots.py

375-375: Unused function argument: permissions_for_dv

(ARG001)

tests/storage/conftest.py

487-487: Unused function argument: namespace

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: build-container
  • GitHub Check: tox
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
🔇 Additional comments (12)
utilities/storage.py (1)

637-641: LGTM! Generic function naming improves reusability.

The rename from run_command_on_cirros_vm_and_check_output to run_command_on_vm_and_check_output removes VM-type-specific naming, making the function more versatile and aligned with its actual behavior.

tests/storage/upgrade/test_upgrade_storage.py (2)

19-19: LGTM! Import updated to match renamed function.

The import correctly reflects the function rename in utilities/storage.py.


75-79: LGTM! Function call updated consistently.

The call to run_command_on_vm_and_check_output is consistent with the renamed function.

tests/storage/conftest.py (5)

24-29: LGTM! Necessary imports for RHEL VM support.

The imports for VirtualMachineClusterInstancetype and VirtualMachineClusterPreference are correctly added to support the RHEL-based VM fixtures.


54-58: LGTM! Constants added for RHEL configuration.

The OS_FLAVOR_RHEL and U1_SMALL constants are appropriately added to support RHEL VM configuration.


71-71: LGTM! Helper function import for DataSource support.

The import of data_volume_template_with_source_ref_dict enables the fixture to create DataVolume templates from DataSources.


430-431: LGTM! Fixture renamed to reflect RHEL VM usage.

The rename from cirros_vm_name to rhel_vm_name correctly aligns the fixture name with its new purpose.


461-481: LGTM! Fixture successfully migrated to DataSource-based RHEL VM.

The migration from Cirros to RHEL VM using DataSource is well-implemented:

  • Uses data_volume_template_with_source_ref_dict helper with rhel10_data_source_scope_session
  • Properly configured with VirtualMachineClusterInstancetype and VirtualMachineClusterPreference
  • Correctly uses OS_FLAVOR_RHEL for the VM flavor
tests/storage/snapshots/test_snapshots.py (4)

29-29: LGTM! Import updated to match renamed function.

The import correctly reflects the function rename in utilities/storage.py.


50-113: LGTM! Test parametrization updated consistently.

The parametrization correctly updates from Cirros to RHEL VM terminology:

  • cirros_vm_namerhel_vm_name
  • snapshots_with_contentsnapshot_with_content

All test parameters are consistently updated across all test cases.


115-137: LGTM! Test implementation updated for RHEL VM fixtures.

The test correctly uses:

  • rhel_vm_for_snapshot instead of cirros_vm_for_snapshot
  • snapshot_with_content instead of snapshots_with_content
  • run_command_on_vm_and_check_output instead of the Cirros-specific variant

All references are consistent with the fixture changes.


373-383: LGTM! The permissions_for_dv fixture is used correctly.

The static analysis warning about unused permissions_for_dv is a false positive. This fixture is used for its side effect (setting up permissions for the test), which is a common pytest pattern. The fixture doesn't need to be referenced in the test body.

@kshvaika
Copy link
Contributor Author

kshvaika commented Dec 5, 2025

/verified

  • All the test from the module have been run:
    uv run pytest -o log_cli=true -s --skip-deprecated-api-test -rsx --cluster-sanity-skip-check tests/storage/snapshots/test_snapshots.py::TestRestoreSnapshots --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization
    uv run pytest -o log_cli=true -s --skip-deprecated-api-test -rsx --cluster-sanity-skip-check tests/storage/snapshots/test_snapshots.py --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization
  • some specific tests have been run:
    uv run pytest -o log_cli=true -s --skip-deprecated-api-test -rsx --cluster-sanity-skip-check -k test_remove_vm_with_snapshots --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization
  • in addition, windows tests have been run as well, though the changes don't touch them:
    uv run pytest -o log_cli=true -s --skip-deprecated-api-test -rsx --cluster-sanity-skip-check tests/storage/snapshots/test_snapshots.py -k "test_online_windows_vm_successful_restore or test_write_to_file_while_snapshot" --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization

@openshift-virtualization-qe-bot-3
Copy link
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST respond with a review comment on the Files Changed tab, NOT as a regular PR comment.
If it cannot be on the 1st line of the 1st file, add it to any other changed file.

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will create a change request comment on the 1st line of the 1st file in the pr with the test execution plan.
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, and fixture inheritance
  5. Detect new tests introduced in the PR

Your deliverable:
Your change request comment will be based on the following requirements:

Test Execution Plan

  • 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 specific marker(s) can be used to cover multiple cases.

Guidelines:

  • Include only tests directly affected by the changes
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name if only specific tests are needed
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Do not add a follow-up comment in the PR, only the change request one

@coderabbitai
Copy link

coderabbitai bot commented Dec 5, 2025

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all test files that import or use run_command_on_vm_and_check_output or the old function name
echo "=== Searching for usages of run_command_on_vm_and_check_output ==="
rg -n "run_command_on_vm_and_check_output|run_command_on_cirros_vm_and_check_output" --type=py -g 'tests/**/*.py'

echo -e "\n=== Searching for usages of renamed fixtures: rhel_vm_for_snapshot, snapshot_with_content, rhel_vm_name ==="
rg -n "rhel_vm_for_snapshot|snapshot_with_content|rhel_vm_name" --type=py -g 'tests/**/*.py'

echo -e "\n=== Checking test_upgrade_storage.py for test functions ==="
rg -n "^\s*def test_" tests/storage/upgrade/test_upgrade_storage.py

echo -e "\n=== Checking if old fixtures are still referenced anywhere ==="
rg -n "cirros_vm_for_snapshot|snapshots_with_content|cirros_vm_name" --type=py -g 'tests/**/*.py'

Length of output: 8587


🏁 Script executed:

#!/bin/bash
# Get context around the usages of run_command_on_vm_and_check_output in test_upgrade_storage.py
echo "=== Checking which tests in test_upgrade_storage.py use run_command_on_vm_and_check_output ==="
rg -n -B 10 "run_command_on_vm_and_check_output" tests/storage/upgrade/test_upgrade_storage.py | grep -E "def test_|run_command_on_vm_and_check_output"

echo -e "\n=== Checking vm_export test files ==="
fd "test_.*\.py" tests/storage/vm_export/

echo -e "\n=== Checking if vm_export tests use the renamed fixtures or function ==="
rg -n "run_command_on_vm_and_check_output|run_command_on_cirros_vm_and_check_output" tests/storage/vm_export/ --type=py

echo -e "\n=== Checking the full context of test_upgrade_storage.py to see fixture dependencies ==="
cat tests/storage/upgrade/test_upgrade_storage.py | head -100

Length of output: 4423


@openshift-virtualization-qe-bot-3, I'll analyze the PR changes and create a test execution plan.

Based on my analysis of the modified files, here are the key changes:

  1. Fixture Changes (tests/storage/conftest.py): Migrated from Cirros to RHEL VM fixtures
  2. Function Rename (utilities/storage.py): run_command_on_cirros_vm_and_check_outputrun_command_on_vm_and_check_output
  3. Test Updates: Updated snapshot tests to use new fixtures and renamed function

Test Execution Plan:

Since you've already run tests/storage/snapshots/test_snapshots.py successfully, the remaining affected tests are:

  • tests/storage/upgrade/test_upgrade_storage.py::TestUpgradeStorage::test_vm_snapshot_restore_before_upgrade - Uses renamed function
  • tests/storage/upgrade/test_upgrade_storage.py::TestUpgradeStorage::test_vm_snapshot_restore_check_after_upgrade - Uses renamed function
  • tests/storage/upgrade/test_upgrade_storage.py::TestUpgradeStorage::test_vm_snapshot_restore_create_after_upgrade - Uses renamed function

Note: The upgrade tests have special dependencies and markers (@pytest.mark.upgrade, @pytest.mark.ocp_upgrade) and may require an actual upgrade scenario to execute meaningfully. The function rename is a low-risk cosmetic change (identical signature and behavior), so if running these tests is impractical outside of an upgrade context, the risk is minimal given that the snapshot tests have been verified.

I'll now post this as a review comment on the Files Changed tab as requested.


🧠 Learnings used
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 2469
File: utilities/sanity.py:139-142
Timestamp: 2025-11-08T07:36:57.616Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers to keep refactoring PRs (like PR #2469) strictly focused on moving/organizing code into more granular modules without adding new functionality, error handling, or behavioral changes. Such improvements should be handled in separate PRs.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-09-29T19:05:24.987Z
Learning: The test execution plan for PR #1904 focuses on cluster-type conditional logic where nmstate functionality is bypassed on cloud clusters (Azure/AWS) but fully functional on bare-metal/PSI clusters, requiring different test strategies for each environment type.

Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 2045
File: tests/virt/cluster/vm_lifecycle/conftest.py:46-47
Timestamp: 2025-09-15T06:49:53.478Z
Learning: In the openshift-virtualization-tests repo, large fixture refactoring efforts like the golden image data source migration are handled incrementally by directory/team ownership. The virt/cluster directory is handled separately from virt/node, tests/infra, tests/storage, etc., with each area managed by relevant teams in follow-up PRs.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-09-29T19:05:24.987Z
Learning: For PR #1904 test execution, the critical validation point is test_connectivity_over_migration_between_localnet_vms which should fail gracefully on cloud clusters but pass on bare-metal/PSI clusters, representing the core nmstate conditional logic functionality.

Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/conftest.py:83-97
Timestamp: 2025-06-23T19:19:31.961Z
Learning: In OpenShift Virtualization mass machine type transition tests, the kubevirt_api_lifecycle_automation_job requires cluster-admin privileges to function properly, as confirmed by the test maintainer akri3i.

Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 1716
File: tests/virt/conftest.py:289-297
Timestamp: 2025-08-09T01:52:26.683Z
Learning: When user dshchedr moves working code from one location to another in the openshift-virtualization-tests repository, they prefer not to modify it unless there's a real issue, maintaining the original implementation to avoid introducing unnecessary changes.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1236
File: conftest.py:539-557
Timestamp: 2025-06-18T13:26:04.504Z
Learning: In the openshift-virtualization-tests repository, PR #1236 intentionally limits error extraction to the setup phase only in the pytest_runtest_makereport hook. The scope is deliberately restricted to setup failures, not all test phases.

Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds architecture-specific OS_FLAVOR attributes to the Images.Cirros class (OS_FLAVOR_CIRROS for x86_64/ARM64, OS_FLAVOR_FEDORA for s390x), enabling conditional logic based on the underlying OS flavor in tests.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:0-0
Timestamp: 2025-09-10T13:25:59.799Z
Learning: In the openshift-virtualization-tests repository, when creating DataVolume objects using ocp_resources, use `api_name="storage"` rather than the default `api_name="pvc"`.

Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR #2199 depends on PR #2139 which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.

Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 1776
File: libs/net/node_network.py:25-31
Timestamp: 2025-08-20T23:43:28.117Z
Learning: In the RedHatQE/openshift-virtualization-tests project, servolkov's team always uses bare metal (BM) clusters with IPv4 setup in their testing environment, making defensive checks for IPv4 data presence potentially redundant in their networking code.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/test_mtc_storage_class_migration.py:165-176
Timestamp: 2025-06-17T07:45:37.776Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers explicit fixture parameters over composite fixtures in test methods, even when there are many parameters, as they find this approach more readable and maintainable for understanding test dependencies.

Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/conftest.py:24-64
Timestamp: 2025-06-23T19:28:20.281Z
Learning: In OpenShift Virtualization mass machine type transition tests, the machine type glob pattern "pc-q35-rhel8.*.*" is intentionally hard-coded in the kubevirt_api_lifecycle_automation_job as it's used only once for this specific test case, with plans to update it in the future if the job needs to support other machine types.

Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1411
File: utilities/os_utils.py:246-279
Timestamp: 2025-07-22T17:13:59.166Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CentOS preferences follow the format "centos-stream<version>" (e.g., "centos-stream9", "centos-stream10"). The generate_instance_type_centos_os_matrix function correctly uses regex to extract numeric versions and constructs the latest version string in the same format as the input preferences for proper comparison.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 2701
File: .github/scripts/coderabbit_workflow.py:45-46
Timestamp: 2025-11-27T11:45:54.224Z
Learning: In the openshift-virtualization-tests repository, when using the PyGithub library or similar API clients, rnetser prefers to rely on API-level validation rather than adding redundant client-side input validation, since the API will handle validation and raise appropriate errors.

Learnt from: SiboWang1997
Repo: RedHatQE/openshift-virtualization-tests PR: 1566
File: tests/global_config_x86_64.py:29-29
Timestamp: 2025-07-25T01:59:02.180Z
Learning: In the openshift-virtualization-tests repo, the s390x architecture still relies on Fedora 41 images, while only x86_64 is updated to Fedora 42 in PR #1566.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 1723
File: conftest.py:496-502
Timestamp: 2025-08-27T12:38:26.496Z
Learning: In PR #1723, the user rnetser clarified that updating downstream string comparisons to handle DataVolume enums from StorageClassConfig is not part of the current PR scope, which focuses only on adding conformance storage class support.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 2014
File: tests/storage/cdi_clone/test_clone.py:215-218
Timestamp: 2025-09-08T12:38:53.119Z
Learning: In OpenShift Virtualization tests, DataSource.source points to a PVC or VolumeSnapshot object, which means data_source.source.instance.to_dict()["spec"] is valid since both PVC and VolumeSnapshot objects contain spec sections.

Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 1729
File: tests/virt/cluster/common_templates/utils.py:655-661
Timestamp: 2025-08-11T05:58:04.127Z
Learning: In the OpenShift Virtualization test suite (tests/virt/cluster/common_templates/utils.py), DataSource objects are pre-deployed on the cluster and validated after deployment to ensure they have source in their spec. Therefore, `data_source.source` is guaranteed to exist when checking `data_source.source.exists` in the `get_matrix_os_golden_image_data_source` function, making null-checks unnecessary.

@kshvaika
Copy link
Contributor Author

kshvaika commented Dec 5, 2025

/retest tox

"spec": cirros_dv_for_snapshot_dict["spec"],
},
os_flavor=OS_FLAVOR_RHEL,
vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL),
Copy link
Collaborator

Choose a reason for hiding this comment

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

client is missing

},
os_flavor=OS_FLAVOR_RHEL,
vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL),
vm_preference=VirtualMachineClusterPreference(name="rhel.10"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto
and please use RHEL10_PREFERENCE constant

):
for idx in range(len(snapshots_to_restore_idx)):
snap_idx = snapshots_to_restore_idx[idx]
with VirtualMachineRestore(
Copy link
Collaborator

Choose a reason for hiding this comment

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

if you're already modifying this code, please add client

The default behavior of the fixture is creating an offline
snapshot unless {online_vm = True} declared in the test
"""
snapshot unless {online_vm = True} declared in the test"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
snapshot unless {online_vm = True} declared in the test"""
snapshot unless {online_vm = True} declared in the test
"""

)
if is_online_test:
cirros_vm_for_snapshot.start(wait=True)
rhel_vm_for_snapshot.start(wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why we were using start() here, but it's better to use running_vm, as it waits for VM to be fully booted

Suggested change
rhel_vm_for_snapshot.start(wait=True)
running_vm(vm=rhel_vm_for_snapshot)

cirros_vm_for_snapshot.start(wait=True)
run_command_on_cirros_vm_and_check_output(
vm=cirros_vm_for_snapshot,
rhel_vm_for_snapshot.start(wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace with running_vm() in all places (unless there's a good reason not to)

Suggested change
rhel_vm_for_snapshot.start(wait=True)
running_vm(vm=rhel_vm_for_snapshot)



def run_command_on_cirros_vm_and_check_output(vm, command, expected_result):
def run_command_on_vm_and_check_output(vm, command, expected_result):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please create a new function under tests/storage/snapshots/utils.py
Upgrade tests will be changed separately.

Please try using run_ssh_commands instead of console. You can see an example in test_vmexport_snapshot_manifests (in vmexport test it only validates the content of one file, but for the snapshot tests we want to keep the validation of the ls command output).

snapshot_with_content,
):
cirros_vm_for_snapshot.start(wait=True)
rhel_vm_for_snapshot.start(wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Comment on lines 502 to +508
write_file(
vm=cirros_vm_for_snapshot,
vm=rhel_vm_for_snapshot,
filename=f"{before_snap_index}.txt",
content=before_snap_index,
)
if is_online_test:
cirros_vm_for_snapshot.start(wait=True)
rhel_vm_for_snapshot.start(wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

write_file stops the VM by default, and then we start it if is_online_test (doesn't seem very efficient).
Could you change that - so if is_online_test - pass write_file(..., stop_vm=False)

Copy link
Contributor

Choose a reason for hiding this comment

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

And actually, let's write the file via ssh, like in rhel_vm_for_snapshot_with_content (instead of console)

Comment on lines 480 to 481
) as vm:
yield vm
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to add running_vm(vm=vm) here

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