1+ ---
12name : Test Kubernetes Deployment
23
34on :
45 pull_request :
56 branches :
67 - main
7- workflow_dispatch : # Allow manual triggering
8+ workflow_dispatch : # Allow manual triggering
89
910jobs :
1011 test-k8s-deployment :
@@ -28,16 +29,16 @@ jobs:
2829 run : |
2930 # Create kind cluster
3031 kind create cluster --name kind
31-
32+
3233 # Verify cluster is running
3334 kind get clusters
34-
35+
3536 # Verify nodes are ready
3637 kubectl get nodes
37-
38+
3839 # Wait for cluster to be ready
3940 kubectl wait --for=condition=ready node --all --timeout=300s
40-
41+
4142 echo "✅ Kind cluster is ready"
4243
4344 - name : Install Docker Buildx
@@ -47,33 +48,33 @@ jobs:
4748 run : |
4849 cd subgraphs
4950 docker build -t subgraphs:test .
50-
51+
5152 # Verify the image was created
5253 if ! docker images | grep -q "subgraphs.*test"; then
5354 echo "❌ Docker build failed for subgraphs"
5455 exit 1
5556 fi
56-
57+
5758 echo "✅ Subgraphs Docker build successful"
58-
59+
5960 # Load image into kind cluster
6061 kind load docker-image subgraphs:test
6162
6263 - name : Test subgraphs container functionality
6364 run : |
6465 # Test subgraphs container locally before deploying to K8s
6566 docker run -d --name subgraphs-test -p 4001:4001 subgraphs:test
66-
67+
6768 # Wait for container to start
6869 sleep 10
69-
70+
7071 # Check if container is running
7172 if ! docker ps | grep -q "subgraphs-test"; then
7273 echo "❌ Subgraphs container failed to start"
7374 docker logs subgraphs-test
7475 exit 1
7576 fi
76-
77+
7778 # Test all subgraph endpoints
7879 echo "Testing products endpoint..."
7980 curl -X POST http://localhost:4001/products/graphql \
@@ -82,25 +83,25 @@ jobs:
8283 --max-time 10 \
8384 --retry 3 \
8485 --retry-delay 2 || exit 1
85-
86+
8687 echo "Testing reviews endpoint..."
8788 curl -X POST http://localhost:4001/reviews/graphql \
8889 -H "Content-Type: application/json" \
8990 -d '{"query":"{ __typename }"}' \
9091 --max-time 10 \
9192 --retry 3 \
9293 --retry-delay 2 || exit 1
93-
94+
9495 echo "Testing users endpoint..."
9596 curl -X POST http://localhost:4001/users/graphql \
9697 -H "Content-Type: application/json" \
9798 -d '{"query":"{ allUsers { id username } }"}' \
9899 --max-time 10 \
99100 --retry 3 \
100101 --retry-delay 2 || exit 1
101-
102+
102103 echo "✅ All subgraph endpoints responding"
103-
104+
104105 # Cleanup test container
105106 docker stop subgraphs-test || true
106107 docker rm subgraphs-test || true
@@ -120,23 +121,27 @@ jobs:
120121 echo "Verifying kind cluster status..."
121122 kind get clusters
122123 kubectl get nodes
123-
124+
124125 # Deploy using our scripts
125126 ./run-k8s.sh --replicas 1
126-
127+
127128 # Wait for deployments to be ready
128- kubectl wait --for=condition=available --timeout=300s deployment/subgraphs -n apollo-supergraph
129- kubectl wait --for=condition=available --timeout=300s deployment/apollo-router -n apollo-supergraph
129+ kubectl wait --for=condition=available --timeout=300s \
130+ deployment/subgraphs -n apollo-supergraph
131+ kubectl wait --for=condition=available --timeout=300s \
132+ deployment/apollo-router -n apollo-supergraph
130133
131134 - name : Test Kubernetes deployment
132135 run : |
133136 # Port forward to access services
134- kubectl port-forward svc/apollo-router-service 4000:4000 -n apollo-supergraph &
135- kubectl port-forward svc/subgraphs-service 4001:4001 -n apollo-supergraph &
136-
137+ kubectl port-forward svc/apollo-router-service 4000:4000 \
138+ -n apollo-supergraph &
139+ kubectl port-forward svc/subgraphs-service 4001:4001 \
140+ -n apollo-supergraph &
141+
137142 # Wait for port forwarding
138143 sleep 10
139-
144+
140145 # Test subgraphs directly in K8s
141146 echo "Testing subgraphs in Kubernetes..."
142147 curl -X POST http://localhost:4001/products/graphql \
@@ -145,7 +150,7 @@ jobs:
145150 --max-time 10 \
146151 --retry 3 \
147152 --retry-delay 2 || exit 1
148-
153+
149154 # Test router in K8s
150155 echo "Testing router in Kubernetes..."
151156 curl -X POST http://localhost:4000/graphql \
@@ -154,17 +159,17 @@ jobs:
154159 --max-time 10 \
155160 --retry 3 \
156161 --retry-delay 2 || exit 1
157-
162+
158163 echo "✅ Kubernetes deployment test successful"
159164
160165 - name : Cleanup
161166 if : always()
162167 run : |
163168 # Stop port forwarding
164169 pkill -f "kubectl port-forward" || true
165-
170+
166171 # Clean up deployment
167172 ./cleanup-k8s.sh || true
168-
173+
169174 # Delete kind cluster
170175 kind delete cluster || true
0 commit comments