Skip to content

Commit 894099a

Browse files
committed
Add e2e tests for pod template spec changes
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
1 parent 120e08d commit 894099a

File tree

9 files changed

+157
-0
lines changed

9 files changed

+157
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: toolhive.stacklok.dev/v1alpha1
2+
kind: MCPServer
3+
metadata:
4+
name: invalid-podtemplate
5+
namespace: toolhive-system
6+
status:
7+
conditions:
8+
- type: PodTemplateValid
9+
status: "False"
10+
reason: InvalidPodTemplateSpec
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: List
3+
items:
4+
- apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: invalid-podtemplate
8+
namespace: toolhive-system
9+
(x-chainsaw-assert/exists): false
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: chainsaw.kyverno.io/v1alpha1
2+
kind: Test
3+
metadata:
4+
name: invalid-podtemplatespec
5+
spec:
6+
description: Tests that MCPServer with invalid PodTemplateSpec blocks deployment creation
7+
timeouts:
8+
apply: 30s
9+
assert: 60s
10+
cleanup: 30s
11+
steps:
12+
- name: verify-operator
13+
description: Ensure operator is ready before testing
14+
try:
15+
- assert:
16+
file: ../../setup/assert-operator-ready.yaml
17+
18+
- name: deploy-mcpserver-with-invalid-podtemplatespec
19+
description: Deploy MCPServer with invalid PodTemplateSpec and verify deployment is blocked
20+
try:
21+
- apply:
22+
file: mcpserver-invalid.yaml
23+
- assert:
24+
file: mcpserver-invalid.yaml
25+
- assert:
26+
file: assert-mcpserver-invalid-condition.yaml
27+
- assert:
28+
file: assert-no-deployment.yaml
29+
30+
- name: cleanup
31+
description: Clean up the invalid MCPServer
32+
try:
33+
- delete:
34+
ref:
35+
apiVersion: toolhive.stacklok.dev/v1alpha1
36+
kind: MCPServer
37+
name: invalid-podtemplate
38+
namespace: toolhive-system
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: toolhive.stacklok.dev/v1alpha1
2+
kind: MCPServer
3+
metadata:
4+
name: invalid-podtemplate
5+
namespace: toolhive-system
6+
spec:
7+
image: ghcr.io/stackloklabs/mcp-fetch:latest
8+
transport: stdio
9+
port: 8080
10+
# Invalid PodTemplateSpec - containers should be an array, not a string
11+
podTemplateSpec:
12+
spec:
13+
containers: "invalid-not-an-array"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: valid-podtemplate
5+
namespace: toolhive-system
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: toolhive.stacklok.dev/v1alpha1
2+
kind: MCPServer
3+
metadata:
4+
name: valid-podtemplate
5+
namespace: toolhive-system
6+
status:
7+
message: "MCP server is running"
8+
phase: "Running"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: toolhive.stacklok.dev/v1alpha1
2+
kind: MCPServer
3+
metadata:
4+
name: valid-podtemplate
5+
namespace: toolhive-system
6+
status:
7+
conditions:
8+
- type: PodTemplateValid
9+
status: "True"
10+
reason: ValidPodTemplateSpec
11+
- type: ImageValidated
12+
status: "True"
13+
reason: ImageValidationSkipped
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: chainsaw.kyverno.io/v1alpha1
2+
kind: Test
3+
metadata:
4+
name: valid-podtemplatespec
5+
spec:
6+
description: Tests that MCPServer with valid PodTemplateSpec creates deployment successfully
7+
timeouts:
8+
apply: 30s
9+
assert: 60s
10+
cleanup: 30s
11+
steps:
12+
- name: verify-operator
13+
description: Ensure operator is ready before testing
14+
try:
15+
- assert:
16+
file: ../../setup/assert-operator-ready.yaml
17+
18+
- name: deploy-mcpserver-with-valid-podtemplatespec
19+
description: Deploy MCPServer with valid PodTemplateSpec and verify deployment is created
20+
try:
21+
- apply:
22+
file: mcpserver-valid.yaml
23+
- assert:
24+
file: mcpserver-valid.yaml
25+
- assert:
26+
file: assert-mcpserver-valid-condition.yaml
27+
- assert:
28+
file: assert-mcpserver-running.yaml
29+
- assert:
30+
file: assert-deployment-exists.yaml
31+
32+
- name: cleanup
33+
description: Clean up the valid MCPServer
34+
try:
35+
- delete:
36+
ref:
37+
apiVersion: toolhive.stacklok.dev/v1alpha1
38+
kind: MCPServer
39+
name: valid-podtemplate
40+
namespace: toolhive-system
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: toolhive.stacklok.dev/v1alpha1
2+
kind: MCPServer
3+
metadata:
4+
name: valid-podtemplate
5+
namespace: toolhive-system
6+
spec:
7+
image: ghcr.io/stackloklabs/mcp-fetch:latest
8+
transport: stdio
9+
port: 8080
10+
# Valid PodTemplateSpec with proper structure
11+
podTemplateSpec:
12+
spec:
13+
containers:
14+
- name: mcp
15+
resources:
16+
limits:
17+
cpu: "100m"
18+
memory: "128Mi"
19+
requests:
20+
cpu: "50m"
21+
memory: "64Mi"

0 commit comments

Comments
 (0)