-
Notifications
You must be signed in to change notification settings - Fork 85
SQL Server support: portability fixes + cross-database test coverage #2235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AnuGayan
wants to merge
15
commits into
wso2:main
Choose a base branch
from
AnuGayan:sqlserver-portability-and-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
505abca
Add SQL Server support for gateway and platform
AnuGayan 4707e2b
Add SQL Server support for gateway and platform schema
AnuGayan 9eff6de
Add SQL Server support for gateway and platform schema
AnuGayan a218494
Merge branch 'main' of https://github.com/wso2/api-platform into main…
AnuGayan ff51cd3
fix(platform-api): tidy go.mod so module-mode build works
AnuGayan 0a7f335
fix(platform-api): make SQL Server repository SQL portable
AnuGayan 2034e1a
fix(platform-api): make the SQL Server schema apply
AnuGayan c6e7004
fix(eventhub): dialect-aware gateway_states insert for SQL Server
AnuGayan 547c649
test(platform-api): add cross-database integration harness
AnuGayan a237220
test: add combined platform-api + gateway live-traffic e2e
AnuGayan fa0b26f
ci(platform-api): run cross-database and e2e integration tests
AnuGayan 96ffe9b
ci: least-privilege permissions and SHA-pinned actions
AnuGayan 7871836
test/docs: fix gateway-scoped publish test and review nits
AnuGayan 707eeea
fix(gateway): harden SQL Server schema-init, DSN redaction, IT helper…
AnuGayan 30e0c7a
test: convert the platform-api + gateway e2e to a Cucumber (godog) suite
AnuGayan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
.github/workflows/gateway-integration-test-sqlserver.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| 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: | | ||
| 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 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/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 | ||
| } | ||
|
|
||
| # 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 |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Platform API + Gateway E2E | ||
|
|
||
| # Combined live-traffic end-to-end test: the real platform-api control plane | ||
| # deploys an API to the real gateway data plane, and a request through the | ||
| # gateway ingress must reach the sample backend — exercised on every database. | ||
| # | ||
| # This builds the gateway (Envoy) images, so it is intentionally not on the | ||
| # per-PR critical path: it runs on demand and when the e2e itself changes. | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'tests/integration-e2e/**' | ||
| - '.github/workflows/platform-api-gateway-e2e.yml' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| e2e: | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| db: [sqlite, postgres, sqlserver] | ||
| 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 platform-api image | ||
| run: docker build -t platform-api:it-e2e --build-context common=../common . | ||
| working-directory: platform-api | ||
|
|
||
| - name: Build gateway images (controller + runtime) | ||
| run: make build VERSION=it-e2e | ||
| working-directory: gateway | ||
|
|
||
| - name: Build sample-service image | ||
| run: make build | ||
| working-directory: samples/sample-service | ||
|
|
||
| - name: Run combined e2e (${{ matrix.db }}) | ||
| run: E2E_DB=${{ matrix.db }} go test -run TestFeatures -count=1 -v -timeout 25m ./... | ||
| working-directory: tests/integration-e2e | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.