86 lines
2.1 KiB
YAML
86 lines
2.1 KiB
YAML
apiVersion: tekton.dev/v1
|
|||
|
|
kind: Task
|
||
|
|
metadata:
|
||
|
|
name: integration-test
|
||
|
|
namespace: api
|
||
|
|
labels:
|
||
|
|
app: api-gateway
|
||
|
|
component: testing
|
||
|
|
spec:
|
||
|
|
description: Run integration tests for API gateway
|
||
|
|
params:
|
||
|
|
- name: image
|
||
|
|
type: string
|
||
|
|
description: Container image to test (including tag)
|
||
|
|
- name: timeout
|
||
|
|
type: string
|
||
|
|
default: "5m"
|
||
|
|
description: Test timeout
|
||
|
|
results:
|
||
|
|
- name: result
|
||
|
|
description: Test result (pass/fail)
|
||
|
|
type: string
|
||
|
|
- name: message
|
||
|
|
description: Test summary message
|
||
|
|
type: string
|
||
|
|
steps:
|
||
|
|
- name: run-tests
|
||
|
|
image: $(params.image)
|
||
|
|
securityContext:
|
||
|
|
runAsNonRoot: true
|
||
|
|
runAsUser: 65532
|
||
|
|
allowPrivilegeEscalation: false
|
||
|
|
env:
|
||
|
|
- name: GATEWAY_URL
|
||
|
|
value: "http://api-gateway:8080"
|
||
|
|
- name: CI
|
||
|
|
value: "true"
|
||
|
|
script: |
|
||
|
|
#!/bin/sh
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "🧪 Starting integration tests..."
|
||
|
|
echo "Image: $(params.image)"
|
||
|
|
echo "Gateway: $GATEWAY_URL"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Wait for gateway to be ready
|
||
|
|
echo "Waiting for gateway service..."
|
||
|
|
for i in $(seq 1 30); do
|
||
|
|
if curl -s $GATEWAY_URL/healthz > /dev/null 2>&1; then
|
||
|
|
echo "✓ Gateway is ready"
|
||
|
|
break
|
||
|
|
fi
|
||
|
|
echo "Attempt $i/30: Waiting for gateway..."
|
||
|
|
sleep 2
|
||
|
|
done
|
||
|
|
|
||
|
|
# Run integration tests
|
||
|
|
echo "Running integration tests..."
|
||
|
|
if go test -v -tags=integration -timeout=$(params.timeout) ./internal/integration/...; then
|
||
|
|
echo "pass" | tee $(results.result.path)
|
||
|
|
echo "✓ All integration tests passed" | tee $(results.message.path)
|
||
|
|
exit 0
|
||
|
|
else
|
||
|
|
echo "fail" | tee $(results.result.path)
|
||
|
|
echo "✗ Some integration tests failed" | tee $(results.message.path)
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
volumeMounts:
|
||
|
|
- name: tmp
|
||
|
|
mountPath: /tmp
|
||
|
|
- name: home
|
||
|
|
mountPath: /home/nonroot
|
||
|
|
resources:
|
||
|
|
requests:
|
||
|
|
cpu: 250m
|
||
|
|
memory: 512Mi
|
||
|
|
limits:
|
||
|
|
cpu: 500m
|
||
|
|
memory: 1Gi
|
||
|
|
volumes:
|
||
|
|
- name: tmp
|
||
|
|
emptyDir: {}
|
||
|
|
- name: home
|
||
|
|
emptyDir: {}
|