Reach QA's published ports from the smoke-qa job container via bridge gateway
The runner executes each job in its own container on docker's default bridge network, so "localhost" never resolves to the docker host - smoke-qa's direct Postgres connection and Playwright/API HTTP calls need the bridge gateway IP instead. Bind the db port to that same gateway IP (not 0.0.0.0) so it stays reachable only from sibling containers, not off-box.
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
# Post-deploy validation for the QA environment: runs the API integration
|
||||
# suite (real HTTP + real Postgres, seeding/cleaning up its own data) and the
|
||||
# Playwright admin e2e suite against the just-deployed QA stack. Intended to
|
||||
# run immediately after deploy-qa.sh, on the same self-hosted qa runner, so
|
||||
# `localhost` resolves to the deployed containers.
|
||||
# run immediately after deploy-qa.sh, on the same self-hosted qa runner. This
|
||||
# job runs in its own job container, a sibling of the QA stack's containers
|
||||
# on docker's default bridge network - not "localhost" from the host's point
|
||||
# of view - so it reaches published ports via the bridge gateway IP, same as
|
||||
# deploy-qa.sh binds the db port to.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" && source ./lib.sh
|
||||
cd "$CI_ROOT"
|
||||
@@ -12,10 +15,14 @@ ensure_dotnet
|
||||
ensure_node
|
||||
|
||||
QA_ADMIN_PORT="${QA_ADMIN_PORT:-3001}"
|
||||
BASE_URL="http://localhost:${QA_ADMIN_PORT}"
|
||||
CI_HOST="$(docker_bridge_gateway)"
|
||||
[[ -n "$CI_HOST" ]] || fail "could not determine docker bridge gateway IP to reach the QA stack"
|
||||
BASE_URL="http://${CI_HOST}:${QA_ADMIN_PORT}"
|
||||
|
||||
log "Resolved docker host as $CI_HOST for reaching the QA stack's published ports"
|
||||
|
||||
export MICCHECK_API_BASE_URL="$BASE_URL"
|
||||
export MICCHECK_DB_CONNECTION_STRING="${MICCHECK_DB_CONNECTION_STRING:-Host=localhost;Port=55432;Database=miccheck;Username=miccheck;Password=password}"
|
||||
export MICCHECK_DB_CONNECTION_STRING="${MICCHECK_DB_CONNECTION_STRING:-Host=$CI_HOST;Port=55432;Database=miccheck;Username=miccheck;Password=password}"
|
||||
|
||||
log "Running API integration suite against $BASE_URL"
|
||||
dotnet test tests/api/MicCheck.Api.Tests.Integration/MicCheck.Api.Tests.Integration.csproj -c Release --logger trx
|
||||
|
||||
Reference in New Issue
Block a user