martin/tests/test.sh
Yuri Astrakhan a0a411f088
Consolidate DB init and tests (#463)
* Add justfile to simplify running all the tests
* Save all PBF outputs to the text files
* Consolidate all tests to reuse the same code
* Consolidate database initialization
* updated readme with the new instructions

Note that while this PR creates "expected" files, the CI cannot validate
the generated results because the output is not stable. Eventually we
may try to output just the non-geometry values to have reasonable tests
comparing against the expected results.
2022-10-28 14:52:39 -04:00

36 lines
1008 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
DATABASE_URL="${DATABASE_URL:-postgres://postgres@localhost/db}"
MARTIN_BIN="${MARTIN_BIN:-cargo run --}"
function wait_for_martin {
# Seems the --retry-all-errors option is not available on older curl versions, but maybe in the future we can just use this:
# timeout -k 20s 20s curl --retry 10 --retry-all-errors --retry-delay 1 -sS http://localhost:3000/healthz
echo "Waiting for Martin to start..."
n=0
until [ "$n" -ge 100 ]; do
timeout -k 20s 20s curl -sSf http://localhost:3000/healthz 2>/dev/null >/dev/null && break
n=$((n+1))
sleep 0.2
done
echo "Martin has started."
}
curl --version
$MARTIN_BIN --default-srid 900913 &
PROCESS_ID=$!
trap "kill $PROCESS_ID || true" EXIT
wait_for_martin
tests/test-auto-sources.sh
kill $PROCESS_ID
$MARTIN_BIN --config tests/config.yaml "$DATABASE_URL" &
PROCESS_ID=$!
trap "kill $PROCESS_ID || true" EXIT
wait_for_martin
tests/test-configured-sources.sh
kill $PROCESS_ID