-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathgateway-integration-test-sqlserver.yml
More file actions
143 lines (121 loc) · 5.34 KB
/
Copy pathgateway-integration-test-sqlserver.yml
File metadata and controls
143 lines (121 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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.5'
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