Skip to content

update JWT Auth and API Key policy definition #1019

update JWT Auth and API Key policy definition

update JWT Auth and API Key policy definition #1019

name: Gateway Integration Test (Postgres)
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'gateway/**'
- '.github/workflows/gateway-integration-test-postgres.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
integration-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26.1'
cache-dependency-path: '**/go.sum'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build coverage-instrumented images
run: |
cd gateway
make build-coverage VERSION=test
- name: Build mock server images
run: |
for mock in mock-jwks mock-azure-content-safety mock-aws-bedrock-guardrail mock-embedding-provider mock-analytics-collector; do
echo "Building $mock..."
docker build -t ghcr.io/wso2/api-platform/$mock:latest tests/mock-servers/$mock
done
- name: Build sample-service
run: |
cd samples/sample-service
make build
- name: Verify gateway-controller uses PostgreSQL
run: |
set -euo pipefail
cd gateway/it
PROJECT="gateway-it-postgres-verify"
cleanup() {
docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml down -v --remove-orphans || true
}
trap cleanup EXIT
docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml up -d postgres gateway-controller
timeout 90 bash -c 'until curl -fsS http://localhost:9092/api/admin/v0.9/health >/dev/null 2>&1; do sleep 2; done' || {
echo "=== Health check timed out — gateway-controller logs ==="
docker logs it-gateway-controller 2>&1 || true
exit 1
}
docker logs it-gateway-controller > /tmp/gateway-controller.log 2>&1 || true
grep -Eq "Initializing PostgreSQL schema|PostgreSQL schema initialized" /tmp/gateway-controller.log
table_count="$(docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml exec -T postgres \
psql -U gateway -d gateway_test -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'artifacts';")"
[ "$table_count" = "1" ]
conn_count="$(docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml exec -T postgres \
psql -U gateway -d gateway_test -tAc "SELECT COUNT(*) FROM pg_stat_activity WHERE application_name = 'gateway-controller';")"
[ "${conn_count:-0}" -ge 1 ]
- name: Run integration tests
run: |
cd gateway
COMPOSE_FILE=docker-compose.test.postgres.yaml make test-integration
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report-postgres
path: gateway/it/coverage/output
retention-days: 7
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports-postgres
path: gateway/it/reports/
retention-days: 7
- name: Debug on failure - Dump logs
if: failure()
run: |
echo "=== Docker Containers ==="
docker ps -a
for ctr in it-gateway-controller it-gateway-runtime it-postgres; do
echo ""
echo "=== Docker logs: $ctr ==="
docker logs "$ctr" 2>&1 || echo "(container $ctr not found)"
done
echo ""
echo "=== gateway/it/logs Directory Contents ==="
if [ -d gateway/it/logs ]; then
if [ "$(ls -A gateway/it/logs)" ]; then
for f in gateway/it/logs/*; do
echo ""
echo "--- Contents of $f ---"
cat "$f"
done
else
echo "No log files found in gateway/it/logs."
fi
else
echo "Directory gateway/it/logs does not exist."
fi