CD/CD consolidation
This commit is contained in:
51
devops/tools/orchestrator-scripts/probe.sh
Normal file
51
devops/tools/orchestrator-scripts/probe.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Synthetic probe for orchestrator infra (postgres, mongo, nats).
|
||||
# Runs lightweight checks and writes a status file under out/orchestrator-probe/.
|
||||
|
||||
COMPOSE_FILE=${COMPOSE_FILE:-ops/devops/orchestrator/docker-compose.orchestrator.yml}
|
||||
STATE_DIR=${STATE_DIR:-out/orchestrator-probe}
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
log() { printf "[probe] %s\n" "$*"; }
|
||||
require() { command -v "$1" >/dev/null 2>&1 || { echo "missing $1" >&2; exit 1; }; }
|
||||
|
||||
require docker
|
||||
|
||||
timestamp() { date -u +%Y-%m-%dT%H:%M:%SZ; }
|
||||
|
||||
log "compose file: $COMPOSE_FILE"
|
||||
|
||||
PG_OK=0
|
||||
MONGO_OK=0
|
||||
NATS_OK=0
|
||||
|
||||
if docker compose -f "$COMPOSE_FILE" ps orchestrator-postgres >/dev/null 2>&1; then
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-postgres psql -U orch -tAc "select 1" | grep -q 1; then
|
||||
PG_OK=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if docker compose -f "$COMPOSE_FILE" ps orchestrator-mongo >/dev/null 2>&1; then
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-mongo mongosh --quiet --eval "db.adminCommand('ping').ok" | grep -q 1; then
|
||||
MONGO_OK=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if docker compose -f "$COMPOSE_FILE" ps orchestrator-nats >/dev/null 2>&1; then
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-nats nats --server localhost:4222 ping >/dev/null 2>&1; then
|
||||
# publish & request to ensure traffic path works
|
||||
docker compose -f "$COMPOSE_FILE" exec -T orchestrator-nats nats --server localhost:4222 pub probe.ping "ok" >/dev/null 2>&1 || true
|
||||
NATS_OK=1
|
||||
fi
|
||||
fi
|
||||
|
||||
cat > "$STATE_DIR/status.txt" <<EOF
|
||||
timestamp=$(timestamp)
|
||||
postgres_ok=$PG_OK
|
||||
mongo_ok=$MONGO_OK
|
||||
nats_ok=$NATS_OK
|
||||
EOF
|
||||
|
||||
log "probe complete (pg=$PG_OK mongo=$MONGO_OK nats=$NATS_OK)"
|
||||
17
devops/tools/orchestrator-scripts/replay-smoke.sh
Normal file
17
devops/tools/orchestrator-scripts/replay-smoke.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Replay smoke: restart infra and rerun baseline smoke to validate persistence/readiness.
|
||||
|
||||
COMPOSE_FILE=${COMPOSE_FILE:-ops/devops/orchestrator/docker-compose.orchestrator.yml}
|
||||
STATE_DIR=${STATE_DIR:-out/orchestrator-smoke}
|
||||
|
||||
log() { printf "[replay-smoke] %s\n" "$*"; }
|
||||
|
||||
log "restarting orchestrator infra (compose: $COMPOSE_FILE)"
|
||||
docker compose -f "$COMPOSE_FILE" down
|
||||
docker compose -f "$COMPOSE_FILE" up -d
|
||||
|
||||
log "running baseline smoke"
|
||||
COMPOSE_FILE="$COMPOSE_FILE" STATE_DIR="$STATE_DIR" scripts/orchestrator/smoke.sh
|
||||
|
||||
log "replay smoke done; readiness at $STATE_DIR/readiness.txt"
|
||||
59
devops/tools/orchestrator-scripts/smoke.sh
Normal file
59
devops/tools/orchestrator-scripts/smoke.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
COMPOSE_FILE="${COMPOSE_FILE:-$ROOT/devops/orchestrator/docker-compose.orchestrator.yml}"
|
||||
STATE_DIR="${STATE_DIR:-$ROOT/out/orchestrator-smoke}"
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Orchestrator infra smoke test
|
||||
- Starts postgres + mongo + nats via docker-compose
|
||||
- Verifies basic connectivity and prints ready endpoints
|
||||
|
||||
Env/flags:
|
||||
COMPOSE_FILE path to compose file (default: ops/devops/orchestrator/docker-compose.orchestrator.yml)
|
||||
STATE_DIR path for logs (default: out/orchestrator-smoke)
|
||||
SKIP_UP set to 1 to skip compose up (assumes already running)
|
||||
USAGE
|
||||
}
|
||||
|
||||
if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then usage; exit 0; fi
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
if [[ "${SKIP_UP:-0}" != "1" ]]; then
|
||||
docker compose -f "$COMPOSE_FILE" up -d
|
||||
fi
|
||||
|
||||
log() { echo "[smoke] $*"; }
|
||||
|
||||
log "waiting for postgres..."
|
||||
for i in {1..12}; do
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-postgres pg_isready -U orch >/dev/null 2>&1; then break; fi
|
||||
sleep 5;
|
||||
done
|
||||
|
||||
log "waiting for mongo..."
|
||||
for i in {1..12}; do
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-mongo mongosh --quiet --eval "db.adminCommand('ping')" >/dev/null 2>&1; then break; fi
|
||||
sleep 5;
|
||||
done
|
||||
|
||||
log "waiting for nats..."
|
||||
for i in {1..12}; do
|
||||
if docker compose -f "$COMPOSE_FILE" exec -T orchestrator-nats nats --server localhost:4222 ping >/dev/null 2>&1; then break; fi
|
||||
sleep 5;
|
||||
done
|
||||
|
||||
log "postgres DSN: postgres://orch:orchpass@localhost:55432/orchestrator"
|
||||
log "mongo uri: mongodb://localhost:57017"
|
||||
log "nats uri: nats://localhost:4222"
|
||||
|
||||
# Write readiness summary
|
||||
cat > "$STATE_DIR/readiness.txt" <<EOF
|
||||
postgres=postgres://orch:orchpass@localhost:55432/orchestrator
|
||||
mongo=mongodb://localhost:57017
|
||||
nats=nats://localhost:4222
|
||||
ready_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
EOF
|
||||
|
||||
log "smoke completed; summary at $STATE_DIR/readiness.txt"
|
||||
Reference in New Issue
Block a user