Skip to content

Add E2E tests for update and reconciliation scenarios#183

Open
aliok wants to merge 2 commits into
kubernetes-sigs:mainfrom
aliok:2026-05-15-e2e-update-reconciliation
Open

Add E2E tests for update and reconciliation scenarios#183
aliok wants to merge 2 commits into
kubernetes-sigs:mainfrom
aliok:2026-05-15-e2e-update-reconciliation

Conversation

@aliok
Copy link
Copy Markdown
Member

@aliok aliok commented May 15, 2026

Fixes #176

Add E2E tests for update and reconciliation scenarios

Signed-off-by: Ali Ok <aliok@redhat.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for mcp-lifecycle-operator ready!

Name Link
🔨 Latest commit 5d8f52a
🔍 Latest deploy log https://app.netlify.com/projects/mcp-lifecycle-operator/deploys/6a09a2d389eeb30007cb9914
😎 Deploy Preview https://deploy-preview-183--mcp-lifecycle-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 15, 2026
@aliok aliok requested a review from Copilot May 15, 2026 13:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 WithReplicas to 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.

Comment on lines +80 to +83
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")
}

Comment on lines +326 to +329
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

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)
Comment on lines +274 to +279
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)
}).
Comment on lines +598 to +602
}

hash := dep.Spec.Template.Annotations["mcp.x-k8s.io/config-hash"]
if hash == "" {
t.Fatal("expected config-hash annotation on pod template")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E Tests: Add update and reconciliation coverage

3 participants