#!/usr/bin/env bash # Seed the dev Mongo deterministically and run the REST smoke test. # # smoke/smoke.sh # compare against committed baseline snapshots # smoke/smoke.sh --update # (re)generate the baseline snapshots # # Env overrides: # MONGO_CONTAINER docker container running the dev Mongo (default tcef-mongo7) # MONGO_DB database name (default fuegos) # MONGO_SHELL mongosh (Mongo 5+) or mongo (Mongo <5) (default mongosh) # MONGO_PORT port mongod listens on inside the container (default 27019) # BASE_URL dev server URL (default http://localhost:3100) # # Mongo 3.2 (Meteor ≤ 2.5) parity example: # MONGO_CONTAINER=tcef-mongo32 MONGO_SHELL=mongo MONGO_PORT=27017 smoke/smoke.sh set -euo pipefail cd "$(dirname "$0")/.." MONGO_CONTAINER="${MONGO_CONTAINER:-tcef-mongo7}" MONGO_DB="${MONGO_DB:-fuegos}" MONGO_SHELL="${MONGO_SHELL:-mongosh}" MONGO_PORT="${MONGO_PORT:-27019}" echo "== Seeding ${MONGO_DB} in ${MONGO_CONTAINER} (${MONGO_SHELL}:${MONGO_PORT}) ==" # Copy the script in and run it as a whole file: the shell evaluates a file # argument atomically (piping via stdin is line-by-line and breaks on multi-line # comments / var scope). docker cp smoke/seed.js "${MONGO_CONTAINER}:/tmp/tcef-seed.js" docker exec "${MONGO_CONTAINER}" "${MONGO_SHELL}" --port "${MONGO_PORT}" "${MONGO_DB}" /tmp/tcef-seed.js | tail -1 echo "== Running REST smoke test against ${BASE_URL:-http://localhost:3100} ==" node smoke/run.js "$@"