WIP: [Storage] Automate testing of predictable PVC/DV names after VM restore#4780
WIP: [Storage] Automate testing of predictable PVC/DV names after VM restore#4780acinko-rh wants to merge 55 commits into
Conversation
Signed-off-by: Adam Cinko <acinko@redhat.com>
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR modernizes test imports and adds fixture-backed test coverage for VM snapshot restore behavior. The changes introduce a new fixture to create deterministic test resources and a parameterized test that validates naming conventions when restoring DataVolumes and PersistentVolumeClaims with the ChangesVM Restore Naming Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (2 errors)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. |
|
/wip |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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/test_predictible_names.py`:
- Around line 59-101: The fixture using vm_restore_with_prefix_policy currently
yields without deleting the created restored VM (restored_vm_name), so
DataVolumes/PVCs leak; after yielding, locate the created VM (use
VirtualMachineForTests(name=restored_vm_name, namespace=namespace.name,
client=admin_client) or check via the API) and delete it (if exists, call
delete(wait=True)) so that its owned DVs/PVCs are cascade-removed; alternatively
wrap the restored VM in a VirtualMachineForTests context manager for teardown to
ensure cleanup.
- Line 161: The Polarion ID used in the pytest marker is invalid ("CNV-80304b");
update the pytest.mark.polarion decorator in
tests/storage/test_predictible_names.py (the pytest-marked test using
`@pytest.mark.polarion`) to use a valid CNV-NNNNN format—either change
"CNV-80304b" to the numeric "CNV-80304" if appropriate or replace it with a
newly issued valid Polarion ID so test reporting will map correctly.
- Around line 1-5: The PR is missing required template sections per
.github/pull_request_template.md; update the pull request description to include
the sections "##### What this PR does / why we need it:", "##### Which issue(s)
this PR fixes:", "##### Special notes for reviewer:", and "##### jira-ticket:"
with meaningful content (not just duplicating the brief description) so
reviewers can see motivation, linked issues (e.g., CNV-80304), any reviewer
instructions, and the jira-ticket; reference the test file name
tests/storage/test_predictible_names.py in the "What this PR does" section to
explain the change and why it’s needed.
- Around line 139-159: Extract the duplicated assertion block into a private
helper (e.g., a `@staticmethod` named _assert_predictable_names) that accepts the
restore dict (vm_snapshot_restore_dicts_scope_function), reads
source_dv_name/source_pvc_name/restored_vm_name/restored_dv_name/restored_pvc_name/volumeRestorePolicy,
computes expected_restored_dv_name and expected_restored_pvc_name using
f"{restored_vm_name}-{source_*}"[:63], and asserts volume_restore_policy ==
VOLUME_RESTORE_POLICY and the two restored name equality checks; then replace
the two identical inline blocks (the ones using source_dv_name, source_pvc_name,
restored_vm_name, restored_dv_name, restored_pvc_name, volumeRestorePolicy) with
calls to
self._assert_predictable_names(vm_snapshot_restore_dicts_scope_function).
- Around line 113-115: The test function
test_restored_dv_and_pvc_names_have_vm_prefix_default_names currently both
declares the fixture vm_snapshot_restore_dicts_scope_function as a function
parameter and also decorates the test with
`@pytest.mark.usefixtures`("vm_snapshot_restore_dicts_scope_function"); remove the
redundant decorator
`@pytest.mark.usefixtures`("vm_snapshot_restore_dicts_scope_function") so the
fixture's return value (accessed inside the test) is provided via the function
parameter only and the test continues to use
vm_snapshot_restore_dicts_scope_function within lines ~139–144.
In `@tests/storage/utils.py`:
- Around line 548-552: The function signature currently exposes dry_run as a
positional boolean, leaves **kwargs untyped, and uses an incomplete Generator
type; update the signature to make dry_run keyword-only and optional by adding a
'*' before it and setting dry_run: bool = False, change **kwargs to **kwargs:
Any, and update the return annotation to Generator[VirtualMachineRestore, None,
None]; also ensure Any is imported from typing (or typing_extensions) if not
already.
🪄 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: 84bf76c2-6c1a-4b27-bd09-212c6fcd4010
📒 Files selected for processing (3)
tests/storage/constants.pytests/storage/test_predictible_names.pytests/storage/utils.py
|
D/S test |
|
Clean rebase detected — no code changes compared to previous head ( |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4780 +/- ##
=======================================
Coverage 98.67% 98.67%
=======================================
Files 25 25
Lines 2485 2487 +2
=======================================
+ Hits 2452 2454 +2
Misses 33 33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
D/S test |
|
/wip cancel |
|
D/S test |
| if rhel_vm_for_snapshot.ready: | ||
| rhel_vm_for_snapshot.stop(wait=True) | ||
|
|
||
| source_volume_name = rhel_vm_for_snapshot.instance.spec.template.spec.volumes[0].name | ||
| restored_vm_name = f"{rhel_vm_for_snapshot.name}-restored" | ||
|
|
||
| with vm_restore_with_prefix_policy( | ||
| name=f"{restored_vm_name}-restore", | ||
| namespace=rhel_vm_for_snapshot.namespace, | ||
| vm_name=restored_vm_name, | ||
| snapshot_name=snapshot_with_content[0].name, | ||
| client=admin_client, | ||
| prefix_policy="PrefixTargetName", | ||
| ) as vm_restore: | ||
| vm_restore.wait_restore_done(timeout=TIMEOUT_10MIN) | ||
|
|
There was a problem hiding this comment.
all of this should be moved to setup
test itself does only validation/assert
There was a problem hiding this comment.
setup moved to a fixture, assertion logic moved to the test case
| class VirtualMachineRestoreWithPolicy(VirtualMachineRestore): | ||
| """VirtualMachineRestore with custom volumeRestorePolicy.""" | ||
|
|
||
| def __init__(self, volume_restore_policy: str, **kwargs): | ||
| """ | ||
| Initialize VirtualMachineRestore with volumeRestorePolicy. | ||
|
|
||
| Args: | ||
| volume_restore_policy: Policy for volume restoration (e.g., "PrefixTargetName") | ||
| **kwargs: Arguments for VirtualMachineRestore parent class | ||
| """ | ||
| super().__init__(**kwargs) | ||
| self.volume_restore_policy = volume_restore_policy | ||
|
|
||
| def to_dict(self): | ||
| super().to_dict() | ||
| self.res["spec"]["volumeRestorePolicy"] = self.volume_restore_policy |
There was a problem hiding this comment.
should be updated in python-wrapper https://github.com/RedHatQE/openshift-python-wrapper/blob/main/ocp_resources/virtual_machine_restore.py#L26
(my mistake, i added the attribute name same as in VMClone object)
There was a problem hiding this comment.
removed this altogether, I can see it in the python wrapper
| from collections.abc import Generator | ||
| from contextlib import contextmanager | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
| from kubernetes.client.rest import ApiException | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.virtual_machine_restore import VirtualMachineRestore |
There was a problem hiding this comment.
please move imports needed only for typechecking under if TYPE_CHECKING
There was a problem hiding this comment.
removed the subclass and the helper method as they were redundant, so these imports have been removed
|
Clean rebase detected — no code changes compared to previous head ( |
|
D/S test |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/snapshots/test_snapshots.py`:
- Around line 269-310: Add STD-first traceability metadata to this new feature
test by including an STP link (or, if unavailable, an RFE/Jira epic link) in the
test's docstring area: place the link in the module docstring at the top of
tests/storage/snapshots/test_snapshots.py or in the class or the
test_restore_snapshot_with_predictable_names test's docstring so the test
(test_restore_snapshot_with_predictable_names) clearly references the STP or
fallback ticket identifier as required by the repository workflow.
- Around line 289-290: The test incorrectly assumes the restored data volume is
volumes[0]; update the logic around rhel_vm_for_snapshot and
restore_status.restores to pick the actual restored volume instead: find the
volume in rhel_vm_for_snapshot.instance.spec.template.spec.volumes whose entry
contains dataVolume or persistentVolumeClaim, or (preferably) match the restore
entry in restore_status.restores[0] by its volumeName and use that name to set
source_volume_name and restored_vm_name; adjust any other occurrences (the block
around lines where source_volume_name and restored_vm_name are set and the
similar code at 303-307) to use this matched volume selection.
In `@tests/storage/snapshots/utils.py`:
- Around line 69-72: VirtualMachineRestoreWithPolicy.to_dict currently calls
super().to_dict() only for its side effects and mutates self.res but does not
return anything, breaking the contract used elsewhere that expects a dict;
change the method to return the result of super().to_dict() (or return self.res
after mutation) so callers like utilities.network (where self.res =
self.to_dict()) receive the resource dict; update
VirtualMachineRestoreWithPolicy.to_dict to return the dict from
super().to_dict() (or return self.res) after setting
self.res["spec"]["volumeRestorePolicy"].
🪄 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: b2d60b06-ee97-4e9d-b900-e5014f142e7f
📒 Files selected for processing (3)
tests/storage/snapshots/test_snapshots.pytests/storage/snapshots/utils.pytests/storage/utils.py
💤 Files with no reviewable changes (1)
- tests/storage/utils.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Never add linter suppressions like# noqa,# type: ignore, or# pylint: disable. Fix the code instead. If you believe a rule is wrong, ask the user for explicit approval.
Search the codebase for existing implementations before writing new code. Checkutilities/,libs/,tests/, andpyproject.tomldependencies. Never duplicate logic—extract to shared modules. Usepyhelper_utils.shell.run_commandfor shell commands instead ofsubprocess.run, and useocp-resourcesclasses instead of raw YAML dicts.
Type hints are MANDATORY. Use mypy strict mode inlibs/and all new public functions under utilities. UseTYPE_CHECKINGfor type-only imports to avoid runtime overhead and circular imports.
Write Google-format docstrings for all public functions with non-obvious return values or side effects.
Always useuv runto execute commands. Never executepython,pip,pytest,tox, orpre-commitdirectly. Useuv run python,uv run pytest,uv run tox,uv run pre-commit, anduv addfor package installation.
Always use absolute imports. Never use relative imports.
Prefer specific imports usingfrom module import funcfor functions and constants. Usefrom package import module(thenmodule.Name) when retaining the module name meaningfully improves readability. Never use bareimport modulewithout afromclause.
Always use named arguments for function calls with more than one argument.
Never use single-letter variable names. Always use descriptive, meaningful names.
No dead code. Every function, variable, and fixture must be used or removed. Code marked with# skip-unused-codeis excluded from dead code analysis (enforced via custom ruff plugin).
Prefer direct attribute access usingfoo.attr. Save to variables only when reusing the same attribute multiple times improves readability or extracting clarifies intent.
Imports must always be at the top of the module. Do not import inside functions.
No defensive programming. Fail...
Files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Use pytest assertions:
assert actual == expected. Never useself.assertEqual(). Include failure messages:assert condition, 'descriptive message explaining failure'.
Files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
**
⚙️ CodeRabbit configuration file
**: ## PR Template Validation
Check the PR description for required sections from.github/pull_request_template.md.
Required sections (must be present, even if empty):
##### What this PR does / why we need it:— MUST be present AND have meaningful content.
Flag as HIGH if the section is missing, empty, whitespace-only, contains only HTML comments,
or contains only placeholder tokens such asTBD,TBA,N/A,-,—,none, or..##### Which issue(s) this PR fixes:— must be present (may be empty)##### Special notes for reviewer:— must be present (may be empty)##### jira-ticket:— must be present (may be empty)
If any required section is absent, orWhat this PR does / why we need it:has no content,
flag it as HIGH severity and ask the author to restore the missing template section(s).
Files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
tests/**/test_*.py
📄 CodeRabbit inference engine (AGENTS.md)
tests/**/test_*.py: New feature tests must follow the STD-first workflow: (1) STP (Software Test Plan) reviewed and approved, (2) STD (Software Test Description) placeholder tests with docstrings and__test__ = Falsereviewed, (3) Implementation only after STD review. Never submit test implementation without prior STD review.
Every new feature test file must include an STP link in the module, class, or test docstring. If there is no STP, the module, class, or test docstring must include a link to the RFE or Jira epic (not support cases) for coverage tracking.
All new tests must have markers. Check pytest.ini for available markers. Tier marker semantics: tier1 = operator/infrastructure tests, tier2 = customer use case tests, tier3 = complex/hardware/platform-specific/time-consuming tests. Assign the correct tier based on what the test validates.tier2is implicit and added automatically to all tests without exclusion markers—do NOT add it explicitly. Team markers (network,storage,virt,iuo,observability,infrastructure,data_protection,chaos) are implicit based on directory location—do NOT add them explicitly.
Each test must verify ONE aspect only with a single purpose. Tests must be independent. Usepytest-dependencyonly when test B requires side effects from test A (e.g., cluster-wide configuration). For resource dependencies, use shared fixtures instead. When using@pytest.mark.dependency, include a comment explaining WHY the dependency exists.
Always use@pytest.mark.usefixtureswhen fixture return value is not used by test. This is REQUIRED.
__test__ = Falseis ALLOWED only for STD placeholder tests that contain only docstrings describing expected behavior with no implementation code (no assertions, no test logic). Once a test has implementation code (assertions, test logic, setup/teardown),__test__ = Falsemust be removed.
STD (Software Test Description) docstrings must follow the format in `docs/SOFTWARE_TEST_DESCRIPTION.m...
Files:
tests/storage/snapshots/test_snapshots.py
🧠 Learnings (59)
📚 Learning: 2025-12-15T12:33:06.686Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 3024
File: tests/network/connectivity/utils.py:17-17
Timestamp: 2025-12-15T12:33:06.686Z
Learning: In the test suite, ensure the ipv6_network_data fixture returns a factory function (Callable) and that all call sites invoke it to obtain the actual data dict, i.e., use ipv6_network_data() at call sites. This enables future extensibility for configuring secondary interfaces' IP addresses without changing call sites. Apply this pattern to all Python test files under tests.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-14T04:08:23.032Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 3404
File: tests/virt/upgrade/conftest.py:291-301
Timestamp: 2026-01-14T04:08:23.032Z
Learning: In the openshift-virtualization-tests repository, when using VirtualMachine objects from ocp-resources in tests, if vm.ready is True, vm.vmi is guaranteed to exist. Therefore, you can access vm.vmi.instance.status or vm.vmi attributes without additional defensive checks (e.g., if vm.vmi: ...). Do not rely on vm.vmi being present when vm.ready may be False; guard those code paths accordingly. This guideline applies to tests under tests/ (notably in virt/upgrade/conftest.py and related test modules) and should be followed for any code paths that assume vm.vmi exists only when vm.ready is True.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-18T09:44:17.044Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 3376
File: tests/network/general/test_ip_family_services.py:96-96
Timestamp: 2026-01-18T09:44:17.044Z
Learning: In the openshift-virtualization-tests repository, function-scoped fixtures must use pytest.fixture() with empty parentheses (not pytest.fixture without parentheses). This repo follows this convention despite Ruff PT001. Apply this consistently to all Python test files under tests/ (not just this one) to maintain repository-wide consistency.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-27T17:18:49.973Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 3619
File: tests/network/user_defined_network/test_user_defined_network.py:97-97
Timestamp: 2026-01-27T17:18:49.973Z
Learning: In tests that exercise lookup_iface_status_ip from libs.net.vmspec, rely on the function's built-in descriptive error messages for failures. Do not add extra assertion messages for IP presence checks using this function; instead, assert on the function behavior or catch its exceptions as appropriate. This reduces duplication and clarifies failures.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-23T16:31:34.505Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/unittests/test_os_utils.py:333-425
Timestamp: 2026-02-23T16:31:34.505Z
Learning: In integration/functional tests located under the tests/ directory, require assertion failure messages using the pattern: assert condition, "descriptive message". For unit tests under utilities/unittests/, rely on pytest's assertion introspection and descriptive test names; explicit failure messages are not required. This guidance helps maintain clear diagnostics for integration tests while keeping unit tests concise and leveraging pytest's built-in introspection.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-25T10:52:09.679Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3873
File: tests/network/localnet/test_non_udn_localnet.py:7-9
Timestamp: 2026-02-25T10:52:09.679Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, networking infrastructure requirements (nmstate, localnet bridge mappings, NIC availability) are not automatically tier3; they are considered standard test environment capabilities. Only tests with truly platform-specific, time-consuming, or bare-metal requirements should be marked as tier3. Apply this guidance to all Python tests under tests/, including tests/network/localnet/test_non_udn_localnet.py, ensuring tier3 designation is reserved for genuine platform-specific or complex scenarios rather than general networking infra necessities.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-19T10:36:59.023Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4147
File: tests/network/upgrade/test_upgrade_network.py:166-177
Timestamp: 2026-03-19T10:36:59.023Z
Learning: In this repository’s pytest-based test files (under `tests/`), do not flag unused test method parameters/fixture arguments for removal when the parameters are intentionally kept only to enforce pytest fixture dependency ordering (e.g., an unused fixture like `bridge_on_one_node`). Treat this as an intentional convention consistent with other fixture definitions in the codebase, and do not open follow-up review issues for those unused parameters.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-25T11:24:07.687Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 4267
File: tests/storage/cross_cluster_live_migration/conftest.py:530-531
Timestamp: 2026-03-25T11:24:07.687Z
Learning: In this repo’s OpenShift virtualization tests, it is a standard pattern to call `to_dict()` on `ocp-resources` objects (e.g., `DataVolume`) without using its return value. The call is used only to populate the object’s `res` attribute, which is then read or mutated (e.g., `dv.res[...] = ...`). Do not flag this as an unused return value and do not request adding an inline comment just to justify it, since maintainers treat this behavior as consistent and intentional across the codebase.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-31T08:35:22.802Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4318
File: tests/network/bandwidth/test_bandwidth.py:1-3
Timestamp: 2026-03-31T08:35:22.802Z
Learning: In this repository, when reviewing Python test modules under tests/, only require an STP link in the module docstring for STD (new-feature) tests. If the test module is a support-exception test tied to SUPPORTEX-* tickets (e.g., SUPPORTEX-29574) and therefore has no STP, do not flag missing STP links in the module docstring.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-31T10:39:33.409Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4318
File: tests/network/l2_bridge/bandwidth/test_bandwidth.py:5-27
Timestamp: 2026-03-31T10:39:33.409Z
Learning: In this repository’s pytest suite, some STD (Standard Definition) placeholder tests under the `tests/` directory are intentionally implemented as docstring-only functions. They must be marked with `__test__ = False` immediately after the function definition (e.g., `test_x.__test__ = False`) to prevent pytest from collecting/executing them until the real test body exists. During code review, do not flag these as missing executable coverage and do not recommend removing or changing the `__test__ = False` setting when the placeholder pattern matches this accepted STD approach.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-02T09:03:57.004Z
Learnt from: ema-aka-young
Repo: RedHatQE/openshift-virtualization-tests PR: 4342
File: tests/storage/cdi_config/test_cdi_config.py:195-205
Timestamp: 2026-04-02T09:03:57.004Z
Learning: When calling `utilities.storage.get_dv_size_from_datasource()` in this repo, do not require an extra `None` guard for its return value if the `datasource` argument originates from a fixture that uses `ensure_exists=True` (e.g., `fedora_data_source_scope_module`). Those fixtures guarantee the datasource exists and provides a valid size, and other repo usages follow the same pattern without additional fail-fast/`None` checks; therefore, reviewers should not flag missing `None` guarding in this specific fixture-driven scenario.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-14T13:00:57.514Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:32-32
Timestamp: 2026-04-14T13:00:57.514Z
Learning: In this repository’s pytest quarantine tests, do not flag or change `pytest.mark.jira(<id>, run=False)` as ineffective. `run=False` on `pytest.mark.jira()` is intentionally handled by the `pytest_jira` plugin, which conditionally skips the test when the referenced Jira issue is open. This is the correct behavior for **Category 1 (Product Bug)** quarantines; the `pytest.mark.xfail(run=False)` approach is reserved for **Category 2 (Automation Issue)** quarantines only (as documented in `docs/QUARANTINE_GUIDELINES.md`).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-14T16:15:31.065Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:0-0
Timestamp: 2026-04-14T16:15:31.065Z
Learning: When reviewing Python tests, avoid redundant parentheses around f-strings in `pytest.mark.xfail` decorators. Prefer `pytest.mark.xfail(reason=f"...", run=False)` over `pytest.mark.xfail(reason=(f"..."), run=False)`, and flag/suggest removing the extra wrapping parentheses where found.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-14T16:15:33.012Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:32-32
Timestamp: 2026-04-14T16:15:33.012Z
Learning: For this repository (RedHatQE/openshift-virtualization-tests), when reviewing any PR with "Quarantine" in the title or a `quarantine` label, check compliance with `docs/QUARANTINE_GUIDELINES.md` in any affected pytest test code. Specifically: (1) For Category 1 (Product Bug), require `pytest.mark.jira("CNV-XXXXX", run=False)` and do not suggest replacing it with `xfail` (the `pytest_jira` plugin conditionally skips when the Jira issue is open). (2) For Category 2 (Automation Issue), require `pytest.mark.xfail(run=False, reason=...)` (pytest handles the skip). During review, flag quarantine PRs that use the wrong marker/category, omit a Jira ticket reference for Category 1, or use `run=False` in an incorrect context; raise these compliance questions even if later resolution confirms the marker was correct.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-21T19:08:39.771Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 4542
File: tests/network/libs/bgp.py:333-354
Timestamp: 2026-04-21T19:08:39.771Z
Learning: In this codebase, when using `retry` imported from `timeout_sampler`, the decorated function must indicate success by returning a truthy value. The decorator retries until it encounters a truthy `sample` (i.e., it does `if sample: return sample`). Therefore, ensure `retry`-decorated functions include `return True` (or another truthy value) on success; avoid removing/altering it on the assumption that the caller ignores the return value. If the function returns `None` (or has no return statement), it will keep retrying and typically end in `TimeoutExpiredError`.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-26T11:44:20.150Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4578
File: tests/network/localnet/nad_ref_change/test_nad_ref_change.py:18-18
Timestamp: 2026-04-26T11:44:20.150Z
Learning: In this repository’s STD (Standard Test Definition) PRs under `tests/**`, it’s expected that Polarion IDs may be placeholders (e.g., `pytest.mark.polarion("CNV-00000")`) while the test scenarios are still being agreed upon. If the test scenario is disabled for the moment (e.g., the scenario/module sets `__test__ = False`), reviewers should not treat placeholder Polarion IDs as a blocking issue. Real Polarion IDs should be filled in before or during the implementation PR.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-04-27T15:40:31.167Z
Learnt from: dalia-frank
Repo: RedHatQE/openshift-virtualization-tests PR: 4603
File: tests/data_protection/oadp/test_velero.py:101-130
Timestamp: 2026-04-27T15:40:31.167Z
Learning: When reviewing tests in RedHatQE/openshift-virtualization-tests, do not require STD-first workflow and STP/RFE/Jira-epic module docstring/traceability for tests that are being re-enabled after previously being blocked by a product bug (e.g., after a CNV Jira bug fix). Only enforce these STD-first and STP/RFE/Jira-epic module docstring requirements for genuinely new feature tests; previously blocked tests that are now unblocked/re-enabled should not be flagged as missing traceability.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-03T14:47:13.096Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4569
File: tests/network/user_defined_network/rhel9_rhel10_cluster/test_connectivity.py:17-51
Timestamp: 2026-05-03T14:47:13.096Z
Learning: In this repository’s pytest suite (files under `tests/`), it is acceptable to have identically named `test_*` functions in different test modules (e.g., same function name in different `.../test_*.py` files). Do not request renaming solely to disambiguate function names across modules, since pytest node IDs remain unique and unambiguous due to the module path prefix. The team accepts the trade-off that `pytest -k <name>` will match tests in all modules containing that name.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-05T17:27:32.109Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:145-145
Timestamp: 2026-05-05T17:27:32.109Z
Learning: In this repo’s Python tests, `pyhelper_utils.shell.run_command` defaults to `check=True` (so it raises `subprocess.CalledProcessError` on non-zero exit). Therefore, don’t flag missing return-code handling/rc checks for bare calls like `run_command(...)` (or calls where `check` is not explicitly provided). Only flag cases where `check=False` is explicitly passed and the exit code/return value is ignored or not otherwise handled.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-05T18:28:01.097Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:142-146
Timestamp: 2026-05-05T18:28:01.097Z
Learning: In this repository, ignore Ruff rule PT022 in Python test files under `tests/`. If PT022 is triggered in a `pytest` fixture that uses `yield` but has no teardown code, treat it as an acceptable low-value nitpick and do not suggest changing the fixture to use `return` or otherwise flag the issue during code review.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-07T12:34:42.589Z
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 4162
File: tests/install_upgrade_operators/crypto_policy/utils.py:320-323
Timestamp: 2026-05-07T12:34:42.589Z
Learning: When parsing the output of `openssl list -tls-groups`, remember it prints TLS group names on a single colon-separated line (e.g., `secp256r1:X25519:SecP256r1MLKEM768:...`). Parse individual TLS group names by splitting on `:` (e.g., `output.strip().split(':')`) rather than assuming one group per line. In code that specifically handles this `openssl list -tls-groups` output, do not flag `split(':')` as incorrect.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-08T12:31:26.895Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4772
File: tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py:20-22
Timestamp: 2026-05-08T12:31:26.895Z
Learning: In RedHatQE/openshift-virtualization-tests, any pytest test already marked with `pytest.mark.mixed_os_nodes` must not also be marked with `pytest.mark.tier3`. The `mixed_os_nodes` marker is responsible for both environment filtering and selecting the dedicated execution lane for dual-stream (mixed RHCOS 9 + RHCOS 10) cluster scenarios. Apply this rule to all test modules under `tests/` that use the `mixed_os_nodes` marker (e.g., `tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py`).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-12T18:18:20.607Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/test_migration_stuntime.py:51-51
Timestamp: 2026-05-12T18:18:20.607Z
Learning: In RedHatQE/openshift-virtualization-tests, do not flag or suggest removing Python linter suppressions `# noqa: PID001` in files under `tests/`. `PID001` is a custom flake8 rule enforced by the Polarion ID checker plugin (not a standard Ruff rule). Therefore Ruff’s `RUF102` (“Invalid rule code in `# noqa`: PID001”) is a false positive in this repo. These `# noqa: PID001` comments are intentional and effective, commonly used on base-class `test_*` methods where the Polarion markers are defined on subclass overrides.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2025-12-22T16:27:40.244Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3196
File: tests/network/upgrade/test_upgrade_network.py:4-4
Timestamp: 2025-12-22T16:27:40.244Z
Learning: For PRs that remove tests, rely on pytest --collect-only to verify the test discovery results (which tests are selected/deselected) and ensure the removal is clean and the test module remains functional. Full test execution is not required for test deletion PRs. This guideline applies to test files anywhere under the tests/ directory (e.g., tests/network/upgrade/test_upgrade_network.py) and should be used for similar test-deletion scenarios across the repository.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-07T09:52:12.342Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3358
File: tests/network/sriov/test_sriov.py:21-21
Timestamp: 2026-01-07T09:52:12.342Z
Learning: When a PR only removes or modifies pytest markers in tests (e.g., removing pytest.mark.post_upgrade) and the test logic remains unchanged, prefer verifying with pytest --collect-only instead of running the full test suite. This validates that marker usage and test selection behavior are preserved. If the test logic changes, or markers affect behavior beyond collection, run the full test suite to confirm.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-18T13:18:48.808Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 3273
File: tests/network/connectivity/test_ovs_linux_bridge.py:5-9
Timestamp: 2026-01-18T13:18:48.808Z
Learning: In tests/network/connectivity/test_ovs_linux_bridge.py and similar test files, prefer importing ipaddress as a module and using qualified calls like ipaddress.ip_interface(...) rather than from ipaddress import ip_interface. This preserves module context for readability, especially when chaining properties (e.g., ipaddress.ip_interface(...).ip). This is an intentional exception to the general rule favoring specific imports, and should apply to test files under the tests directory where module context aids understanding.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-18T14:51:50.846Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3495
File: tests/network/third_part_ip_request/test_third_party_ip_request.py:4-12
Timestamp: 2026-01-18T14:51:50.846Z
Learning: In the openshift-virtualization-tests repository, tests consistently import pytest as a module (import pytest) and avoid from pytest import ...; this is the established pattern across 398+ test files. Do not flag or refactor imports to use specific pytest names in tests under tests/**. If a file already follows this pattern, leave it as is; this guideline applies broadly to Python test files under the tests directory.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-29T05:30:13.982Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 3649
File: tests/network/user_defined_network/ip_specification/libipspec.py:1-4
Timestamp: 2026-01-29T05:30:13.982Z
Learning: In the openshift-virtualization-tests repository, Python imports should use module import style for the standard library 'json' (import json) rather than 'from json import ...'. This improves readability by making calls like json.loads and json.dumps explicit, and aligns with patterns used for modules like logging, ipaddress, cloudinit, and pytest. Apply this to all Python test files under tests/ (and similar test directories).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-02T17:41:12.759Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3690
File: tests/after_cluster_deploy_sanity/test_after_cluster_deploy_sanity.py:65-65
Timestamp: 2026-02-02T17:41:12.759Z
Learning: In test files, keep test_* functions with simple one-line docstrings. For helper functions, utilities, and library code with non-obvious return values or side effects, use Google-style docstrings with Args, Returns, and Side effects sections. Do not require Google-style docstrings for pytest test functions themselves.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-03T07:34:34.184Z
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 3697
File: tests/infrastructure/instance_types/test_common_vm_instancetype.py:53-98
Timestamp: 2026-02-03T07:34:34.184Z
Learning: In test files (Python, pytest), prefer using tier3 markers for categorization since tier2, tier1, and tier4 are not used in this repository. Do not rely on non-official markers; formalize and document the allowed markers in pytest.ini (or equivalent) to ensure consistent usage. When reviewing new tests, ensure markers align with this convention (only tier3, unless a project-wide decision defines additional tiers) and remove any unnecessary or undocumented markers.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-10T15:04:14.799Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3577
File: tests/virt/conftest.py:251-267
Timestamp: 2026-02-10T15:04:14.799Z
Learning: In Python tests, remove all bare time.sleep() calls. Replace with a waiting mechanism such as TimeoutSampler from the timeout_sampler package or a function decorated with retry (with appropriate timeout/conditions) to ensure determinism and avoid flakiness. This applies to all Python tests under the tests directory (not just this file) to maintain consistent waiting behavior across the suite.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-25T11:00:02.013Z
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3873
File: tests/network/localnet/test_non_udn_localnet.py:19-27
Timestamp: 2026-02-25T11:00:02.013Z
Learning: In the test codebase, do not import from conftest.py files. This avoids import ambiguity in pytest. Do not import constants or helpers defined in conftest.py into tests. If a value is needed in both conftest.py and test files, duplicate it in both places or place it in a separate utility module that is importable by tests.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-29T13:51:25.599Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 4267
File: tests/storage/cross_cluster_live_migration/test_cclm.py:96-106
Timestamp: 2026-03-29T13:51:25.599Z
Learning: In this repository, follow the existing pytest convention for `pytest.mark.parametrize` argument names: use a single comma-separated string for `argnames` (e.g., `"dv_wait_timeout, vms_for_cclm"`), not a tuple (e.g., `("dv_wait_timeout", "vms_for_cclm")`). Do not flag or suggest changing `argnames` to a tuple. Also note that PT006 is not enforced by Ruff in this repo, so reviewers should not treat PT006 as a reason to alter the `argnames` format.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-12T11:24:13.825Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:50-52
Timestamp: 2026-01-12T11:24:13.825Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when catching exceptions in Python, use LOGGER.error before re-raising and do not replace it with LOGGER.exception in except blocks. This follows the established pattern across the codebase.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-12T14:25:05.723Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3366
File: tests/storage/cdi_clone/test_clone.py:5-9
Timestamp: 2026-01-12T14:25:05.723Z
Learning: In Python tests and utility code across the repository, bitmath.parse_string_unsafe correctly parses Kubernetes quantities (e.g., '4Gi', '512Mi', PVC storage requests) without supplying system=bitmath.NIST. There are 30+ usages indicating this is the standard behavior. Reviewers should verify that code that builds or compares quantity strings does not pass the NIST parameter, and if a new test relies on quantity parsing, assume no NIST parameter is required unless explicitly documented.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-20T01:03:13.139Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:1-8
Timestamp: 2026-01-20T01:03:13.139Z
Learning: In the openshift-virtualization-tests repository, Python imports should consistently use module-level imports for the logging module (i.e., import logging) rather than from logging import ... The established pattern spans 270+ files and should not be flagged for refactoring. Apply this guideline to Python files across the repo (e.g., tests/network/provider_migration/libprovider.py).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-21T21:26:41.805Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 3559
File: utilities/infra.py:251-254
Timestamp: 2026-01-21T21:26:41.805Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when reviewing Python code, recognize that with Python 3.14 the syntax 'except ValueError, TypeError:' is valid if there is no 'as' clause, and should not be flagged as Python 2 syntax. If you use an 'as' binding (e.g., 'except (ValueError, TypeError) as e:'), parentheses are required. Ensure this pattern is version-consistent and not flagged as Python 2 syntax when 'as' is absent.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-01-25T13:18:21.675Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3571
File: tests/storage/storage_migration/utils.py:158-167
Timestamp: 2026-01-25T13:18:21.675Z
Learning: In reviews of the openshift-virtualization-tests repo (and similar Python code), avoid suggesting minor stylistic changes that require extra verification (e.g., removing dict.keys() checks for membership) unless the change has clear correctness or maintainability impact. Focus on fixes with observable behavior, security, performance, or maintainability benefits; defer low-impact style tweaks that are costly to verify.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-18T06:35:39.536Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: utilities/virt.py:2449-2453
Timestamp: 2026-02-18T06:35:39.536Z
Learning: In Python code, a function named clearly and self-descriptively can be deemed not to require a docstring. However, treat this as a context-specific guideline and not a universal rule. For public APIs or functions with side effects, prefer concise docstrings explaining behavior, inputs, outputs, and side effects. This guidance is based on the example in utilities/virt.py from RedHatQE/openshift-virtualization-tests where validate_libvirt_persistent_domain(vm, admin_client) was considered self-documenting.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-23T16:33:22.070Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/pytest_utils.py:441-463
Timestamp: 2026-02-23T16:33:22.070Z
Learning: In Python code reviews, the guideline to always use named arguments for multi-argument calls does not apply to built-ins or methods that have positional-only parameters (those defined with a / in their signature). Do not flag or require named arguments for calls like dict.get(key, default=None, /), list.pop(), str.split(sep, maxsplit) and similar built-ins that cannot accept keyword arguments. Apply the named-argument rule only to functions/methods that explicitly accept keyword arguments.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In RedHatQE/openshift-virtualization-tests, when reviewing Python files, post targeted inline comments on the Files changed tab at the exact location (file and line) of the issue rather than opening a single discussion thread for multiple issues. This should be done for each applicable location to improve traceability and clarity. If multiple issues exist in the same file, address them with separate inline comments pointing to the specific lines.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CodeRabbit should post targeted inline comments at each applicable location in the Files Changed tab, rather than aggregating multiple issues into a single PR discussion thread reply. This guideline applies to all Python files (any file ending in .py) changed in a PR; for non-Python files, follow the same inline-comment-at-location principle if relevant.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-04T13:45:29.122Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: utilities/console.py:54-59
Timestamp: 2026-05-04T13:45:29.122Z
Learning: During review of RedHatQE/openshift-virtualization-tests “lint-cleanup” PRs (e.g., changes targeting lint issues like stale noqa/utf-8 headers), do not flag existing `# type: ignore` directives that were already present before the PR and were not introduced or modified by the PR. Only raise findings for `# type: ignore` suppressions that the PR itself adds, changes, or otherwise makes newly effective (i.e., they appear in the diff as additions/edits).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-04T13:45:33.892Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: tests/virt/cluster/common_templates/centos/test_centos_os_support.py:78-83
Timestamp: 2026-05-04T13:45:33.892Z
Learning: When reviewing lint-cleanup or formatting-only pull requests in this repo (e.g., changes like removing/updating `# noqa` comments or UTF-8 headers), do not raise findings for code patterns that already existed before the PR. Specifically, if a problematic construct such as `.is_connective(tcp_timeout=120)` was present in the base branch, suppress that finding and only raise issues when the PR itself introduces or modifies that construct (i.e., the diff adds/changes the call or its arguments). Apply this rule across all Python files (`**/*.py`).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-05T17:01:15.294Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:2-2
Timestamp: 2026-05-05T17:01:15.294Z
Learning: In this repo’s Python code, it’s acceptable (and preferred by convention) to build `run_command` inputs using `shlex.split(f"<command> {arg}")` rather than converting to direct list literals like `['oc', 'adm', 'uncordon', name]`. During code review, generally don’t flag `shlex.split(...)` usage for `run_command` calls and don’t suggest replacing it with list literals; the string-form pattern is used to keep commands readable and consistent with how they’re typed in a terminal.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-08T12:49:20.694Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4788
File: utilities/os_utils.py:257-262
Timestamp: 2026-05-08T12:49:20.694Z
Learning: In RedHatQE/openshift-virtualization-tests, the Ruff flake8-boolean-trap rules FBT001/FBT002 are intentionally not enabled (pyproject.toml does not select the FBT rules; confirmed via `ruff check --show-settings`). Therefore, do not flag boolean positional parameters as FBT001/FBT002 violations in this repository. If Ruff configuration changes and starts selecting FBT rules, this exception should be reconsidered.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-12T05:10:24.601Z
Learnt from: acinko-rh
Repo: RedHatQE/openshift-virtualization-tests PR: 4780
File: tests/storage/utils.py:568-572
Timestamp: 2026-05-12T05:10:24.601Z
Learning: In this repository, Ruff rule UP043 ("unnecessary default type arguments") is enforced. When annotating `collections.abc.Generator` return types, prefer the single-parameter form `Generator[YieldType]` rather than `Generator[YieldType, None, None]`. Explicit `None, None` for the SendType and ReturnType are unnecessary defaults (per PEP 696) and will trigger UP043. Apply this consistently across all Python files.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-13T19:23:09.603Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/libstuntime.py:25-25
Timestamp: 2026-05-13T19:23:09.603Z
Learning: In this repository, do not recommend adding `from __future__ import annotations` to fix forward-reference type annotation issues (e.g., Ruff UP037). Follow the established convention: use quoted string type annotations for forward references when the referenced class/type is defined later in the same file (e.g., `"ContinuousPing"`), and prefer `typing.Self` for self-referential return types.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T06:30:56.781Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_bitwarden.py:207-207
Timestamp: 2026-05-18T06:30:56.781Z
Learning: During Ruff/lint rule-enablement PRs in this repository (e.g., when introducing a new rule like PLC0415), it’s acceptable to keep CI green by adding per-line, targeted suppressions for pre-existing violations: add only `# noqa: <single-ruff-rule-id>` at the end of the specific violating line. In this PR context, reviewers should NOT flag these targeted `# noqa: PLC0415` comments as policy violations, assuming the suppression is for a pre-existing issue and is documented in the PR description as a candidate for follow-up cleanup. Do not allow blanket `# noqa` (without a specific rule) or `per-file-ignores`; those remain disallowed.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T06:31:12.015Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_pytest_utils.py:270-270
Timestamp: 2026-05-18T06:31:12.015Z
Learning: In RedHatQE/openshift-virtualization-tests, if a PR is a Ruff rule-enforcement PR and its “Special notes for reviewer” documents that pre-existing Ruff violations are being temporarily handled via per-line suppressions (e.g., `# noqa: PLC0415`) to keep CI green, reviewers should treat those specific `# noqa: <rule>` comments as an agreed, temporary mechanism. Do not flag them as code-quality issues and do not recommend removing, consolidating, or refactoring those suppressions within the same PR; cleanup/remediation is expected to happen in dedicated follow-up PRs instead.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T06:31:15.083Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_data_collector.py:304-304
Timestamp: 2026-05-18T06:31:15.083Z
Learning: When reviewing Python code in this repository for Ruff/linter rule rollouts, do not treat temporary suppression comments as violations in the specific migration scenario where a PR enables a new Ruff rule (e.g., PLC0415) and the PR description explicitly documents that all *pre-existing* violations are being annotated with `# noqa: <RULE>` as a short-lived measure. In that case, only flag `# noqa: <RULE>` suppressions that are newly introduced on code that did not previously violate the rule—i.e., verify via the PR diff against the prior state (and/or prior Ruff findings) that the suppressed line was already violating before the rule was enabled. Ignore suppressions that are covering violations that existed before the new rule rollout and were intentionally bulk-added for cleanup in follow-up PRs.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T06:31:20.848Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_hco.py:501-501
Timestamp: 2026-05-18T06:31:20.848Z
Learning: When reviewing Python code in RedHatQE/openshift-virtualization-tests, avoid flagging Ruff `# noqa: <RULE>` suppressions as issues if they were intentionally added as a temporary measure to keep CI green after a PR enables a new Ruff/lint rule (e.g., PLC0415) and the PR description documents this under "Special notes for reviewer". Treat these suppressions as deferred technical debt. Only flag `# noqa: PLC0415` (and similar rule-specific suppressions) when they are newly introduced without an accompanying documented intent in the PR (and thus appear to be masking a new violation rather than a pre-existing one).
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T09:09:09.479Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4878
File: utilities/unittests/test_pytest_utils.py:2194-2197
Timestamp: 2026-05-18T09:09:09.479Z
Learning: In this repository (RedHatQE/openshift-virtualization-tests), do not flag missing return type annotations or missing argument type annotations as Ruff “ANN” rule violations (e.g., ANN001/ANN002/ANN201/ANN202). The repo’s Ruff configuration does not enable ANN rules and only uses `extend-select = ["PLC0415"]`, so missing type annotations should not be treated as ANN lint failures during code review.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When using Kubernetes API models like `NodeSelectorRequirement` or `LabelSelectorRequirement` with operators `Exists` or `DoesNotExist`, the `values` field must not be non-empty. It is valid for `values` to be omitted / left as `None` (Python) / passed as `null`—Kubernetes rejects non-empty `values` for these operators, but does not require the field to be present or explicitly set to an empty list. In code reviews, do not treat missing `values=[]` for `Exists`/`DoesNotExist` as a validation issue; only flag cases where `values` is provided with actual elements.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When constructing Kubernetes `NodeSelectorRequirement` (or `LabelSelectorRequirement`) objects in code, do not treat `values` being omitted, `None`, or an empty list as an API-validation problem when the requirement’s operator is `Exists` or `DoesNotExist`. Per the Kubernetes API spec, these operators only require that the `values` array is not non-empty (i.e., it must be empty); they do not require the field to be explicitly present as `[]`. Therefore, reviewers should not flag `values=None`/missing `values` for `Exists`/`DoesNotExist`.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-02-19T15:36:04.744Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3926
File: tests/storage/cross_cluster_live_migration/utils.py:137-156
Timestamp: 2026-02-19T15:36:04.744Z
Learning: In cross-cluster live migration (CCLM) tests vs storage-migration tests, boot-time verification uses different access methods: console-based (get_vm_boot_time_via_console) when SSH to VMs in the remote cluster is unavailable, and SSH-based (get_vm_boot_time) when VMs remain in the same cluster. Code reviews should enforce separate, clearly named verification functions for each scenario (e.g., verify_vms_boot_time_after_migration vs verify_vms_boot_time_after_storage_migration) and place them in the appropriate modules. This pattern applies to all Python test utilities under tests/storage.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-03T15:38:09.624Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: tests/virt/node/general/test_windows_vtpm_bitlocker.py:50-52
Timestamp: 2026-05-03T15:38:09.624Z
Learning: During review of PRs that are lint cleanups or tooling/version bumps, do not flag code-quality issues for patterns that pre-existed before the PR. Specifically, if the diff does not introduce/modify constructs such as nested `if` blocks or unnecessary list comprehensions, treat them as known/deferred and leave them for dedicated follow-up cleanup PRs. Only raise issues when the PR itself adds, changes, or refactors the problematic code.
Applied to files:
tests/storage/snapshots/utils.pytests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-18T10:38:33.820Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4884
File: .coderabbit.yaml:79-80
Timestamp: 2026-05-18T10:38:33.820Z
Learning: In this repo, pytest tests are expected to live only in files named `test_*.py`. When applying CodeRabbit STP case B (newly added `def test_*` inside an existing test file), scope the check to existing files that match `test_*.py` and do not broaden it to newly added `def test_*` found in other non-`test_*.py` Python files.
Applied to files:
tests/storage/snapshots/test_snapshots.py
📚 Learning: 2026-05-19T17:16:55.817Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/test_migration_stuntime.py:33-38
Timestamp: 2026-05-19T17:16:55.817Z
Learning: In this repo’s test suite (under `tests/`), module-level triple-quoted string blocks used as STD documentation for shared preconditions (e.g., a `"""Preconditions: ..."""` block placed after `pytestmark`) are intentional. Do not flag them as dead code and do not suggest moving them into module/class docstrings or deleting them, as they are a consistent documentation convention across STD test modules.
Applied to files:
tests/storage/snapshots/test_snapshots.py
🪛 Ruff (0.15.13)
tests/storage/snapshots/utils.py
[warning] 58-58: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
[warning] 58-58: Missing type annotation for **kwargs
(ANN003)
[warning] 82-82: Boolean-typed positional argument in function definition
(FBT001)
[warning] 82-82: Boolean default positional argument in function definition
(FBT002)
[warning] 83-83: Dynamically typed expressions (typing.Any) are disallowed in **kwargs
(ANN401)
tests/storage/snapshots/test_snapshots.py
[warning] 270-270: Wrong type passed to first argument of pytest.mark.parametrize; expected tuple
Use a tuple for the first argument
(PT006)
| @pytest.mark.parametrize( | ||
| "rhel_vm_name, snapshot_with_content", | ||
| [ | ||
| pytest.param( | ||
| {"vm_name": "vm-cnv-80304"}, | ||
| {"number_of_snapshots": 1, "online_vm": False}, | ||
| marks=pytest.mark.polarion("CNV-80304"), | ||
| ), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| def test_restore_snapshot_with_predictable_names( | ||
| self, | ||
| admin_client, | ||
| rhel_vm_for_snapshot, | ||
| snapshot_with_content, | ||
| ): | ||
| if rhel_vm_for_snapshot.ready: | ||
| rhel_vm_for_snapshot.stop(wait=True) | ||
|
|
||
| source_volume_name = rhel_vm_for_snapshot.instance.spec.template.spec.volumes[0].name | ||
| restored_vm_name = f"{rhel_vm_for_snapshot.name}-restored" | ||
|
|
||
| with vm_restore_with_prefix_policy( | ||
| name=f"{restored_vm_name}-restore", | ||
| namespace=rhel_vm_for_snapshot.namespace, | ||
| vm_name=restored_vm_name, | ||
| snapshot_name=snapshot_with_content[0].name, | ||
| client=admin_client, | ||
| prefix_policy="PrefixTargetName", | ||
| ) as vm_restore: | ||
| vm_restore.wait_restore_done(timeout=TIMEOUT_10MIN) | ||
|
|
||
| restore_status = vm_restore.instance.status | ||
| assert_restored_dv_pvc_predictable_names( | ||
| restored_vm_name=restored_vm_name, | ||
| source_volume_name=source_volume_name, | ||
| restored_dv_name=restore_status.restores[0].dataVolumeName, | ||
| restored_pvc_name=restore_status.restores[0].persistentVolumeClaim, | ||
| volume_restore_policy=vm_restore.instance.spec.get("volumeRestorePolicy"), | ||
| ) | ||
|
|
There was a problem hiding this comment.
HIGH: New feature test is missing STD-first traceability metadata
This PR adds a new feature test implementation, but the file/class/test context does not show STD-first traceability (STP link, or RFE/Jira-epic link in docstring as fallback) required by the repository workflow.
As per coding guidelines, “New feature tests must follow the STD-first workflow … Every new feature test file must include an STP link in the module, class, or test docstring; if there is no STP, include an RFE or Jira epic link.”
🧰 Tools
🪛 Ruff (0.15.13)
[warning] 270-270: Wrong type passed to first argument of pytest.mark.parametrize; expected tuple
Use a tuple for the first argument
(PT006)
🤖 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/snapshots/test_snapshots.py` around lines 269 - 310, Add
STD-first traceability metadata to this new feature test by including an STP
link (or, if unavailable, an RFE/Jira epic link) in the test's docstring area:
place the link in the module docstring at the top of
tests/storage/snapshots/test_snapshots.py or in the class or the
test_restore_snapshot_with_predictable_names test's docstring so the test
(test_restore_snapshot_with_predictable_names) clearly references the STP or
fallback ticket identifier as required by the repository workflow.
There was a problem hiding this comment.
isn't the polarion mark in the test itself enough?
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check what STP/STD traceability looks like in nearby or similar feature test files
rg -n "STP|stp\.|RFE|jira.*epic|CNV-[0-9]+" tests/storage/snapshots/ --type py -C1 | head -60
echo "---"
# Check module docstrings in storage test files for STP link pattern
rg -n "https://.*stp|STP-[0-9]+|RFE-[0-9]+" tests/storage/ --type py | head -20
echo "---"
# Check general pattern in tests for STP links
rg -n "STP-[0-9]+|https://.*polarion.*stp|RFE-[0-9]+" tests/ --type py | head -20
Repository: RedHatQE/openshift-virtualization-tests
Length of output: 4032
@acinko-rh — Good question, worth clarifying. They are not equivalent — they serve different purposes:
| Artifact | Purpose | What it answers |
|---|---|---|
pytest.mark.polarion("CNV-80304") |
Links test code → test case in Polarion TMS | "Which test case executes this code?" |
| STP / RFE / Jira-epic link in docstring | Links test code → the design/requirement that drove it | "Why does this test exist? What feature does it validate?" |
The STD-first guideline requires the design traceability link so reviewers can verify the test was planned before implementation, not reverse-engineered after.
That said — after checking the actual codebase, no existing test in tests/storage/snapshots/test_snapshots.py (or anywhere in tests/storage/) carries an STP or RFE link. The only example I found in the whole repo is tests/network/l2_bridge/bandwidth/test_bandwidth.py line 5 with an RFE link. So requiring it strictly on your new test while the surrounding module has none would be inconsistent.
My original comment was too aggressive given the existing state of this file. I'm withdrawing it as a blocking issue — but ideally the module docstring would gain a link like:
"""
Snapshots tests
https://redhat.atlassian.net/browse/CNV-80304
"""That's a LOW/nice-to-have, not a blocker.
✏️ Learnings added
Learnt from: acinko-rh
Repo: RedHatQE/openshift-virtualization-tests PR: 4780
File: tests/storage/snapshots/test_snapshots.py:267-299
Timestamp: 2026-05-20T08:46:30.219Z
Learning: In tests/storage/snapshots/test_snapshots.py and across the entire tests/storage/ directory, the existing convention is to use only pytest.mark.polarion() for test traceability — no STP links or RFE/Jira-epic links are present in any module docstring. Do not flag missing STP/RFE links as HIGH severity for tests added to this file; the guideline is aspirational but unenforced here. Only flag it as LOW/informational and only if adding to a file that already has STD traceability established.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 3024
File: tests/network/connectivity/utils.py:17-17
Timestamp: 2025-12-15T12:33:06.686Z
Learning: In the test suite, ensure the ipv6_network_data fixture returns a factory function (Callable) and that all call sites invoke it to obtain the actual data dict, i.e., use ipv6_network_data() at call sites. This enables future extensibility for configuring secondary interfaces' IP addresses without changing call sites. Apply this pattern to all Python test files under tests.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3196
File: tests/network/upgrade/test_upgrade_network.py:4-4
Timestamp: 2025-12-22T16:27:40.244Z
Learning: For PRs that remove tests, rely on pytest --collect-only to verify the test discovery results (which tests are selected/deselected) and ensure the removal is clean and the test module remains functional. Full test execution is not required for test deletion PRs. This guideline applies to test files anywhere under the tests/ directory (e.g., tests/network/upgrade/test_upgrade_network.py) and should be used for similar test-deletion scenarios across the repository.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3358
File: tests/network/sriov/test_sriov.py:21-21
Timestamp: 2026-01-07T09:52:12.342Z
Learning: When a PR only removes or modifies pytest markers in tests (e.g., removing pytest.mark.post_upgrade) and the test logic remains unchanged, prefer verifying with pytest --collect-only instead of running the full test suite. This validates that marker usage and test selection behavior are preserved. If the test logic changes, or markers affect behavior beyond collection, run the full test suite to confirm.
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:50-52
Timestamp: 2026-01-12T11:24:13.825Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when catching exceptions in Python, use LOGGER.error before re-raising and do not replace it with LOGGER.exception in except blocks. This follows the established pattern across the codebase.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3366
File: tests/storage/cdi_clone/test_clone.py:5-9
Timestamp: 2026-01-12T14:25:05.723Z
Learning: In Python tests and utility code across the repository, bitmath.parse_string_unsafe correctly parses Kubernetes quantities (e.g., '4Gi', '512Mi', PVC storage requests) without supplying system=bitmath.NIST. There are 30+ usages indicating this is the standard behavior. Reviewers should verify that code that builds or compares quantity strings does not pass the NIST parameter, and if a new test relies on quantity parsing, assume no NIST parameter is required unless explicitly documented.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 3404
File: tests/virt/upgrade/conftest.py:291-301
Timestamp: 2026-01-14T04:08:23.032Z
Learning: In the openshift-virtualization-tests repository, when using VirtualMachine objects from ocp-resources in tests, if vm.ready is True, vm.vmi is guaranteed to exist. Therefore, you can access vm.vmi.instance.status or vm.vmi attributes without additional defensive checks (e.g., if vm.vmi: ...). Do not rely on vm.vmi being present when vm.ready may be False; guard those code paths accordingly. This guideline applies to tests under tests/ (notably in virt/upgrade/conftest.py and related test modules) and should be followed for any code paths that assume vm.vmi exists only when vm.ready is True.
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 3376
File: tests/network/general/test_ip_family_services.py:96-96
Timestamp: 2026-01-18T09:44:17.044Z
Learning: In the openshift-virtualization-tests repository, function-scoped fixtures must use pytest.fixture() with empty parentheses (not pytest.fixture without parentheses). This repo follows this convention despite Ruff PT001. Apply this consistently to all Python test files under tests/ (not just this one) to maintain repository-wide consistency.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 3273
File: tests/network/connectivity/test_ovs_linux_bridge.py:5-9
Timestamp: 2026-01-18T13:18:48.808Z
Learning: In tests/network/connectivity/test_ovs_linux_bridge.py and similar test files, prefer importing ipaddress as a module and using qualified calls like ipaddress.ip_interface(...) rather than from ipaddress import ip_interface. This preserves module context for readability, especially when chaining properties (e.g., ipaddress.ip_interface(...).ip). This is an intentional exception to the general rule favoring specific imports, and should apply to test files under the tests directory where module context aids understanding.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3495
File: tests/network/third_part_ip_request/test_third_party_ip_request.py:4-12
Timestamp: 2026-01-18T14:51:50.846Z
Learning: In the openshift-virtualization-tests repository, tests consistently import pytest as a module (import pytest) and avoid from pytest import ...; this is the established pattern across 398+ test files. Do not flag or refactor imports to use specific pytest names in tests under tests/**. If a file already follows this pattern, leave it as is; this guideline applies broadly to Python test files under the tests directory.
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:1-8
Timestamp: 2026-01-20T01:03:13.139Z
Learning: In the openshift-virtualization-tests repository, Python imports should consistently use module-level imports for the logging module (i.e., import logging) rather than from logging import ... The established pattern spans 270+ files and should not be flagged for refactoring. Apply this guideline to Python files across the repo (e.g., tests/network/provider_migration/libprovider.py).
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 3559
File: utilities/infra.py:251-254
Timestamp: 2026-01-21T21:26:41.805Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when reviewing Python code, recognize that with Python 3.14 the syntax 'except ValueError, TypeError:' is valid if there is no 'as' clause, and should not be flagged as Python 2 syntax. If you use an 'as' binding (e.g., 'except (ValueError, TypeError) as e:'), parentheses are required. Ensure this pattern is version-consistent and not flagged as Python 2 syntax when 'as' is absent.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3571
File: tests/storage/storage_migration/utils.py:158-167
Timestamp: 2026-01-25T13:18:21.675Z
Learning: In reviews of the openshift-virtualization-tests repo (and similar Python code), avoid suggesting minor stylistic changes that require extra verification (e.g., removing dict.keys() checks for membership) unless the change has clear correctness or maintainability impact. Focus on fixes with observable behavior, security, performance, or maintainability benefits; defer low-impact style tweaks that are costly to verify.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 3619
File: tests/network/user_defined_network/test_user_defined_network.py:97-97
Timestamp: 2026-01-27T17:18:49.973Z
Learning: In tests that exercise lookup_iface_status_ip from libs.net.vmspec, rely on the function's built-in descriptive error messages for failures. Do not add extra assertion messages for IP presence checks using this function; instead, assert on the function behavior or catch its exceptions as appropriate. This reduces duplication and clarifies failures.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 3649
File: tests/network/user_defined_network/ip_specification/libipspec.py:1-4
Timestamp: 2026-01-29T05:30:13.982Z
Learning: In the openshift-virtualization-tests repository, Python imports should use module import style for the standard library 'json' (import json) rather than 'from json import ...'. This improves readability by making calls like json.loads and json.dumps explicit, and aligns with patterns used for modules like logging, ipaddress, cloudinit, and pytest. Apply this to all Python test files under tests/ (and similar test directories).
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3690
File: tests/after_cluster_deploy_sanity/test_after_cluster_deploy_sanity.py:65-65
Timestamp: 2026-02-02T17:41:12.759Z
Learning: In test files, keep test_* functions with simple one-line docstrings. For helper functions, utilities, and library code with non-obvious return values or side effects, use Google-style docstrings with Args, Returns, and Side effects sections. Do not require Google-style docstrings for pytest test functions themselves.
Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 3697
File: tests/infrastructure/instance_types/test_common_vm_instancetype.py:53-98
Timestamp: 2026-02-03T07:34:34.184Z
Learning: In test files (Python, pytest), prefer using tier3 markers for categorization since tier2, tier1, and tier4 are not used in this repository. Do not rely on non-official markers; formalize and document the allowed markers in pytest.ini (or equivalent) to ensure consistent usage. When reviewing new tests, ensure markers align with this convention (only tier3, unless a project-wide decision defines additional tiers) and remove any unnecessary or undocumented markers.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3577
File: tests/virt/conftest.py:251-267
Timestamp: 2026-02-10T15:04:14.799Z
Learning: In Python tests, remove all bare time.sleep() calls. Replace with a waiting mechanism such as TimeoutSampler from the timeout_sampler package or a function decorated with retry (with appropriate timeout/conditions) to ensure determinism and avoid flakiness. This applies to all Python tests under the tests directory (not just this file) to maintain consistent waiting behavior across the suite.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: utilities/virt.py:2449-2453
Timestamp: 2026-02-18T06:35:39.536Z
Learning: In Python code, a function named clearly and self-descriptively can be deemed not to require a docstring. However, treat this as a context-specific guideline and not a universal rule. For public APIs or functions with side effects, prefer concise docstrings explaining behavior, inputs, outputs, and side effects. This guidance is based on the example in utilities/virt.py from RedHatQE/openshift-virtualization-tests where validate_libvirt_persistent_domain(vm, admin_client) was considered self-documenting.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3926
File: tests/storage/cross_cluster_live_migration/utils.py:137-156
Timestamp: 2026-02-19T15:36:04.744Z
Learning: In cross-cluster live migration (CCLM) tests vs storage-migration tests, boot-time verification uses different access methods: console-based (get_vm_boot_time_via_console) when SSH to VMs in the remote cluster is unavailable, and SSH-based (get_vm_boot_time) when VMs remain in the same cluster. Code reviews should enforce separate, clearly named verification functions for each scenario (e.g., verify_vms_boot_time_after_migration vs verify_vms_boot_time_after_storage_migration) and place them in the appropriate modules. This pattern applies to all Python test utilities under tests/storage.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/unittests/test_os_utils.py:333-425
Timestamp: 2026-02-23T16:31:34.505Z
Learning: In integration/functional tests located under the tests/ directory, require assertion failure messages using the pattern: assert condition, "descriptive message". For unit tests under utilities/unittests/, rely on pytest's assertion introspection and descriptive test names; explicit failure messages are not required. This guidance helps maintain clear diagnostics for integration tests while keeping unit tests concise and leveraging pytest's built-in introspection.
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/pytest_utils.py:441-463
Timestamp: 2026-02-23T16:33:22.070Z
Learning: In Python code reviews, the guideline to always use named arguments for multi-argument calls does not apply to built-ins or methods that have positional-only parameters (those defined with a / in their signature). Do not flag or require named arguments for calls like dict.get(key, default=None, /), list.pop(), str.split(sep, maxsplit) and similar built-ins that cannot accept keyword arguments. Apply the named-argument rule only to functions/methods that explicitly accept keyword arguments.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3873
File: tests/network/localnet/test_non_udn_localnet.py:7-9
Timestamp: 2026-02-25T10:52:09.679Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, networking infrastructure requirements (nmstate, localnet bridge mappings, NIC availability) are not automatically tier3; they are considered standard test environment capabilities. Only tests with truly platform-specific, time-consuming, or bare-metal requirements should be marked as tier3. Apply this guidance to all Python tests under tests/, including tests/network/localnet/test_non_udn_localnet.py, ensuring tier3 designation is reserved for genuine platform-specific or complex scenarios rather than general networking infra necessities.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 3873
File: tests/network/localnet/test_non_udn_localnet.py:19-27
Timestamp: 2026-02-25T11:00:02.013Z
Learning: In the test codebase, do not import from conftest.py files. This avoids import ambiguity in pytest. Do not import constants or helpers defined in conftest.py into tests. If a value is needed in both conftest.py and test files, duplicate it in both places or place it in a separate utility module that is importable by tests.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In RedHatQE/openshift-virtualization-tests, when reviewing Python files, post targeted inline comments on the Files changed tab at the exact location (file and line) of the issue rather than opening a single discussion thread for multiple issues. This should be done for each applicable location to improve traceability and clarity. If multiple issues exist in the same file, address them with separate inline comments pointing to the specific lines.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CodeRabbit should post targeted inline comments at each applicable location in the Files Changed tab, rather than aggregating multiple issues into a single PR discussion thread reply. This guideline applies to all Python files (any file ending in .py) changed in a PR; for non-Python files, follow the same inline-comment-at-location principle if relevant.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4147
File: tests/network/upgrade/test_upgrade_network.py:166-177
Timestamp: 2026-03-19T10:36:59.023Z
Learning: In this repository’s pytest-based test files (under `tests/`), do not flag unused test method parameters/fixture arguments for removal when the parameters are intentionally kept only to enforce pytest fixture dependency ordering (e.g., an unused fixture like `bridge_on_one_node`). Treat this as an intentional convention consistent with other fixture definitions in the codebase, and do not open follow-up review issues for those unused parameters.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 4267
File: tests/storage/cross_cluster_live_migration/conftest.py:530-531
Timestamp: 2026-03-25T11:24:07.687Z
Learning: In this repo’s OpenShift virtualization tests, it is a standard pattern to call `to_dict()` on `ocp-resources` objects (e.g., `DataVolume`) without using its return value. The call is used only to populate the object’s `res` attribute, which is then read or mutated (e.g., `dv.res[...] = ...`). Do not flag this as an unused return value and do not request adding an inline comment just to justify it, since maintainers treat this behavior as consistent and intentional across the codebase.
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 4267
File: tests/storage/cross_cluster_live_migration/test_cclm.py:96-106
Timestamp: 2026-03-29T13:51:25.599Z
Learning: In this repository, follow the existing pytest convention for `pytest.mark.parametrize` argument names: use a single comma-separated string for `argnames` (e.g., `"dv_wait_timeout, vms_for_cclm"`), not a tuple (e.g., `("dv_wait_timeout", "vms_for_cclm")`). Do not flag or suggest changing `argnames` to a tuple. Also note that PT006 is not enforced by Ruff in this repo, so reviewers should not treat PT006 as a reason to alter the `argnames` format.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4318
File: tests/network/bandwidth/test_bandwidth.py:1-3
Timestamp: 2026-03-31T08:35:22.802Z
Learning: In this repository, when reviewing Python test modules under tests/, only require an STP link in the module docstring for STD (new-feature) tests. If the test module is a support-exception test tied to SUPPORTEX-* tickets (e.g., SUPPORTEX-29574) and therefore has no STP, do not flag missing STP links in the module docstring.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4318
File: tests/network/l2_bridge/bandwidth/test_bandwidth.py:5-27
Timestamp: 2026-03-31T10:39:33.409Z
Learning: In this repository’s pytest suite, some STD (Standard Definition) placeholder tests under the `tests/` directory are intentionally implemented as docstring-only functions. They must be marked with `__test__ = False` immediately after the function definition (e.g., `test_x.__test__ = False`) to prevent pytest from collecting/executing them until the real test body exists. During code review, do not flag these as missing executable coverage and do not recommend removing or changing the `__test__ = False` setting when the placeholder pattern matches this accepted STD approach.
Learnt from: ema-aka-young
Repo: RedHatQE/openshift-virtualization-tests PR: 4342
File: tests/storage/cdi_config/test_cdi_config.py:195-205
Timestamp: 2026-04-02T09:03:57.004Z
Learning: When calling `utilities.storage.get_dv_size_from_datasource()` in this repo, do not require an extra `None` guard for its return value if the `datasource` argument originates from a fixture that uses `ensure_exists=True` (e.g., `fedora_data_source_scope_module`). Those fixtures guarantee the datasource exists and provides a valid size, and other repo usages follow the same pattern without additional fail-fast/`None` checks; therefore, reviewers should not flag missing `None` guarding in this specific fixture-driven scenario.
Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:32-32
Timestamp: 2026-04-14T13:00:57.514Z
Learning: In this repository’s pytest quarantine tests, do not flag or change `pytest.mark.jira(<id>, run=False)` as ineffective. `run=False` on `pytest.mark.jira()` is intentionally handled by the `pytest_jira` plugin, which conditionally skips the test when the referenced Jira issue is open. This is the correct behavior for **Category 1 (Product Bug)** quarantines; the `pytest.mark.xfail(run=False)` approach is reserved for **Category 2 (Automation Issue)** quarantines only (as documented in `docs/QUARANTINE_GUIDELINES.md`).
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:0-0
Timestamp: 2026-04-14T16:15:31.065Z
Learning: When reviewing Python tests, avoid redundant parentheses around f-strings in `pytest.mark.xfail` decorators. Prefer `pytest.mark.xfail(reason=f"...", run=False)` over `pytest.mark.xfail(reason=(f"..."), run=False)`, and flag/suggest removing the extra wrapping parentheses where found.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:32-32
Timestamp: 2026-04-14T16:15:33.012Z
Learning: For this repository (RedHatQE/openshift-virtualization-tests), when reviewing any PR with "Quarantine" in the title or a `quarantine` label, check compliance with `docs/QUARANTINE_GUIDELINES.md` in any affected pytest test code. Specifically: (1) For Category 1 (Product Bug), require `pytest.mark.jira("CNV-XXXXX", run=False)` and do not suggest replacing it with `xfail` (the `pytest_jira` plugin conditionally skips when the Jira issue is open). (2) For Category 2 (Automation Issue), require `pytest.mark.xfail(run=False, reason=...)` (pytest handles the skip). During review, flag quarantine PRs that use the wrong marker/category, omit a Jira ticket reference for Category 1, or use `run=False` in an incorrect context; raise these compliance questions even if later resolution confirms the marker was correct.
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 4542
File: tests/network/libs/bgp.py:333-354
Timestamp: 2026-04-21T19:08:39.771Z
Learning: In this codebase, when using `retry` imported from `timeout_sampler`, the decorated function must indicate success by returning a truthy value. The decorator retries until it encounters a truthy `sample` (i.e., it does `if sample: return sample`). Therefore, ensure `retry`-decorated functions include `return True` (or another truthy value) on success; avoid removing/altering it on the assumption that the caller ignores the return value. If the function returns `None` (or has no return statement), it will keep retrying and typically end in `TimeoutExpiredError`.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4578
File: tests/network/localnet/nad_ref_change/test_nad_ref_change.py:18-18
Timestamp: 2026-04-26T11:44:20.150Z
Learning: In this repository’s STD (Standard Test Definition) PRs under `tests/**`, it’s expected that Polarion IDs may be placeholders (e.g., `pytest.mark.polarion("CNV-00000")`) while the test scenarios are still being agreed upon. If the test scenario is disabled for the moment (e.g., the scenario/module sets `__test__ = False`), reviewers should not treat placeholder Polarion IDs as a blocking issue. Real Polarion IDs should be filled in before or during the implementation PR.
Learnt from: dalia-frank
Repo: RedHatQE/openshift-virtualization-tests PR: 4603
File: tests/data_protection/oadp/test_velero.py:101-130
Timestamp: 2026-04-27T15:40:31.167Z
Learning: When reviewing tests in RedHatQE/openshift-virtualization-tests, do not require STD-first workflow and STP/RFE/Jira-epic module docstring/traceability for tests that are being re-enabled after previously being blocked by a product bug (e.g., after a CNV Jira bug fix). Only enforce these STD-first and STP/RFE/Jira-epic module docstring requirements for genuinely new feature tests; previously blocked tests that are now unblocked/re-enabled should not be flagged as missing traceability.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4569
File: tests/network/user_defined_network/rhel9_rhel10_cluster/test_connectivity.py:17-51
Timestamp: 2026-05-03T14:47:13.096Z
Learning: In this repository’s pytest suite (files under `tests/`), it is acceptable to have identically named `test_*` functions in different test modules (e.g., same function name in different `.../test_*.py` files). Do not request renaming solely to disambiguate function names across modules, since pytest node IDs remain unique and unambiguous due to the module path prefix. The team accepts the trade-off that `pytest -k <name>` will match tests in all modules containing that name.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: tests/virt/node/general/test_windows_vtpm_bitlocker.py:50-52
Timestamp: 2026-05-03T15:38:09.624Z
Learning: During review of PRs that are lint cleanups or tooling/version bumps, do not flag code-quality issues for patterns that pre-existed before the PR. Specifically, if the diff does not introduce/modify constructs such as nested `if` blocks or unnecessary list comprehensions, treat them as known/deferred and leave them for dedicated follow-up cleanup PRs. Only raise issues when the PR itself adds, changes, or refactors the problematic code.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: utilities/console.py:54-59
Timestamp: 2026-05-04T13:45:29.122Z
Learning: During review of RedHatQE/openshift-virtualization-tests “lint-cleanup” PRs (e.g., changes targeting lint issues like stale noqa/utf-8 headers), do not flag existing `# type: ignore` directives that were already present before the PR and were not introduced or modified by the PR. Only raise findings for `# type: ignore` suppressions that the PR itself adds, changes, or otherwise makes newly effective (i.e., they appear in the diff as additions/edits).
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: tests/virt/cluster/common_templates/centos/test_centos_os_support.py:78-83
Timestamp: 2026-05-04T13:45:33.892Z
Learning: When reviewing lint-cleanup or formatting-only pull requests in this repo (e.g., changes like removing/updating `# noqa` comments or UTF-8 headers), do not raise findings for code patterns that already existed before the PR. Specifically, if a problematic construct such as `.is_connective(tcp_timeout=120)` was present in the base branch, suppress that finding and only raise issues when the PR itself introduces or modifies that construct (i.e., the diff adds/changes the call or its arguments). Apply this rule across all Python files (`**/*.py`).
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:2-2
Timestamp: 2026-05-05T17:01:15.294Z
Learning: In this repo’s Python code, it’s acceptable (and preferred by convention) to build `run_command` inputs using `shlex.split(f"<command> {arg}")` rather than converting to direct list literals like `['oc', 'adm', 'uncordon', name]`. During code review, generally don’t flag `shlex.split(...)` usage for `run_command` calls and don’t suggest replacing it with list literals; the string-form pattern is used to keep commands readable and consistent with how they’re typed in a terminal.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:145-145
Timestamp: 2026-05-05T17:27:32.109Z
Learning: In this repo’s Python tests, `pyhelper_utils.shell.run_command` defaults to `check=True` (so it raises `subprocess.CalledProcessError` on non-zero exit). Therefore, don’t flag missing return-code handling/rc checks for bare calls like `run_command(...)` (or calls where `check` is not explicitly provided). Only flag cases where `check=False` is explicitly passed and the exit code/return value is ignored or not otherwise handled.
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:142-146
Timestamp: 2026-05-05T18:28:01.097Z
Learning: In this repository, ignore Ruff rule PT022 in Python test files under `tests/`. If PT022 is triggered in a `pytest` fixture that uses `yield` but has no teardown code, treat it as an acceptable low-value nitpick and do not suggest changing the fixture to use `return` or otherwise flag the issue during code review.
Learnt from: OhadRevah
Repo: RedHatQE/openshift-virtualization-tests PR: 4162
File: tests/install_upgrade_operators/crypto_policy/utils.py:320-323
Timestamp: 2026-05-07T12:34:42.589Z
Learning: When parsing the output of `openssl list -tls-groups`, remember it prints TLS group names on a single colon-separated line (e.g., `secp256r1:X25519:SecP256r1MLKEM768:...`). Parse individual TLS group names by splitting on `:` (e.g., `output.strip().split(':')`) rather than assuming one group per line. In code that specifically handles this `openssl list -tls-groups` output, do not flag `split(':')` as incorrect.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4772
File: tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py:20-22
Timestamp: 2026-05-08T12:31:26.895Z
Learning: In RedHatQE/openshift-virtualization-tests, any pytest test already marked with `pytest.mark.mixed_os_nodes` must not also be marked with `pytest.mark.tier3`. The `mixed_os_nodes` marker is responsible for both environment filtering and selecting the dedicated execution lane for dual-stream (mixed RHCOS 9 + RHCOS 10) cluster scenarios. Apply this rule to all test modules under `tests/` that use the `mixed_os_nodes` marker (e.g., `tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py`).
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4788
File: utilities/os_utils.py:257-262
Timestamp: 2026-05-08T12:49:20.694Z
Learning: In RedHatQE/openshift-virtualization-tests, the Ruff flake8-boolean-trap rules FBT001/FBT002 are intentionally not enabled (pyproject.toml does not select the FBT rules; confirmed via `ruff check --show-settings`). Therefore, do not flag boolean positional parameters as FBT001/FBT002 violations in this repository. If Ruff configuration changes and starts selecting FBT rules, this exception should be reconsidered.
Learnt from: acinko-rh
Repo: RedHatQE/openshift-virtualization-tests PR: 4780
File: tests/storage/utils.py:568-572
Timestamp: 2026-05-12T05:10:24.601Z
Learning: In this repository, Ruff rule UP043 ("unnecessary default type arguments") is enforced. When annotating `collections.abc.Generator` return types, prefer the single-parameter form `Generator[YieldType]` rather than `Generator[YieldType, None, None]`. Explicit `None, None` for the SendType and ReturnType are unnecessary defaults (per PEP 696) and will trigger UP043. Apply this consistently across all Python files.
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/test_migration_stuntime.py:51-51
Timestamp: 2026-05-12T18:18:20.607Z
Learning: In RedHatQE/openshift-virtualization-tests, do not flag or suggest removing Python linter suppressions `# noqa: PID001` in files under `tests/`. `PID001` is a custom flake8 rule enforced by the Polarion ID checker plugin (not a standard Ruff rule). Therefore Ruff’s `RUF102` (“Invalid rule code in `# noqa`: PID001”) is a false positive in this repo. These `# noqa: PID001` comments are intentional and effective, commonly used on base-class `test_*` methods where the Polarion markers are defined on subclass overrides.
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/libstuntime.py:25-25
Timestamp: 2026-05-13T19:23:09.603Z
Learning: In this repository, do not recommend adding `from __future__ import annotations` to fix forward-reference type annotation issues (e.g., Ruff UP037). Follow the established convention: use quoted string type annotations for forward references when the referenced class/type is defined later in the same file (e.g., `"ContinuousPing"`), and prefer `typing.Self` for self-referential return types.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_bitwarden.py:207-207
Timestamp: 2026-05-18T06:30:56.781Z
Learning: During Ruff/lint rule-enablement PRs in this repository (e.g., when introducing a new rule like PLC0415), it’s acceptable to keep CI green by adding per-line, targeted suppressions for pre-existing violations: add only `# noqa: <single-ruff-rule-id>` at the end of the specific violating line. In this PR context, reviewers should NOT flag these targeted `# noqa: PLC0415` comments as policy violations, assuming the suppression is for a pre-existing issue and is documented in the PR description as a candidate for follow-up cleanup. Do not allow blanket `# noqa` (without a specific rule) or `per-file-ignores`; those remain disallowed.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_pytest_utils.py:270-270
Timestamp: 2026-05-18T06:31:12.015Z
Learning: In RedHatQE/openshift-virtualization-tests, if a PR is a Ruff rule-enforcement PR and its “Special notes for reviewer” documents that pre-existing Ruff violations are being temporarily handled via per-line suppressions (e.g., `# noqa: PLC0415`) to keep CI green, reviewers should treat those specific `# noqa: <rule>` comments as an agreed, temporary mechanism. Do not flag them as code-quality issues and do not recommend removing, consolidating, or refactoring those suppressions within the same PR; cleanup/remediation is expected to happen in dedicated follow-up PRs instead.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_data_collector.py:304-304
Timestamp: 2026-05-18T06:31:15.083Z
Learning: When reviewing Python code in this repository for Ruff/linter rule rollouts, do not treat temporary suppression comments as violations in the specific migration scenario where a PR enables a new Ruff rule (e.g., PLC0415) and the PR description explicitly documents that all *pre-existing* violations are being annotated with `# noqa: <RULE>` as a short-lived measure. In that case, only flag `# noqa: <RULE>` suppressions that are newly introduced on code that did not previously violate the rule—i.e., verify via the PR diff against the prior state (and/or prior Ruff findings) that the suppressed line was already violating before the rule was enabled. Ignore suppressions that are covering violations that existed before the new rule rollout and were intentionally bulk-added for cleanup in follow-up PRs.
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_hco.py:501-501
Timestamp: 2026-05-18T06:31:20.848Z
Learning: When reviewing Python code in RedHatQE/openshift-virtualization-tests, avoid flagging Ruff `# noqa: <RULE>` suppressions as issues if they were intentionally added as a temporary measure to keep CI green after a PR enables a new Ruff/lint rule (e.g., PLC0415) and the PR description documents this under "Special notes for reviewer". Treat these suppressions as deferred technical debt. Only flag `# noqa: PLC0415` (and similar rule-specific suppressions) when they are newly introduced without an accompanying documented intent in the PR (and thus appear to be masking a new violation rather than a pre-existing one).
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4878
File: utilities/unittests/test_pytest_utils.py:2194-2197
Timestamp: 2026-05-18T09:09:09.479Z
Learning: In this repository (RedHatQE/openshift-virtualization-tests), do not flag missing return type annotations or missing argument type annotations as Ruff “ANN” rule violations (e.g., ANN001/ANN002/ANN201/ANN202). The repo’s Ruff configuration does not enable ANN rules and only uses `extend-select = ["PLC0415"]`, so missing type annotations should not be treated as ANN lint failures during code review.
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4884
File: .coderabbit.yaml:79-80
Timestamp: 2026-05-18T10:38:33.820Z
Learning: In this repo, pytest tests are expected to live only in files named `test_*.py`. When applying CodeRabbit STP case B (newly added `def test_*` inside an existing test file), scope the check to existing files that match `test_*.py` and do not broaden it to newly added `def test_*` found in other non-`test_*.py` Python files.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When using Kubernetes API models like `NodeSelectorRequirement` or `LabelSelectorRequirement` with operators `Exists` or `DoesNotExist`, the `values` field must not be non-empty. It is valid for `values` to be omitted / left as `None` (Python) / passed as `null`—Kubernetes rejects non-empty `values` for these operators, but does not require the field to be present or explicitly set to an empty list. In code reviews, do not treat missing `values=[]` for `Exists`/`DoesNotExist` as a validation issue; only flag cases where `values` is provided with actual elements.
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When constructing Kubernetes `NodeSelectorRequirement` (or `LabelSelectorRequirement`) objects in code, do not treat `values` being omitted, `None`, or an empty list as an API-validation problem when the requirement’s operator is `Exists` or `DoesNotExist`. Per the Kubernetes API spec, these operators only require that the `values` array is not non-empty (i.e., it must be empty); they do not require the field to be explicitly present as `[]`. Therefore, reviewers should not flag `values=None`/missing `values` for `Exists`/`DoesNotExist`.
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/test_migration_stuntime.py:33-38
Timestamp: 2026-05-19T17:16:55.817Z
Learning: In this repo’s test suite (under `tests/`), module-level triple-quoted string blocks used as STD documentation for shared preconditions (e.g., a `"""Preconditions: ..."""` block placed after `pytestmark`) are intentional. Do not flag them as dead code and do not suggest moving them into module/class docstrings or deleting them, as they are a consistent documentation convention across STD test modules.
as suggested by a reviewer Signed-off-by: Adam Cinko <acinko@redhat.com>
for more information, see https://pre-commit.ci
|
D/S test |
|
D/S test |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/storage/snapshots/conftest.py (1)
1-3:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHIGH: Restore missing PR template content before merge.
PR description is missing required template content for at least:
Which issue(s) this PR fixes, detailed reviewer notes/rationale, andjira-ticketURL/details. Please restore/fill all required template sections so automation and reviewers can validate scope/traceability.As per coding guidelines, required PR template sections must be present, and “What this PR does / why we need it” must contain meaningful content.
🤖 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/snapshots/conftest.py` around lines 1 - 3, The PR is missing required template sections—populate the PR description with the required fields: fill in "Which issue(s) this PR fixes" with the issue ID(s), complete "What this PR does / why we need it" with a concise rationale and summary of changes, add reviewer notes/rationale, and include the "jira-ticket" URL/details so automation and reviewers can validate scope and traceability; ensure these fields are present before merging.
🤖 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/snapshots/conftest.py`:
- Around line 119-120: The test currently picks a source volume via volumes[0]
which is flaky; change the selection logic for source_volume_name to
deterministically pick the volume that represents the persistent disk (e.g., the
first volume in rhel_vm_for_snapshot.instance.spec.template.spec.volumes that
contains a persistentVolumeClaim or whose name matches the expected data disk
rather than cloud-init). Replace the direct index access with a small
comprehension/loop that finds the volume with a persistentVolumeClaim (or
excludes known ephemeral names like "cloud-init") and assign that volume.name to
source_volume_name so restored_vm_name assertions target the correct restored
volume.
---
Outside diff comments:
In `@tests/storage/snapshots/conftest.py`:
- Around line 1-3: The PR is missing required template sections—populate the PR
description with the required fields: fill in "Which issue(s) this PR fixes"
with the issue ID(s), complete "What this PR does / why we need it" with a
concise rationale and summary of changes, add reviewer notes/rationale, and
include the "jira-ticket" URL/details so automation and reviewers can validate
scope and traceability; ensure these fields are present before merging.
🪄 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: c1997e73-92ec-4766-8a01-210058d31dc1
📒 Files selected for processing (2)
tests/storage/snapshots/conftest.pytests/storage/snapshots/test_snapshots.py
| with VirtualMachineRestore( | ||
| name=f"{restored_vm_name}-restore", | ||
| namespace=rhel_vm_for_snapshot.namespace, | ||
| vm_name=restored_vm_name, |
There was a problem hiding this comment.
The idea of the Snaphot-Restore is to restore the VM with the same name:
vm_name=rhel_vm_for_snapshot.name
When we want to restore to a VM with a different name, it's more of the VMClone flow than a VMRestore.
| vm_name=restored_vm_name, | ||
| snapshot_name=snapshot_with_content[0].name, | ||
| client=admin_client, | ||
| volume_restore_policy="PrefixTargetName", |
There was a problem hiding this comment.
Please make a change to the wrapper; currently, the wrapper has volume_name_policy
https://github.com/RedHatQE/openshift-python-wrapper/blob/main/ocp_resources/virtual_machine_restore.py#L50
But when you do oc explain VirtualMachineRestore.spec - there's no volumeNamePolicy, but there is volumeRestorePolicy
btw, I think it's a bug that there are no mentioned options for volumeRestorePolicy, how would we know the possible values?
$ oc explain VirtualMachineRestore.spec.volumeRestorePolicy
GROUP: snapshot.kubevirt.io
KIND: VirtualMachineRestore
VERSION: v1beta1
FIELD: volumeRestorePolicy <string>
DESCRIPTION:
VolumeRestorePolicy defines how to handle the restore of snapshotted volumes
There was a problem hiding this comment.
Should I just change the mapping spec["volumeNamePolicy"] to spec["volumeRestorePolicy"] in the wrapper?
There was a problem hiding this comment.
| def test_restore_snapshot_with_predictable_names( | ||
| self, | ||
| vm_restore_with_predictable_names, | ||
| ): |
There was a problem hiding this comment.
Please add the test description
| yield { | ||
| "restored_vm_name": restored_vm_name, | ||
| "source_volume_name": source_volume_name, | ||
| "vm_restore": vm_restore, | ||
| } |
There was a problem hiding this comment.
Wouldn't it be better to yield the whole vm_restore object? Then we can access all the properties/get all the resource fields that we need to use/check.
There was a problem hiding this comment.
I need the source volume name, so I will just remove the restored vm name since it's in the vm_restore object
|
Clean rebase detected — no code changes compared to previous head ( |
|
D/S test |
|
/wip |
|
/build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=7664e882ccbab8847a6331c797ece9cbe9f06aed |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4780 published |
Signed-off-by: Adam Cinko <acinko@redhat.com>
|
D/S test |
|
D/S test |
|
Clean rebase detected — no code changes compared to previous head ( |
|
D/S test |
Short description:
There's a feature that let's the user chose they want to restore a VM with predictable DV/PVC name derived from the vm-name from the snapshot.
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
Co-authored: Claude Code
https://redhat.atlassian.net/browse/CNV-80304
Depends of wrapper PR: RedHatQE/openshift-python-wrapper#2726
jira-ticket:
Summary by CodeRabbit
Tests
Chores