Repository navigation
74 lines (74 loc) · 4.47 KB
/
Copy pathstack.yml
File metadata and controls
74 lines (74 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: stack
on:
pull_request:
paths: ['infra/**', 'data/seeds/**', 'apps/web/**', 'packages/scripture-guide/**', '.github/workflows/stack.yml']
push:
branches: [master]
paths: ['infra/**', 'data/seeds/**', 'apps/web/**', 'packages/scripture-guide/**', '.github/workflows/stack.yml']
jobs:
compose:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Start seeded stack with Sphinx
run: docker compose -f infra/docker-compose.yml --profile search up -d --build --wait --wait-timeout 300 db web
- name: Start Sphinx (indexes the seeded verses)
run: |
docker compose -f infra/docker-compose.yml --profile search up -d sphinx
for _ in $(seq 1 60); do mysql -h127.0.0.1 -P9306 -e "SHOW TABLES" >/dev/null 2>&1 && break; sleep 3; done
- name: Web serves seeded text
run: |
curl -fsS http://localhost:3000/health
curl -fsS http://localhost:3000/kjv/John.3.16 | grep -q "For God so loved the world"
curl -fsS http://localhost:3000/asv/gen.1.1 | grep -q "In the beginning God created"
curl -fsS http://localhost:3000/tyn/gen.1.1 | grep -q "In the begynnynge God created"
curl -fsS http://localhost:3000/1830/1-ne.1.1 | grep -q "having been born of goodly parents"
curl -fsS http://localhost:3000/1833/boc.1.1 | grep -q "Harken, O ye people of my church"
- name: Web serves seeded headings
run: |
curl -fsS http://localhost:3000/asv/ps.1.1 | grep -q "The righteous and the wicked contrasted"
curl -fsS http://localhost:3000/1920/1-ne.1.1 | grep -q "Beginning of the record of Nephi"
- name: Sphinx finds seeded verses
run: |
n=$(mysql -h127.0.0.1 -P9306 -N -e "SELECT COUNT(*) FROM sgindex WHERE MATCH('loved')")
echo "sphinx matches for 'loved': $n"
test "$n" -gt 0
- name: Search response times, Sphinx vs MySQL fallback
run: |
# The compose web service has no SPHINX_HOST, so it searches through the MySQL fallback.
# A second web container on the same network searches through Sphinx.
docker compose -f infra/docker-compose.yml --profile search run -d --name web-sphinx \
-e SPHINX_HOST=sphinx -p 127.0.0.1:3001:3000 web
up=
for _ in $(seq 1 60); do curl -fsS http://localhost:3001/health >/dev/null 2>&1 && { up=1; break; }; sleep 2; done
[ -n "$up" ] || { echo "web-sphinx did not answer /health within 120 s"; docker logs --tail 80 web-sphinx; exit 1; }
# /healthz reports "sphinx":"ok" only when SPHINX_HOST is set and its SphinxQL port answers
health=$(curl -sS http://localhost:3001/healthz)
echo "web-sphinx /healthz: $health"
echo "$health" | grep -q '"sphinx":"ok"' || { echo "web-sphinx is not searching through Sphinx"; exit 1; }
# median of 5 timed requests after one warm-up, in ms
median() {
curl -fsS -o /dev/null "$1"
for _ in 1 2 3 4 5; do curl -fsS -o /dev/null -w '%{time_total}\n' "$1"; done |
sort -n | sed -n 3p | awk '{printf "%d", $1 * 1000}'
}
printf '%-28s %10s %10s\n' path 'mysql ms' 'sphinx ms'
worst=0
for p in /search/loved /search/faith /search/the '/search/%22the%20lord%22' /kjv/charity; do
m=$(median "http://localhost:3000$p"); s=$(median "http://localhost:3001$p")
printf '%-28s %10s %10s\n' "$p" "$m" "$s"
[ "$s" -gt "$worst" ] && worst=$s
done
echo "slowest Sphinx search: ${worst} ms"
# Generous for now; production times come from staging (Task 8)
loved=$(median http://localhost:3001/search/loved)
test "$loved" -lt 500 || { echo "Sphinx /search/loved took ${loved} ms (limit 500)"; exit 1; }
- name: Sphinx and MySQL fallback find the same verses
# web-sphinx has SPHINX_HOST=sphinx and MYSQL_HOST=db. The script runs the same
# SearchService.hits() calls on a Sphinx-backed and a fallback instance and compares the
# verse ids: per version (KJV, ASV, WEB), the all-versions first pass, and the per-range
# LDS/KJV requery that search() makes past 300 hits. It relies on the image containing
# apps/web/test (the Dockerfile copies all of apps/web).
run: docker exec web-sphinx node test/integration/sphinx-vs-fallback.mjs
- if: failure()
run: docker compose -f infra/docker-compose.yml --profile search logs --tail 80