Skip to content

Conversation

@kaovilai
Copy link
Member

@kaovilai kaovilai commented May 30, 2025

  • Add test files for all restore.go files that were missing tests
  • Update existing test files to improve coverage:
    • horizontalpodautoscaler: Add Execute() tests for all scenarios
    • pod: Add tests for AppliesTo(), PodHasVolumesToBackUp(), and PodHasRestoreHookAnnotations()
    • route: Add Execute() tests for route host generation scenarios
  • Add documentation comments explaining where Execute() functionality is tested for plugins that only test AppliesTo()
  • Fix failing tests by adjusting to match implementation behavior

Co-authored-by: Claude-Code

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 30, 2025
@kaovilai kaovilai force-pushed the unit_tests branch 2 times, most recently from 10fbc8e to c20f908 Compare June 2, 2025 20:04
- Add test files for all restore.go files that were missing tests
- Update existing test files to improve coverage:
  - horizontalpodautoscaler: Add Execute() tests for all scenarios
  - pod: Add tests for AppliesTo(), PodHasVolumesToBackUp(), and PodHasRestoreHookAnnotations()
  - route: Add Execute() tests for route host generation scenarios
- Add documentation comments explaining where Execute() functionality is tested for plugins that only test AppliesTo()
- Fix failing tests by adjusting to match implementation behavior
@kaovilai
Copy link
Member Author

kaovilai commented Jun 3, 2025

/cherry-pick oadp-1.5 oadp-1.4

@openshift-cherrypick-robot
Copy link
Contributor

@kaovilai: once the present PR merges, I will cherry-pick it on top of oadp-1.5 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick oadp-1.5 oadp-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kaovilai
Copy link
Member Author

kaovilai commented Jun 3, 2025

/hold for #315
and #316 to merge first

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 3, 2025
@kaovilai
Copy link
Member Author

kaovilai commented Jun 3, 2025

/cherry-pick oadp-1.4

@openshift-cherrypick-robot
Copy link
Contributor

@kaovilai: once the present PR merges, I will cherry-pick it on top of oadp-1.4 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick oadp-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 28, 2025
@kaovilai
Copy link
Member Author

/test all

@kaovilai
Copy link
Member Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 28, 2025
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 27, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Walkthrough

This PR adds unit test coverage across 22 Velero restore plugins under velero-plugins/. Most tests validate the AppliesTo method to verify correct resource selectors, while several include Execute method tests covering transformation logic such as namespace mapping, registry swapping, annotation handling, and resource filtering.

Changes

Cohort / File(s) Summary
Simple AppliesTo Tests
velero-plugins/buildconfig/restore_test.go, velero-plugins/cronjob/restore_test.go, velero-plugins/daemonset/restore_test.go, velero-plugins/deployment/restore_test.go, velero-plugins/deploymentconfig/restore_test.go, velero-plugins/imagetag/restore_test.go, velero-plugins/replicaset/restore_test.go, velero-plugins/statefulset/restore_test.go
Adds TestRestorePluginAppliesTo validating resource selector includes expected resource types.
AppliesTo and Execute Tests
velero-plugins/configmap/restore_test.go
Tests AppliesTo for "configmaps" and Execute with table-driven cases covering annotation-based SkipRestore decisions (nil, empty, explicit true/false, invalid, unrelated annotations).
Job and ReplicationController Ownership Logic
velero-plugins/job/restore_test.go, velero-plugins/replicationcontroller/restore_test.go
Tests AppliesTo and Execute with OwnerReference validation; skips restore when owned by CronJob or DeploymentConfig (unless paused).
PersistentVolume and PVC Migration Tests
velero-plugins/persistentvolume/restore_test.go, velero-plugins/pvc/restore_test.go
Tests AppliesTo and Execute covering non-migration restores, snapshot PV skipping on stage-restore, and storageClassName handling based on migration annotations.
Pod Volume and Hook Annotation Tests
velero-plugins/pod/restore_test.go
Tests AppliesTo, PodHasVolumesToBackUp, and PodHasRestoreHookAnnotations covering volume types and hook detection logic.
RoleBindings Namespace Mapping
velero-plugins/rolebindings/restore_test.go
Adds exported helper functions SwapSubjectNamespaces, SwapUserNamesNamespaces, SwapGroupNamesNamespaces; refactors tests to unit-test transformation logic instead of end-to-end Execute path.
Route Host Generation
velero-plugins/route/restore_test.go
Tests Execute with table-driven cases verifying host field removal when openshift.io/host.generated annotation is true.
SCC Namespace Mapping
velero-plugins/scc/restore_test.go
Tests AppliesTo and Execute with namespace mapping for system:serviceaccount users in SecurityContextConstraints.
Secret Originating Service Annotation
velero-plugins/secret/restore_test.go
Tests AppliesTo and Execute covering SkipRestore when originating-service annotation is present.
Service External IP Handling
velero-plugins/service/restore_test.go
Tests AppliesTo and Execute verifying ExternalIPs are cleared for LoadBalancer service type but preserved for ClusterIP, NodePort, ExternalName.
ServiceAccount Dockercfg Secret Removal
velero-plugins/serviceaccount/restore_test.go
Tests AppliesTo and Execute to verify dockercfg secrets are removed from both secrets and imagePullSecrets fields.
HorizontalPodAutoscaler API Version Update
velero-plugins/horizontalpodautoscaler/restore_test.go
Tests Execute with table-driven cases updating scaleTargetRef.apiVersion to v1 for DeploymentConfig targets, leaving unchanged for other cases.
ClusterRoleBindings Resource Selection
velero-plugins/clusterrolebindings/restore_test.go
Tests AppliesTo verifying ResourceSelector includes clusterrolebinding.authorization.openshift.io.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Rolebindings exported functions: Review new public helper functions (SwapSubjectNamespaces, SwapUserNamesNamespaces, SwapGroupNamesNamespaces) for correctness, namespace mapping logic, and service account handling.
  • Configmap Execute tests: Validate table-driven test structure and annotation parsing logic for SkipRestore decisions.
  • PersistentVolume and PVC migration logic: Verify stage-restore skipping conditions and storageClassName annotation handling.
  • Service external IP logic: Confirm conditional clearing based on service type and proper field manipulation.
  • Ownership and namespace mapping tests: Ensure OwnerReference comparisons and namespace mapping transformations are correct across job, replicationcontroller, scc, and rolebindings.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
velero-plugins/service/restore_test.go (1)

22-98: Good coverage of service types.

The table-driven test covers all four Kubernetes service types. The verification logic correctly handles the unstructured type conversion.

Consider adding a test case for a LoadBalancer service with no initial ExternalIPs to verify the plugin handles nil/empty gracefully.

 		{
 			name:                     "ExternalName service - keeps ExternalIPs",
 			serviceType:              corev1.ServiceTypeExternalName,
 			externalIPs:              []string{"1.2.3.4", "5.6.7.8"},
 			expectExternalIPsCleared: false,
 		},
+		{
+			name:                     "LoadBalancer service with no ExternalIPs",
+			serviceType:              corev1.ServiceTypeLoadBalancer,
+			externalIPs:              nil,
+			expectExternalIPsCleared: true,
+		},
 	}
velero-plugins/serviceaccount/restore_test.go (1)

146-154: Consider adding assertions for secret names, not just counts.

The test verifies the correct count of secrets but doesn't validate that the correct secrets remain. If the implementation has a bug that removes the wrong secret, this test would still pass.

 			// Check secrets
 			outputSecrets, ok := outputObj["secrets"].([]interface{})
 			require.True(t, ok)
 			assert.Len(t, outputSecrets, len(tt.expectedSecrets))
+			for i, expected := range tt.expectedSecrets {
+				secretMap := outputSecrets[i].(map[string]interface{})
+				assert.Equal(t, expected.Name, secretMap["name"])
+			}
 
 			// Check imagePullSecrets
 			outputImagePullSecrets, ok := outputObj["imagePullSecrets"].([]interface{})
 			require.True(t, ok)
 			assert.Len(t, outputImagePullSecrets, len(tt.expectedImagePullSecrets))
+			for i, expected := range tt.expectedImagePullSecrets {
+				secretMap := outputImagePullSecrets[i].(map[string]interface{})
+				assert.Equal(t, expected.Name, secretMap["name"])
+			}
velero-plugins/persistentvolume/restore_test.go (1)

80-147: Good table-driven test for storageClassName handling.

The test correctly validates that storageClassName is set when PvCopyAction annotation is present and absent otherwise. The table-driven approach is clean and the assertions properly check both value and presence.

Consider adding test scenarios for:

  • PV with PvCopyAction but no MigrateStorageClassAnnotation
  • PV with existing storageClassName being overwritten

This would further strengthen the test coverage, though current scenarios cover the main paths.

velero-plugins/horizontalpodautoscaler/restore_test.go (2)

7-12: Consider removing unused expectedScaleTargetRef (and its type import).

expectedScaleTargetRef v2beta1.CrossVersionObjectReference is never set or asserted in the tests, so the only effect is to keep the autoscaling/v2beta1 import alive. That’s a bit misleading for readers and slightly hurts maintainability.

If you don’t plan to assert on a fully-typed CrossVersionObjectReference, consider dropping this field and the v2beta1 import to keep the test focused and minimal.

Also applies to: 27-27


22-164: Table-driven Execute tests look solid; consider an explicit expectError flag.

The scenarios cover the key behaviors of the restore plugin (DC v1→apps.openshift.io/v1, already-correct DC, Deployment, missing scaleTargetRef, and invalid API version) and the assertions on spec.scaleTargetRef.apiVersion vs. unchanged items look good.

One small maintainability tweak: instead of special-casing the error-path with if tt.name == "HPA with invalid API version should return error", add an expectError bool field to the table and branch on that. It’s less brittle if names change or new error cases are added.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 0b73ea6 and 31223f7.

📒 Files selected for processing (22)
  • velero-plugins/buildconfig/restore_test.go (1 hunks)
  • velero-plugins/clusterrolebindings/restore_test.go (1 hunks)
  • velero-plugins/configmap/restore_test.go (1 hunks)
  • velero-plugins/cronjob/restore_test.go (1 hunks)
  • velero-plugins/daemonset/restore_test.go (1 hunks)
  • velero-plugins/deployment/restore_test.go (1 hunks)
  • velero-plugins/deploymentconfig/restore_test.go (1 hunks)
  • velero-plugins/horizontalpodautoscaler/restore_test.go (2 hunks)
  • velero-plugins/imagetag/restore_test.go (1 hunks)
  • velero-plugins/job/restore_test.go (1 hunks)
  • velero-plugins/persistentvolume/restore_test.go (1 hunks)
  • velero-plugins/pod/restore_test.go (2 hunks)
  • velero-plugins/pvc/restore_test.go (1 hunks)
  • velero-plugins/replicaset/restore_test.go (1 hunks)
  • velero-plugins/replicationcontroller/restore_test.go (1 hunks)
  • velero-plugins/rolebindings/restore_test.go (4 hunks)
  • velero-plugins/route/restore_test.go (2 hunks)
  • velero-plugins/scc/restore_test.go (1 hunks)
  • velero-plugins/secret/restore_test.go (1 hunks)
  • velero-plugins/service/restore_test.go (1 hunks)
  • velero-plugins/serviceaccount/restore_test.go (1 hunks)
  • velero-plugins/statefulset/restore_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • velero-plugins/deploymentconfig/restore_test.go
  • velero-plugins/statefulset/restore_test.go
  • velero-plugins/daemonset/restore_test.go
  • velero-plugins/clusterrolebindings/restore_test.go
  • velero-plugins/pod/restore_test.go
  • velero-plugins/horizontalpodautoscaler/restore_test.go
  • velero-plugins/replicationcontroller/restore_test.go
  • velero-plugins/route/restore_test.go
  • velero-plugins/secret/restore_test.go
  • velero-plugins/job/restore_test.go
  • velero-plugins/pvc/restore_test.go
  • velero-plugins/configmap/restore_test.go
  • velero-plugins/serviceaccount/restore_test.go
  • velero-plugins/persistentvolume/restore_test.go
  • velero-plugins/scc/restore_test.go
  • velero-plugins/deployment/restore_test.go
  • velero-plugins/service/restore_test.go
  • velero-plugins/cronjob/restore_test.go
  • velero-plugins/buildconfig/restore_test.go
  • velero-plugins/imagetag/restore_test.go
  • velero-plugins/rolebindings/restore_test.go
  • velero-plugins/replicaset/restore_test.go
🧬 Code graph analysis (12)
velero-plugins/deploymentconfig/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/daemonset/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/pod/restore_test.go (3)
velero-plugins/pod/restore.go (3)
  • RestorePlugin (31-34)
  • PodHasVolumesToBackUp (44-51)
  • PodHasRestoreHookAnnotations (61-73)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/common/types.go (2)
  • PostRestoreHookAnnotation (111-111)
  • InitContainerRestoreHookAnnotation (113-113)
velero-plugins/horizontalpodautoscaler/restore_test.go (2)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginExecute (20-148)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/secret/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/job/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/configmap/restore_test.go (2)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/common/types.go (1)
  • SkipBuildConfigConfigMapRestore (29-29)
velero-plugins/scc/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/cronjob/restore_test.go (16)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/buildconfig/restore_test.go (4)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/imagetag/restore_test.go (17)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicaset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/util/test/test_logger.go (1)
  • NewLogger (10-14)
velero-plugins/replicaset/restore_test.go (16)
velero-plugins/buildconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/clusterrolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/configmap/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/cronjob/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/daemonset/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deployment/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/deploymentconfig/restore_test.go (1)
  • TestRestorePluginAppliesTo (12-17)
velero-plugins/horizontalpodautoscaler/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/imagetag/restore_test.go (1)
  • TestRestorePluginAppliesTo (14-19)
velero-plugins/job/restore_test.go (1)
  • TestRestorePluginAppliesTo (15-20)
velero-plugins/persistentvolume/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/pod/restore_test.go (1)
  • TestRestorePluginAppliesTo (177-182)
velero-plugins/pvc/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/replicationcontroller/restore_test.go (1)
  • TestRestorePluginAppliesTo (16-21)
velero-plugins/rolebindings/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
velero-plugins/route/restore_test.go (1)
  • TestRestorePluginAppliesTo (13-18)
🔇 Additional comments (43)
velero-plugins/cronjob/restore_test.go (2)

12-17: LGTM! Clean test implementation.

The AppliesTo test correctly validates the resource selector for cronjobs. The test structure is clear and uses appropriate assertions.


19-22: Good documentation of Execute() test coverage.

The comment clearly explains where Execute() functionality is validated through component tests, which helps maintainers understand the complete test strategy.

velero-plugins/statefulset/restore_test.go (1)

12-17: LGTM! Consistent test pattern.

The test correctly validates the statefulsets.apps resource selector, maintaining consistency with other plugin tests in this PR.

velero-plugins/daemonset/restore_test.go (1)

12-17: LGTM! Proper resource selector validation.

The test correctly validates the daemonsets.apps resource selector with appropriate assertions.

velero-plugins/buildconfig/restore_test.go (2)

12-17: LGTM! Buildconfig resource selector test is correct.

The test properly validates the buildconfigs resource selector.


19-24: Helpful documentation of test strategy.

The comment provides good context about how Execute() is validated through build.UpdateCommonSpec() and related helper tests, including specific details about secret updates and image reference handling.

velero-plugins/job/restore_test.go (2)

15-20: LGTM! AppliesTo test is correct.

The test properly validates the jobs resource selector.


22-89: Excellent Execute() test coverage.

The table-driven test comprehensively validates the skip logic for Jobs owned by CronJobs. The three test cases correctly cover:

  • Independent Jobs (should restore)
  • CronJob-managed Jobs (should skip - CronJob will recreate)
  • Jobs with other owners (should restore)

The test structure is clean and maintainable.

velero-plugins/replicaset/restore_test.go (1)

12-17: LGTM! Replicaset resource selector test is correct.

The test properly validates the replicasets.apps resource selector.

velero-plugins/clusterrolebindings/restore_test.go (2)

12-17: LGTM! ClusterRoleBinding resource selector test is correct.

The test properly validates the OpenShift-specific clusterrolebinding resource selector.


19-24: Clear documentation of shared test coverage.

The comment effectively explains that Execute() behavior is validated through rolebindings tests, documenting the shared helper functions for namespace mapping.

velero-plugins/replicationcontroller/restore_test.go (2)

16-21: LGTM! AppliesTo test is correct.

The test properly validates the replicationcontrollers resource selector.


23-147: Excellent Execute() test coverage with important edge cases.

The table-driven test comprehensively validates the skip logic for ReplicationControllers, including the critical paused annotation handling:

  • Independent RCs (should restore)
  • DeploymentConfig-managed RCs (should skip - DC will recreate)
  • Paused DeploymentConfig-managed RCs (should restore - DC won't recreate)
  • RCs with other owners (should restore)

The test correctly uses the common.PausedOwnerRef constant and includes realistic object structures with container specs.

velero-plugins/deploymentconfig/restore_test.go (1)

12-17: LGTM!

The test correctly follows the established pattern for AppliesTo() tests across the codebase, verifying that the plugin targets "deploymentconfigs" resources.

velero-plugins/secret/restore_test.go (2)

14-19: LGTM!

The AppliesTo() test follows the established pattern, correctly verifying the plugin targets "secrets" resources.


21-78: Well-structured table-driven test.

The test comprehensively covers all SkipRestore scenarios for secrets with originating service annotations. The four test cases appropriately cover: no annotations, only the originating service annotation, other annotations, and mixed annotations.

velero-plugins/deployment/restore_test.go (1)

12-17: LGTM!

The test correctly uses "deployments.apps" for the resource selector, consistent with other .apps group resources like daemonsets.apps and replicasets.apps.

velero-plugins/imagetag/restore_test.go (2)

14-19: LGTM!

The AppliesTo() test correctly verifies the plugin targets "imagetags" resources.


21-38: LGTM!

The test validates the expected behavior that ImageTag resources are always skipped during restore. The test setup correctly uses the OpenShift image.openshift.io/v1 API version.

velero-plugins/service/restore_test.go (1)

15-20: LGTM!

The AppliesTo() test correctly verifies the plugin targets "services" resources.

velero-plugins/pod/restore_test.go (4)

176-182: LGTM!

The test follows the established pattern used across other plugin test files, correctly validating that the plugin targets pods resources.


184-245: LGTM!

Good test coverage for PodHasVolumesToBackUp with meaningful scenarios: no volumes, PVC-backed volume (should backup), and ConfigMap volume (should not backup).


247-304: LGTM!

The test cases correctly cover the annotation detection logic, including nil annotations, both hook annotation types, and unrelated annotations.


306-310: LGTM!

Good documentation explaining why certain functions aren't unit tested and suggesting integration tests as the appropriate approach.

velero-plugins/serviceaccount/restore_test.go (1)

15-20: LGTM!

Standard AppliesTo test pattern, correctly validates the plugin targets serviceaccounts.

velero-plugins/configmap/restore_test.go (2)

14-19: LGTM!

Standard AppliesTo test following the established pattern.


21-88: LGTM!

Comprehensive test coverage for the Execute method, covering all meaningful annotation scenarios including edge cases like invalid values.

velero-plugins/scc/restore_test.go (2)

14-19: LGTM!

Standard AppliesTo test correctly validates the plugin targets securitycontextconstraints.


56-94: LGTM!

Good test coverage for namespace mapping scenarios including service account transformation, regular users, mixed cases, and empty mapping.

velero-plugins/route/restore_test.go (3)

13-18: LGTM!

Standard AppliesTo test correctly validates the plugin targets routes.


20-148: LGTM!

Comprehensive test coverage for the Execute method with well-structured test cases covering the host stripping logic based on the openshift.io/host.generated annotation.


150-152: LGTM!

Helpful documentation explaining the testing limitations for error paths.

velero-plugins/pvc/restore_test.go (3)

16-21: LGTM! AppliesTo validation is correct.

The test properly validates that the plugin targets PersistentVolumeClaim resources.


23-47: LGTM! Non-migration test coverage is solid.

The test correctly validates that non-migration restores pass through unchanged with SkipRestore=false.


49-80: LGTM! Stage restore skip behavior is correctly tested.

The test properly validates that PVCs with snapshot copy method are skipped during stage restore.

velero-plugins/persistentvolume/restore_test.go (3)

16-21: LGTM! AppliesTo validation is correct.

The test properly validates that the plugin targets PersistentVolume resources.


23-46: LGTM! Non-migration test is correct.

The test properly validates that non-migration restores return the item unchanged without skipping.


48-78: LGTM! Stage restore skip test is correct.

The test properly validates that PVs with snapshot copy method are skipped during stage restore.

velero-plugins/rolebindings/restore_test.go (5)

13-18: LGTM! AppliesTo test is correct.

The test properly validates that the plugin targets rolebinding resources.


20-24: Excellent documentation of test coverage approach.

This comment clearly explains that Execute() functionality is tested through the helper functions, which is a valuable addition for future maintainers.


26-109: LGTM! Comprehensive test coverage for subject namespace swapping.

The test cases thoroughly cover different subject kinds, successful mappings, missing mappings, and namespace-less subjects. Well-structured table-driven test.


111-150: LGTM! Thorough test coverage for UserNames namespace swapping.

The test scenarios cover service account usernames, regular usernames, missing mappings, and mixed inputs. The assertions correctly validate the expected namespace transformations.


152-185: LGTM! Complete test coverage for GroupNames namespace swapping.

The test scenarios appropriately cover service accounts groups, regular groups, and missing mappings. The assertions validate the correct behavior.

@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Dec 28, 2025
@openshift-ci
Copy link

openshift-ci bot commented Dec 28, 2025

@openshift-bot: Closed this PR.

Details

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kaovilai kaovilai reopened this Jan 19, 2026
@kaovilai
Copy link
Member Author

/test all

@openshift-ci
Copy link

openshift-ci bot commented Jan 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kaovilai, shubham-pampattiwar, sseago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [kaovilai,shubham-pampattiwar,sseago]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kaovilai kaovilai added ai-generated-test lgtm Indicates that a PR is ready to be merged. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jan 19, 2026
@openshift-ci
Copy link

openshift-ci bot commented Jan 19, 2026

@kaovilai: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit b1a2756 into openshift:oadp-dev Jan 19, 2026
4 checks passed
@openshift-cherrypick-robot
Copy link
Contributor

@kaovilai: new pull request created: #370

Details

In response to this:

/cherry-pick oadp-1.5 oadp-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-cherrypick-robot
Copy link
Contributor

@kaovilai: new pull request created: #371

Details

In response to this:

/cherry-pick oadp-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated-test approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants