feat: CI/CD integration testing with network access #23
+10
-16
@@ -70,11 +70,9 @@ jobs:
|
||||
KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Install kubectl
|
||||
- name: Verify kubectl availability
|
||||
run: |
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
chmod +x kubectl
|
||||
sudo mv kubectl /usr/local/bin/
|
||||
kubectl version --client || (echo "ERROR: kubectl not available" && exit 1)
|
||||
|
||||
- name: Deploy test pod from new image
|
||||
run: |
|
||||
@@ -91,20 +89,16 @@ jobs:
|
||||
kubectl wait --for=condition=ready pod -l run=api-gateway-test-${{ steps.sha.outputs.short_sha }} -n api --timeout=60s
|
||||
continue-on-error: true
|
||||
|
||||
- name: Run integration tests against test pod
|
||||
- name: Run integration tests inside test pod
|
||||
run: |
|
||||
echo "Running integration tests against test pod..."
|
||||
# Port-forward to test pod
|
||||
kubectl port-forward -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} 8080:8080 &
|
||||
PF_PID=$!
|
||||
sleep 3
|
||||
echo "Running integration tests inside test pod..."
|
||||
echo "Test pod: api-gateway-test-${{ steps.sha.outputs.short_sha }}"
|
||||
sleep 5
|
||||
|
||||
# Run tests
|
||||
TEST_RESULT=0
|
||||
go test -v -tags=integration -timeout=5m ./internal/integration/... || TEST_RESULT=$?
|
||||
|
||||
kill $PF_PID || true
|
||||
exit $TEST_RESULT
|
||||
# Run tests from inside the pod
|
||||
# Pod has network access to all services via network policy labels
|
||||
kubectl exec -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} -- \
|
||||
go test -v -tags=integration -timeout=5m ./internal/integration/...
|
||||
env:
|
||||
GATEWAY_URL: http://localhost:8080
|
||||
continue-on-error: false
|
||||
|
||||
Reference in New Issue
Block a user