Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .buildkite/validate-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions test/docker-compose.override.yaml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 10 additions & 21 deletions test/executor-smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==="

Expand Down Expand Up @@ -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" \
Expand All @@ -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
17 changes: 14 additions & 3 deletions test/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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}}'
Expand All @@ -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"
}

Expand Down
Loading