50 lines
1.9 KiB
Bash
50 lines
1.9 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
cd /home/mikail/dana-medical
|
|
origin=http://172.17.0.1:8082
|
|
marker="DANA-DEPLOY-CHECK-$(date +%Y%m%d%H%M%S)"
|
|
body="/tmp/dana-lead-check-$$.json"
|
|
cleanup() {
|
|
docker compose -p dana-medical -f docker-compose.prod.yml exec -T db \
|
|
psql -U dana -d dana -v ON_ERROR_STOP=1 -c "delete from leads where name='$marker'" >/dev/null 2>&1 || true
|
|
rm -f "$body"
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
for path in / /services/ /company/staff/ /price/ /checkup/ /contacts/ /robots.txt /sitemap.xml /admin/ /api/v1/health /api/v1/forms; do
|
|
code="$(curl -sS -o /dev/null -w '%{http_code}' "$origin$path")"
|
|
[ "$code" = 200 ]
|
|
printf '%s=%s\n' "$path" "$code"
|
|
done
|
|
|
|
curl -fsS "$origin/" | grep -q '<h1'
|
|
curl -fsS "$origin/" | grep -q 'https://danamedical.ru/'
|
|
curl -fsS "$origin/admin/pbx.js" | grep -q 'toggle(b.dataset.end)'
|
|
|
|
invalid_code="$(curl -sS -o /dev/null -w '%{http_code}' \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"form":"callback","phone":"+7 900 000-00-01","consent":false}' \
|
|
"$origin/api/v1/leads")"
|
|
[ "$invalid_code" = 400 ]
|
|
|
|
created_code="$(curl -sS -o "$body" -w '%{http_code}' \
|
|
-H 'Content-Type: application/json' \
|
|
-d "{\"form\":\"callback\",\"name\":\"$marker\",\"phone\":\"+7 900 000-01-23\",\"message\":\"Проверка после развёртывания\",\"page_url\":\"/deploy-check\",\"consent\":true}" \
|
|
"$origin/api/v1/leads")"
|
|
[ "$created_code" = 201 ]
|
|
grep -q '"id"' "$body"
|
|
|
|
lead_count="$(docker compose -p dana-medical -f docker-compose.prod.yml exec -T db \
|
|
psql -U dana -d dana -Atqc "select count(*) from leads where name='$marker'")"
|
|
[ "$lead_count" = 1 ]
|
|
printf 'lead_create=%s\n' "$created_code"
|
|
printf 'lead_persisted=%s\n' "$lead_count"
|
|
|
|
cleanup
|
|
trap - EXIT INT TERM
|
|
remaining="$(docker compose -p dana-medical -f docker-compose.prod.yml exec -T db \
|
|
psql -U dana -d dana -Atqc "select count(*) from leads where name='$marker'")"
|
|
[ "$remaining" = 0 ]
|
|
printf 'lead_cleanup=ok\n'
|