From a7b019bd563f238ac62854c3ec7cf679a3ef8663 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:46:48 -0600 Subject: [PATCH] ci: Deploy Jaeger and the executor in the smoke test The smoke test started only docker-compose.yaml, then started a second, separate executor with `docker compose run`. Jaeger never ran. Start all three Compose files with one `up`, so the container count, health check wait, and restart check cover every service. The executor exits without a password and a queue name, so a test override file sets them, and executor-smoke-test.sh reads the password from the container. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c731-7931-7091-9b5e-664cc2379c79 Co-authored-by: Amp --- .buildkite/validate-docker-compose.sh | 2 ++ test/docker-compose.override.yaml | 8 +++++++ test/executor-smoke-test.sh | 31 +++++++++------------------ test/smoke-test.sh | 17 ++++++++++++--- 4 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 test/docker-compose.override.yaml diff --git a/.buildkite/validate-docker-compose.sh b/.buildkite/validate-docker-compose.sh index ae74f69ba..8a716a3d7 100755 --- a/.buildkite/validate-docker-compose.sh +++ b/.buildkite/validate-docker-compose.sh @@ -12,6 +12,8 @@ docker compose --file docker-compose.yaml --file jaeger/docker-compose.yaml conf docker compose --file docker-compose.yaml --file jaeger/docker-compose.yaml --file dev/docker-compose.yaml config --quiet docker compose --file docker-compose.yaml --file executors/executor.docker-compose.yaml config --quiet docker compose --file executors/executor.docker-compose.yaml config --quiet +# The combination the smoke test deploys +docker compose --file docker-compose.yaml --file jaeger/docker-compose.yaml --file executors/executor.docker-compose.yaml --file ../test/docker-compose.override.yaml config --quiet for override in examples/*/docker-compose.override.yaml; do docker compose --file docker-compose.yaml --file "$override" config --quiet done diff --git a/test/docker-compose.override.yaml b/test/docker-compose.override.yaml new file mode 100644 index 000000000..2cc86799c --- /dev/null +++ b/test/docker-compose.override.yaml @@ -0,0 +1,8 @@ +version: '2.4' +services: + # The executor exits unless both are set. + # executor-smoke-test.sh sets this password as `executors.accessToken` in the site config + executor: + environment: + - EXECUTOR_FRONTEND_PASSWORD=executor-smoke-test-token + - EXECUTOR_QUEUE_NAME=batches diff --git a/test/executor-smoke-test.sh b/test/executor-smoke-test.sh index f92e1b474..052c829d1 100755 --- a/test/executor-smoke-test.sh +++ b/test/executor-smoke-test.sh @@ -3,18 +3,18 @@ set -euo pipefail # Executor smoke test for deploy-sourcegraph-docker # -# Requires: a running Sourcegraph docker-compose stack (from smoke-test.sh or manual start). -# This script creates a site admin account, configures executor access, starts an executor -# container, and verifies it registers with the Sourcegraph instance. +# Requires: a running Sourcegraph docker-compose stack with an executor container +# (from smoke-test.sh or manual start). +# This script creates a site admin account, configures executor access, and verifies +# the executor registers with the Sourcegraph instance. # -# Dependencies: curl, jq, docker compose +# Dependencies: curl, jq, docker FRONTEND_URL="${FRONTEND_URL:-http://localhost:80}" -EXECUTOR_TOKEN="executor-smoke-test-token" +EXECUTOR_TOKEN=$(docker exec executor printenv EXECUTOR_FRONTEND_PASSWORD) ADMIN_EMAIL="smoke-test@sourcegraph.com" ADMIN_USERNAME="smoke-admin" ADMIN_PASSWORD="smoke-test-password-123!" -COMPOSE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../docker-compose" && pwd)" echo "=== Executor Smoke Test ===" @@ -74,19 +74,8 @@ curl -s -o /dev/null -X POST "${FRONTEND_URL}/.api/graphql" \ --data-raw "{\"query\":\"mutation UpdateSiteConfig(\$input: String!) { updateSiteConfiguration(lastID: $LAST_ID, input: \$input) }\", \"variables\":{\"input\":$NEW_CONFIG}}" echo " Site config updated" -# Step 5: Start executor container -echo "Step 5: Starting executor container..." -EXECUTOR_CONTAINER=$(docker compose \ - -f "${COMPOSE_DIR}/docker-compose.yaml" \ - -f "${COMPOSE_DIR}/executors/executor.docker-compose.yaml" \ - run -d \ - -e "EXECUTOR_FRONTEND_PASSWORD=${EXECUTOR_TOKEN}" \ - -e EXECUTOR_QUEUE_NAME=batches \ - executor 2>&1 | tail -1) -echo " Executor container started: ${EXECUTOR_CONTAINER:0:12}" - -# Step 6: Wait for executor to register -echo "Step 6: Waiting for executor to register..." +# Step 5: Wait for executor to register +echo "Step 5: Waiting for executor to register..." MAX_ATTEMPTS=24 for i in $(seq 1 $MAX_ATTEMPTS); do COUNT=$(curl -s -X POST "${FRONTEND_URL}/.api/graphql" \ @@ -110,8 +99,8 @@ echo "=== EXECUTOR SMOKE TEST FAILED ===" echo "Executor did not register within $((MAX_ATTEMPTS * 5))s" echo "" echo "Container status:" -docker inspect "$EXECUTOR_CONTAINER" --format '{{.State.Status}} (exit code: {{.State.ExitCode}})' 2>/dev/null || echo " Container not found" +docker inspect executor --format '{{.State.Status}} (exit code: {{.State.ExitCode}})' 2>/dev/null || echo " Container not found" echo "" echo "Container logs:" -docker logs "$EXECUTOR_CONTAINER" 2>&1 | tail -20 || echo " No logs available" +docker logs executor 2>&1 | tail -20 || echo " No logs available" exit 1 diff --git a/test/smoke-test.sh b/test/smoke-test.sh index e733e4333..3b39ed1c8 100755 --- a/test/smoke-test.sh +++ b/test/smoke-test.sh @@ -11,12 +11,20 @@ configure_docker() { gcloud auth configure-docker us-central1-docker.pkg.dev,us-docker.pkg.dev } +# Every service a customer can deploy, started and checked by the same commands +compose_files=( + --file docker-compose/docker-compose.yaml + --file docker-compose/jaeger/docker-compose.yaml + --file docker-compose/executors/executor.docker-compose.yaml + --file test/docker-compose.override.yaml +) + deploy_sourcegraph() { cd "$(dirname "${BASH_SOURCE[0]}")/.." docker-compose version # `up` pulls images one at a time, `pull` pulls them in parallel - docker-compose --file docker-compose/docker-compose.yaml pull --quiet - docker-compose --file docker-compose/docker-compose.yaml up -d -t 600 + docker-compose "${compose_files[@]}" pull --quiet + docker-compose "${compose_files[@]}" up -d -t 600 } wait_until_healthy() { @@ -36,7 +44,7 @@ wait_until_healthy() { test_count() { echo "TEST: Every service has a running container" # migrator exits when it is done, every other service keeps running - expect_containers=$(docker-compose --file docker-compose/docker-compose.yaml config --services | grep --count --invert-match '^migrator$') + expect_containers=$(docker-compose "${compose_files[@]}" config --services | grep --count --invert-match '^migrator$') containers_count=$(docker ps --filter status=running --format '{{.Names}}' | wc -l) if [[ "$containers_count" -ne "$expect_containers" ]]; then docker ps --all --format '{{.Names}}: {{.Status}}' @@ -58,6 +66,9 @@ test_containers() { curl -f http://localhost:80 curl -f http://localhost:80/healthz + echo "TEST: Checking Jaeger is accessible" + curl --fail --silent --show-error --location --output /dev/null http://localhost:16686/-/debug/jaeger/ + echo "ALL TESTS PASSED" }