32 lines
963 B
Bash
32 lines
963 B
Bash
#!/bin/sh
|
|
set -eu
|
|
ruff format --check .
|
|
ruff check .
|
|
mypy app
|
|
pytest
|
|
|
|
docker build -t endpoint-monitor:verify .
|
|
container="$(docker run -d -p 127.0.0.1:18000:8000 endpoint-monitor:verify)"
|
|
trap 'docker rm -f "$container" >/dev/null 2>&1 || true' EXIT
|
|
tries=0
|
|
until python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:18000/health/ready', timeout=1)"; do
|
|
tries=$((tries + 1))
|
|
[ "$tries" -lt 20 ] || exit 1
|
|
sleep 0.5
|
|
done
|
|
python - <<'PY'
|
|
import json
|
|
import urllib.request
|
|
base = "http://127.0.0.1:18000"
|
|
assert json.load(urllib.request.urlopen(base + "/health/live")) == {"status": "ok"}
|
|
request = urllib.request.Request(
|
|
base + "/monitors",
|
|
data=b'{"name":"smoke","url":"https://example.com"}',
|
|
headers={"content-type": "application/json"},
|
|
method="POST",
|
|
)
|
|
created = json.load(urllib.request.urlopen(request))
|
|
assert created["name"] == "smoke"
|
|
assert len(json.load(urllib.request.urlopen(base + "/monitors"))) == 1
|
|
PY
|