Add E2E tests for update and reconciliation scenarios#183
Conversation
Signed-off-by: Ali Ok <aliok@redhat.com>
✅ Deploy Preview for mcp-lifecycle-operator ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aliok The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR adds new end-to-end (E2E) coverage for MCPServer update flows and reconciliation/drift scenarios, expanding the validation of controller behavior against real Kubernetes resources.
Changes:
- Added a new E2E test suite covering spec updates (image, storage), drift correction (replicas, service port), deletion/recreation, owner references, cascading deletion, and config-hash rollout behavior.
- Extended the E2E MCPServer builder options with
WithReplicasto configure runtime replica count.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/e2e/reconciliation_test.go | Introduces new reconciliation/update E2E scenarios validating controller behavior across multiple drift and mutation cases. |
| test/e2e/framework/builders.go | Adds WithReplicas option for constructing MCPServer CRs with a desired replica count in E2E tests. |
Comments suppressed due to low confidence (1)
test/e2e/reconciliation_test.go:249
- This ranges over dep.Spec.Template.Spec.Containers[0].VolumeMounts without checking that the pod template has at least one container. A defensive len(dep.Spec.Template.Spec.Containers) check would prevent a panic and provide a clearer assertion failure.
for _, m := range dep.Spec.Template.Spec.Containers[0].VolumeMounts {
if m.MountPath == "/etc/remove-config" {
t.Fatal("volume mount at /etc/remove-config should have been removed")
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| actualImage := dep.Spec.Template.Spec.Containers[0].Image | ||
| if actualImage != digestRef { | ||
| t.Fatalf("expected image %q, got %q", digestRef, actualImage) | ||
| } |
| if !foundVolume { | ||
| t.Fatal("expected ConfigMap volume 'add-config' after storage addition") | ||
| } | ||
|
|
| svc.Spec.Ports[0].Port = 9999 | ||
| if err := r.Update(ctx, svc); err != nil { | ||
| t.Fatalf("failed to change Service port: %v", err) | ||
| } |
Signed-off-by: Ali Ok <aliok@redhat.com>
| WithLabel("type", "reconciliation"). | ||
| WithLabel("scenario", "storage-add"). | ||
| Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
| ns := ctx.Value(f.NsKey).(string) |
| feature := features.New("MCPServer replica drift correction"). | ||
| WithLabel("type", "reconciliation"). | ||
| WithLabel("scenario", "drift-replicas"). | ||
| Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
| return f.SetupMCPServer(ctx, t, cfg, "drift-repl", true) | ||
| }). |
| } | ||
|
|
||
| hash := dep.Spec.Template.Annotations["mcp.x-k8s.io/config-hash"] | ||
| if hash == "" { | ||
| t.Fatal("expected config-hash annotation on pod template") |
Fixes #176
Add E2E tests for update and reconciliation scenarios