-
Notifications
You must be signed in to change notification settings - Fork 170
Add MCPRemoteProxy controller integration tests #3376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive integration tests for the MCPRemoteProxy controller covering basic functionality as outlined in issue #3362: - Deployment creation and validation (labels, ServiceAccount, ports) - Service creation and validation (labels, selectors, ports) - ConfigMap (RunConfig) creation with content validation - RBAC resource creation (ServiceAccount, Role, RoleBinding) - Status condition tracking (Ready, Phase, ObservedGeneration, URL) - AuthConfigured condition for valid OIDC config Co-Authored-By: Claude Opus 4.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3376 +/- ##
==========================================
- Coverage 64.82% 64.76% -0.07%
==========================================
Files 375 375
Lines 36626 36626
==========================================
- Hits 23744 23720 -24
- Misses 11011 11035 +24
Partials 1871 1871 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jerm-dro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| By("verifying the Deployment has correct labels") | ||
| Expect(deployment.Labels).To(HaveKeyWithValue("app", "mcpremoteproxy")) | ||
| Expect(deployment.Labels).To(HaveKeyWithValue("app.kubernetes.io/name", "mcpremoteproxy")) | ||
| Expect(deployment.Labels).To(HaveKeyWithValue("app.kubernetes.io/instance", proxy.Name)) | ||
| Expect(deployment.Labels).To(HaveKeyWithValue("toolhive", "true")) | ||
| Expect(deployment.Labels).To(HaveKeyWithValue("toolhive-name", proxy.Name)) | ||
|
|
||
| By("verifying the Deployment has correct spec") | ||
| Expect(deployment.Spec.Replicas).NotTo(BeNil()) | ||
| Expect(*deployment.Spec.Replicas).To(Equal(int32(1))) | ||
|
|
||
| By("verifying the Deployment has correct selector labels") | ||
| Expect(deployment.Spec.Selector.MatchLabels).To(HaveKeyWithValue("app", "mcpremoteproxy")) | ||
| Expect(deployment.Spec.Selector.MatchLabels).To(HaveKeyWithValue("toolhive-name", proxy.Name)) | ||
|
|
||
| By("verifying the pod template has correct labels") | ||
| Expect(deployment.Spec.Template.Labels).To(HaveKeyWithValue("app", "mcpremoteproxy")) | ||
| Expect(deployment.Spec.Template.Labels).To(HaveKeyWithValue("toolhive", "true")) | ||
|
|
||
| By("verifying the container configuration") | ||
| Expect(deployment.Spec.Template.Spec.Containers).To(HaveLen(1)) | ||
| container := deployment.Spec.Template.Spec.Containers[0] | ||
| Expect(container.Name).To(Equal("toolhive")) | ||
| Expect(container.Ports).To(HaveLen(1)) | ||
| Expect(container.Ports[0].ContainerPort).To(Equal(int32(8080))) | ||
| Expect(container.Ports[0].Name).To(Equal("http")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, non-blocking: are there helper functions that would allow these assertions to be more declarative?
Ideally, we'd write Expect(actualDeployment).To(Equal(expectedDeployments), so the tests are less gingko boilerplate.
|
|
||
| By("verifying the Deployment uses the correct ServiceAccount") | ||
| expectedServiceAccountName := fmt.Sprintf("%s-remote-proxy-runner", proxy.Name) | ||
| Expect(deployment.Spec.Template.Spec.ServiceAccountName).To(Equal(expectedServiceAccountName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, non-blocking: You could just pull these lines up to the test above. No need to create a brand new Deployment.
| By("verifying the Service has correct labels") | ||
| Expect(service.Labels).To(HaveKeyWithValue("app", "mcpremoteproxy")) | ||
| Expect(service.Labels).To(HaveKeyWithValue("app.kubernetes.io/name", "mcpremoteproxy")) | ||
| Expect(service.Labels).To(HaveKeyWithValue("app.kubernetes.io/instance", proxy.Name)) | ||
| Expect(service.Labels).To(HaveKeyWithValue("toolhive", "true")) | ||
|
|
||
| By("verifying the Service port configuration") | ||
| Expect(service.Spec.Ports).To(HaveLen(1)) | ||
| Expect(service.Spec.Ports[0].Port).To(Equal(int32(8080))) | ||
| Expect(service.Spec.Ports[0].Name).To(Equal("http")) | ||
|
|
||
| By("verifying the Service selector") | ||
| Expect(service.Spec.Selector).To(HaveKeyWithValue("app", "mcpremoteproxy")) | ||
| Expect(service.Spec.Selector).To(HaveKeyWithValue("toolhive-name", proxy.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Again, these assertions could be made on the MCPRemoteProxy from line 49.
|
|
||
| // NewRemoteProxyBuilder creates a new MCPRemoteProxy builder with sensible defaults | ||
| // for required fields (RemoteURL, OIDCConfig) so tests only need to override what they're testing | ||
| func (h *MCPRemoteProxyTestHelper) NewRemoteProxyBuilder(name string) *RemoteProxyBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion, feel free to ignore: you might be able to get rid of these helpers if you reuse the MCPRemoteProxy for more tests. That would also improve test readibility. For example, for one of the tests, I wondered "where does 'remote.example.com' come from?"
| RunSpecs(t, "MCPRemoteProxy Controller Integration Test Suite", suiteConfig, reporterConfig) | ||
| } | ||
|
|
||
| var _ = BeforeSuite(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking, for my education: do we really have to redefine these for every directory in test-integration? How could we avoid doing this?
Summary
Test plan
task operator-test-integrationto verify tests pass