ci: pre-warm dictionary cache + give /api/dictionary 6h TTL
Adds a workflow step that fetches the four dictionary endpoints (world_regions, countries, cities, airports — see api.ts) before playwright runs. With the longer 6h TTL on /api/dictionary, every e2e spec hits cache for the same 4 URLs that drive most of the data-driven tests (breadcrumb city names, etc). 2s sleeps between warm-up calls keep the cold-cache pass under the WAF rate-limit window.
This commit is contained in:
@@ -110,6 +110,29 @@ jobs:
|
||||
curl -k -sSI -u "$BASIC_AUTH_USER:$BASIC_AUTH_PASS" \
|
||||
https://ui-dashboard.gnerim.ru/api/dictionary/1/world_regions | grep -iE "^HTTP|x-cache|x-envoy"
|
||||
|
||||
- name: Pre-warm /api cache (dictionaries shared across e2e specs)
|
||||
id: cache_warmup
|
||||
env:
|
||||
BASIC_AUTH_USER: ${{ secrets.BASIC_AUTH_USER }}
|
||||
BASIC_AUTH_PASS: ${{ secrets.BASIC_AUTH_PASS }}
|
||||
run: |
|
||||
# The four dictionary endpoints (see src/shared/dictionaries/api.ts)
|
||||
# are read by every page load — fetch them once before e2e to warm
|
||||
# nginx's proxy_cache. Subsequent e2e fetches hit the cache instead
|
||||
# of the upstream WAF, which has a low per-source-IP rate limit.
|
||||
# Brief sleep between requests to avoid tripping the WAF on the
|
||||
# cold-cache pass.
|
||||
for path in world_regions countries cities airports; do
|
||||
url="https://ui-dashboard.gnerim.ru/api/dictionary/1/${path}"
|
||||
rc=$(curl -k -sS -u "$BASIC_AUTH_USER:$BASIC_AUTH_PASS" -o /dev/null -w "%{http_code}" "$url")
|
||||
echo "warm $path -> HTTP $rc"
|
||||
sleep 2
|
||||
done
|
||||
echo "--- verify cache HIT on a re-fetch ---"
|
||||
curl -k -sSI -u "$BASIC_AUTH_USER:$BASIC_AUTH_PASS" \
|
||||
https://ui-dashboard.gnerim.ru/api/dictionary/1/cities \
|
||||
| grep -iE "^HTTP|x-cache-status"
|
||||
|
||||
- name: Install Playwright browsers
|
||||
id: playwright_install
|
||||
run: pnpm exec playwright install --with-deps chromium
|
||||
|
||||
Reference in New Issue
Block a user