🧪 Add e2e test for multi-container pod migration#632
Conversation
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a tier0 Ginkgo test for migrating an nginx deployment with a sidecar. It validates source and target container counts, runs the Crane export-transform-apply pipeline, and verifies both target container images. ChangesMulti-container migration validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
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: 47.8% Per-package coverage
Full function-level detailsPosted by CI |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
e2e-tests/tests/tier0/mta_838_multi_container_stateless_migration_test.go (2)
59-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSource verification only checks container count, not names and images.
The target verification (lines 134-144) checks container names and images, but the source verification (lines 59-75) only checks
HaveLen(2). If the source deployment was set up with incorrect container names or images, the failure would surface at the target stage with a misleading error message. Verifying source container names and images here would provide faster, clearer diagnostics.🤖 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/tier0/mta_838_multi_container_stateless_migration_test.go` around lines 59 - 75, Enhance the source verification in the deployment inspection flow by validating each entry in containers, not only its length. Assert that the source containers have the expected names and images, matching the checks used in the target verification, while preserving the existing two-container count assertion.
64-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract shared helper for deployment container extraction.
The source (lines 64-75) and target (lines 111-121) verification blocks contain near-identical JSON unmarshaling and
spec.template.spec.containersnavigation logic. Extracting a helper would eliminate duplication and reduce the risk of the two blocks diverging.♻️ Proposed helper extraction
+// getDeploymentContainers unmarshals deployment JSON and returns the pod template containers. +func getDeploymentContainers(jsonStr string) ([]any, error) { + var deployment map[string]any + if err := json.Unmarshal([]byte(jsonStr), &deployment); err != nil { + return nil, err + } + spec, ok := deployment["spec"].(map[string]any) + if !ok { + return nil, fmt.Errorf("spec should be a map") + } + template, ok := spec["template"].(map[string]any) + if !ok { + return nil, fmt.Errorf("template should be a map") + } + podSpec, ok := template["spec"].(map[string]any) + if !ok { + return nil, fmt.Errorf("podSpec should be a map") + } + containers, ok := podSpec["containers"].([]any) + if !ok { + return nil, fmt.Errorf("containers should be a slice") + } + return containers, nil +}Then replace both blocks with:
- var deploymentSrc map[string]any - Expect(json.Unmarshal([]byte(deploymentOut), &deploymentSrc)).NotTo(HaveOccurred()) - spec, ok := deploymentSrc["spec"].(map[string]any) - Expect(ok).To(BeTrue(), "spec should be a map") - template, ok := spec["template"].(map[string]any) - Expect(ok).To(BeTrue(), "template should be a map") - podSpec, ok := template["spec"].(map[string]any) - Expect(ok).To(BeTrue(), "podSpec should be a map") - containers, ok := podSpec["containers"].([]any) - Expect(ok).To(BeTrue(), "containers should be a slice") + containers, err := getDeploymentContainers(deploymentOut) + Expect(err).NotTo(HaveOccurred()) Expect(containers).To(HaveLen(2), "source deployment should have 2 containers")Also applies to: 111-121
🤖 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/tier0/mta_838_multi_container_stateless_migration_test.go` around lines 64 - 75, Extract the repeated JSON navigation from the source and target verification blocks into a shared helper that unmarshals a deployment and returns its spec.template.spec.containers slice, preserving the existing assertion messages and container-count checks at each call site. Replace both inline extraction sequences with calls to the helper, using the visible test function and deployment verification flow as the integration points.
🤖 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_838_multi_container_stateless_migration_test.go`:
- Around line 43-57: Move the DeferCleanup registration in the test setup to
immediately after successful NewScenarioPaths and before PrepareSourceApp, while
retaining the existing CleanupScenario callback and source/target app arguments.
Keep the export, transform, and apply option initialization unchanged.
---
Nitpick comments:
In `@e2e-tests/tests/tier0/mta_838_multi_container_stateless_migration_test.go`:
- Around line 59-75: Enhance the source verification in the deployment
inspection flow by validating each entry in containers, not only its length.
Assert that the source containers have the expected names and images, matching
the checks used in the target verification, while preserving the existing
two-container count assertion.
- Around line 64-75: Extract the repeated JSON navigation from the source and
target verification blocks into a shared helper that unmarshals a deployment and
returns its spec.template.spec.containers slice, preserving the existing
assertion messages and container-count checks at each call site. Replace both
inline extraction sequences with calls to the helper, using the visible test
function and deployment verification flow as the integration points.
🪄 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: c4fbc2ea-b53b-47ba-92db-d5c0575e8b0b
📒 Files selected for processing (1)
e2e-tests/tests/tier0/mta_838_multi_container_stateless_migration_test.go
|
Tested on OCP successfully. |
|
/rfr |
|
thanks, minor comments |
RanWurmbrand
left a comment
There was a problem hiding this comment.
think we could replace all of these checks with single kubectl & umarshal commands.
what do you think?
…ion_test.go Co-authored-by: RanWurmbrand <rwurmbra@redhat.com>
Summary
migration
intact
cluster
Test plan
images
Polarion: MTA-838
Summary by CodeRabbit