🧪 Add tier0/tier1 RBAC e2e tests (MTA-856, MTA-866, MTA-867)#633
🧪 Add tier0/tier1 RBAC e2e tests (MTA-856, MTA-866, MTA-867)#633RanWurmbrand wants to merge 3 commits into
Conversation
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
📝 WalkthroughWalkthroughAdds three end-to-end tests covering namespace-admin migration, linked cluster-level RBAC export, and filtering of orphan ClusterRoles from migration output. ChangesCluster resource migration E2E coverage
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Test Coverage ReportTotal: 49.2% Per-package coverage
Full function-level detailsPosted by CI |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
e2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go (1)
50-69: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNo target-apply/validation step; test only checks export-side filtering.
Unlike the sibling tests in this cohort, this test never applies output to the target cluster nor validates the app comes up. That's likely intentional given the narrow focus (orphan
ClusterRolefiltering), but it means the test gives no signal on whether namespace-scoped resources still migrate correctly in this scenario.🤖 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 `@e2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go` around lines 50 - 69, Extend the test after RunCranePipelineWithChecks to apply the generated output to the target cluster and validate the migrated application becomes ready, following the sibling tier1 tests’ target-apply and app-validation flow. Keep the existing _cluster export-directory assertion for orphan ClusterRole filtering, and use the existing target/app validation helpers rather than adding new test infrastructure.
🤖 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 `@e2e-tests/tests/tier0/mta_866_na_no_cluster_resources_test.go`:
- Around line 77-88: Update the apply step following the “Applying namespace
resources to target as namespace-admin” marker to call ApplyDir on
kubectlTgtNonAdmin instead of kubectlTgt, preserving the existing output
directory and error assertion so the test exercises namespace-admin RBAC.
- Around line 27-32: Update the test setup in
mta_866_na_no_cluster_resources_test.go to use SetupActiveKubectlRunners,
allowing RUN_AS_ADMIN to select admin runners without requiring non-admin
contexts. Remove the standalone DeferCleanup(rbacCleanup) registration and
retain the existing cleanup invocation inside its closure so RBAC cleanup runs
only once.
---
Nitpick comments:
In `@e2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go`:
- Around line 50-69: Extend the test after RunCranePipelineWithChecks to apply
the generated output to the target cluster and validate the migrated application
becomes ready, following the sibling tier1 tests’ target-apply and
app-validation flow. Keep the existing _cluster export-directory assertion for
orphan ClusterRole filtering, and use the existing target/app validation helpers
rather than adding new test infrastructure.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6bfeb328-d4a8-463b-a567-ef5adfa085dc
📒 Files selected for processing (3)
e2e-tests/tests/tier0/mta_866_na_no_cluster_resources_test.goe2e-tests/tests/tier1/mta_856_multiple_crbs_minimal_rbac_test.goe2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go
335ed90 to
60e81c5
Compare
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
60e81c5 to
20392b0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@e2e-tests/tests/tier0/mta_866_na_no_cluster_resources_test.go`:
- Around line 70-72: Strengthen the assertion around HasFilesRecursively so it
verifies the error is specifically a missing-directory condition, using
errors.Is with fs.ErrNotExist rather than only checking that an error occurred.
Preserve the existing no-cluster-resources scenario while preventing unrelated
filepath.Walk failures from passing the test.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 86633712-de23-43b1-8a61-b87669430863
📒 Files selected for processing (3)
e2e-tests/tests/tier0/mta_866_na_no_cluster_resources_test.goe2e-tests/tests/tier1/mta_856_multiple_crbs_minimal_rbac_test.goe2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- e2e-tests/tests/tier1/mta_867_orphan_clusterrole_test.go
- e2e-tests/tests/tier1/mta_856_multiple_crbs_minimal_rbac_test.go
Signed-off-by: Ran Wurmbrand <rwurmbra@redhat.com>
|
those test was tested both on Minikube and ocp |
|
/rfr |
| Expect(clusterDir).NotTo(BeADirectory()) | ||
|
|
||
| By("Applying namespace resources to target as namespace-admin") | ||
| Expect(kubectlTgtNonAdmin.ApplyDir(filepath.Join(paths.OutputDir))).NotTo(HaveOccurred()) |
There was a problem hiding this comment.
Can be Replaced with Expect(ApplyOutputToTargetNonAdmin(kubectlTgtNonAdmin, paths.OutputDir)).NotTo(HaveOccurred()) ??
|
|
||
| By("Verifying orphan ClusterRole Did not migrate") | ||
| clusterDir := filepath.Join(paths.OutputDir, "resources", "_cluster") | ||
| _, _, err = utils.HasFilesRecursively(clusterDir) |
There was a problem hiding this comment.
better to use Expect(clusterDir).NotTo(BeADirectory())
aufi
left a comment
There was a problem hiding this comment.
Overall looks good 👍 , but deffering to colleagues with better background on E2E test suite with approval.
|
Medium severity
Low severity
Trivial
|
closes: #581
closes: #634
Summary
Add e2e test coverage for RBAC-related cluster-level export scenarios:
Verified
those test was tested both on Minikube and ocp
Test plan
ginkgo --label-filter="tier0" ./e2e-tests/...ginkgo --label-filter="tier1" ./e2e-tests/...Summary by CodeRabbit
Summary by CodeRabbit