-
Notifications
You must be signed in to change notification settings - Fork 69
storage: STD for storage class migration cleanup #4340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,109 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Storage migration cleanup tests for MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Tests verify the retentionPolicy field functionality, which controls whether source DataVolumes/PVCs | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| are kept (keepSource) or deleted (deleteSource) after successful VM storage migration. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| The retentionPolicy field can be configured at: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Namespace level for MultiNamespaceVirtualMachineStorageMigrationPlan | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Spec level for MultiNamespaceVirtualMachineStorageMigrationPlan | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Combination of namespace and spec level for MultiNamespaceVirtualMachineStorageMigrationPlan | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| STP Reference: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| https://github.com/RedHatQE/openshift-virtualization-tests-design-docs/blob/main/stps/sig-storage/storage_mig_cleanup.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import pytest | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| __test__ = False | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH: Replace module-level Using module-level Proposed fix-__test__ = False
@@
class TestMultiNamespaceVirtualMachineStorageMigrationPlanRetentionPolicy:
@@
def test_retention_policy_default_behavior(self):
"""
...
"""
+ test_retention_policy_default_behavior.__test__ = False
@@
def test_namespace_level_retention_policy_delete_source(self):
"""
...
"""
+ test_namespace_level_retention_policy_delete_source.__test__ = False
@@
def test_spec_level_retention_policy_delete_source(self):
"""
...
"""
+ test_spec_level_retention_policy_delete_source.__test__ = False
@@
def test_combined_namespace_and_spec_level_retention_policy(self):
"""
...
"""
+ test_combined_namespace_and_spec_level_retention_policy.__test__ = FalseBased on learnings: STD placeholder tests under 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| class TestStorageMigrationRetentionPolicy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test retentionPolicy functionality for MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Preconditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - VM with source PVC/DataVolume | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.polarion("CNV-XXXXX") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM: Placeholder Polarion IDs and missing feature markers All tests use WHY: Polarion integration requires valid IDs for test tracking. Feature markers enable selective test execution and proper categorization. As per coding guidelines: "All new tests MUST have markers - check pytest.ini for available markers, NEVER commit unmarked tests." Also applies to: 48-48, 64-64, 95-95 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_retention_policy_default_behavior(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test that default behavior is keepSource when retentionPolicy is not specified in MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Preconditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Create MultiNamespaceVirtualMachineStorageMigrationPlan without retentionPolicy field | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| (neither spec-level nor namespace-level) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Wait for migration to complete successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Verify VM is using new PVC/DataVolume | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+37
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iiuc this should be part of the test setup - i.e the tested feature is to verify that after VM migration the source PVC is not deleted. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Verify source PVC/DataVolume still exists (default behavior) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expected: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Migration completes successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Source PVC/DataVolume is kept (default keepSource behavior) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - VM is running on new storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial LOW: Consider restructuring preconditions to align with fixture-based setup As noted by reviewer rnetser, migration completion and VM state verification (items 2-3 in preconditions) should be handled by fixtures, not listed as preconditions that might be confused with in-test verification steps. WHY: Test preconditions should describe the required state before the test runs. Migration execution and its success verification are setup responsibilities, typically handled by fixtures like The current structure mixes setup responsibilities with verification intent. Consider restructuring:
Also applies to: 49-62, 65-78 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.polarion("CNV-XXXXX") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_namespace_level_retention_policy_delete_source(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test namespace-level retentionPolicy=deleteSource in MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Preconditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Create MultiNamespaceVirtualMachineStorageMigrationPlan with namespace-level retentionPolicy=deleteSource | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Wait for migration to complete successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Verify VM is using new PVC/DataVolume | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Verify source PVC/DataVolume is deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expected: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Migration completes successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Source PVC/DataVolume is deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - VM is running on new storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.polarion("CNV-XXXXX") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_spec_level_retention_policy_delete_source(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test spec-level retentionPolicy=deleteSource in MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Preconditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Create MultiNamespaceVirtualMachineStorageMigrationPlan with spec-level retentionPolicy=deleteSource | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Wait for migration to complete successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Verify VM is using new PVC/DataVolume | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Verify source PVC/DataVolume is deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expected: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Migration completes successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Source PVC/DataVolume is deleted (spec-level policy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - VM is running on new storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| class TestStorageMigrationCombinedRetentionPolicy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test combination of retentionPolicy for MultiNamespaceVirtualMachineStorageMigrationPlan. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Preconditions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Two VMs with source PVCs/DataVolumes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Create MultiNamespaceVirtualMachineStorageMigrationPlan with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - spec-level retentionPolicy=keepSource | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - namespace-level retentionPolicy=deleteSource for specific namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. Wait for all migrations to complete successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4. Verify the two VMs are using new PVCs | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.polarion("CNV-XXXXX") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_combined_namespace_and_spec_level_retention_policy(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Test combination of namespace-level and spec-level retentionPolicy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Namespace-level policy should override spec-level policy for that namespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. Verify source PVCs in namespaces WITHOUT namespace-level policy are kept (spec-level policy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. Verify source PVCs in namespaces WITH namespace-level policy=deleteSource are deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expected: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - All migrations complete successfully | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Source PVCs in namespaces with namespace-level policy are deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Source PVCs in other namespaces are kept (spec-level policy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+96
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM: Missing required The WHY: Consistent docstring format enables tooling to parse and validate test definitions. The class-level preconditions should be referenced or restated in the test. Proposed fix def test_combined_namespace_and_spec_level_retention_policy(self):
"""
Test combination of namespace-level and spec-level retentionPolicy.
Namespace-level policy should override spec-level policy for that namespace.
+ Preconditions:
+ 1. Two VMs with source PVCs/DataVolumes in different namespaces
+ 2. MultiNamespaceVirtualMachineStorageMigrationPlan created with:
+ - spec-level retentionPolicy=keepSource
+ - namespace-level retentionPolicy=deleteSource for specific namespace
+ 3. All migrations completed successfully
+ 4. Both VMs verified using new PVCs
+
Steps:
1. Verify source PVCs in namespaces WITHOUT namespace-level policy are kept (spec-level policy)
2. Verify source PVCs in namespaces WITH namespace-level policy=deleteSource are deleted
Expected:
- All migrations complete successfully
- Source PVCs in namespaces with namespace-level policy are deleted
- Source PVCs in other namespaces are kept (spec-level policy)
"""As per coding guidelines: "STD test docstrings MUST follow format with Required sections: 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
MEDIUM: Place this new feature under a dedicated storage subdirectory
Current location (
tests/storage/test_storage_class_migration_cleanup.py) violates the repository test-layout rule for feature isolation. Please move it to a feature folder (example:tests/storage/storage_migration_cleanup/test_storage_class_migration_cleanup.py) to align discovery and ownership boundaries.As per coding guidelines: “Feature subdirectories REQUIRED - each feature MUST have its own subdirectory under component …”
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@duyanyan, the file is now correctly placed attests/storage/storage_migration/test_storage_class_migration_cleanup.py— that aligns with the feature-subdirectory layout rule. Thanks for addressing this! 🎉🧠 Learnings used
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!