[APIP] Add Access Logging support #217
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Gateway Integration Test (SQL Server) | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'gateway/**' | |
| - 'common/**' | |
| - 'tests/mock-servers/mock-platform-api/**' | |
| - '.github/workflows/gateway-integration-test-sqlserver.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 | |
| env: | |
| # Used for both Compose interpolation and the runner-side sqlcmd checks below. | |
| MSSQL_SA_PASSWORD: Gateway_Strong!Pass123 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Go | |
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 | |
| with: | |
| go-version: '1.26.2' | |
| cache-dependency-path: '**/go.sum' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 | |
| - name: Build coverage-instrumented images | |
| run: | | |
| cd gateway | |
| make build-coverage VERSION=test | |
| - name: Build mock server images | |
| run: make -C tests/mock-servers build | |
| - name: Build sample-service | |
| run: | | |
| cd samples/sample-service | |
| make build | |
| - name: Verify gateway-controller uses SQL Server | |
| run: | | |
| set -euo pipefail | |
| cd gateway/it | |
| PROJECT="gateway-it-sqlserver-verify" | |
| cleanup() { | |
| docker compose -p "$PROJECT" -f docker-compose.test.sqlserver.yaml down -v --remove-orphans || true | |
| } | |
| trap cleanup EXIT | |
| docker compose -p "$PROJECT" -f docker-compose.test.sqlserver.yaml up -d sqlserver mssql-init gateway-controller | |
| timeout 120 bash -c 'until curl -fsS http://localhost:9092/api/admin/v1/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 | |
| } | |
| # Dump controller logs on any subsequent failure so the cause is never hidden | |
| # by the cleanup trap (otherwise an assertion failure tears everything down silently). | |
| dump_logs() { | |
| echo "=== gateway-controller logs ===" | |
| docker logs it-gateway-controller 2>&1 || true | |
| } | |
| trap 'dump_logs; cleanup' EXIT | |
| docker logs it-gateway-controller > /tmp/gateway-controller.log 2>&1 || true | |
| grep -Eq "Initializing SQLServer schema|SQLServer schema initialized" /tmp/gateway-controller.log | |
| table_count="$(docker compose -p "$PROJECT" -f docker-compose.test.sqlserver.yaml exec -T sqlserver \ | |
| /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -d gateway_test -h -1 -W \ | |
| -Q "SET NOCOUNT ON; SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'artifacts'" | tr -d '[:space:]')" | |
| echo "artifacts table_count=$table_count" | |
| [ "$table_count" = "1" ] | |
| # The controller's DSN sets 'app name=gateway-controller', so its sessions are | |
| # tagged accordingly in sys.dm_exec_sessions (SQL Server's analog of pg_stat_activity). | |
| conn_count="$(docker compose -p "$PROJECT" -f docker-compose.test.sqlserver.yaml exec -T sqlserver \ | |
| /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P "$MSSQL_SA_PASSWORD" -d gateway_test -h -1 -W \ | |
| -Q "SET NOCOUNT ON; SELECT COUNT(*) FROM sys.dm_exec_sessions WHERE program_name = 'gateway-controller'" | tr -d '[:space:]')" | |
| echo "gateway-controller conn_count=$conn_count" | |
| [ "${conn_count:-0}" -ge 1 ] | |
| - name: Run integration tests | |
| run: | | |
| cd gateway | |
| COMPOSE_FILE=docker-compose.test.sqlserver.yaml make test-integration | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: always() | |
| with: | |
| name: coverage-report-sqlserver | |
| path: gateway/it/coverage/output | |
| retention-days: 7 | |
| - name: Upload test reports | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: always() | |
| with: | |
| name: test-reports-sqlserver | |
| 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-sqlserver it-mock-platform-api; 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 |