forked from mtusi2026/mtusi2026lab2
test_attachment_faults.py runs through the balancer against the real PostgreSQL and RustFS. The negative suite sends a body one byte over the limit with Content-Length (answered before any body byte) and chunked, a decompression bomb, truncated and disguised images, missing and foreign content types, dangerous names, a stranger's reads and references, an attachment of another chat and invalid lists, checks each code and error body, and finds no 5xx in the replica logs and no extra rows. Faults come from triggers installed for the module and dropped after it: an AFTER INSERT trigger remembers the id and key of each fault intent, a BEFORE UPDATE trigger rejects the ready commit for fault-fail names and holds it for 1.8 s for fault-crash names, while the test finds the waiting backend's client address and kills that replica with SIGKILL. The rejected commit leaves neither row nor object right away and an audit line says compensation; a crash leaves a pending row and an object, the one aged past the grace period is swept with its object while the fresh one stays, and an aged ready attachment in a message still downloads. A body cut after 256 KiB is logged as 400 with nothing written, and a stalled body gets 503 after 8 s with nothing written. make upload-faults stores the output in evidence/upload-faults.txt without tracebacks of locals, and the CI acceptance job runs it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
89 lines
3.4 KiB
YAML
89 lines
3.4 KiB
YAML
name: Application
|
||
|
||
on: [push, pull_request]
|
||
|
||
permissions:
|
||
contents: read
|
||
|
||
jobs:
|
||
quality:
|
||
name: Линт, типы и собственные тесты
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: astral-sh/setup-uv@v5
|
||
with:
|
||
enable-cache: true
|
||
- run: uv sync --locked --group dev
|
||
- run: make lint VENV=.venv
|
||
- run: make student-test VENV=.venv
|
||
|
||
acceptance:
|
||
name: Стенд Compose с RustFS за HAProxy, smoke, вложения, отказ реплики, рестарт и отказы зависимостей
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: astral-sh/setup-uv@v5
|
||
with:
|
||
enable-cache: true
|
||
- run: uv sync --locked --group dev
|
||
|
||
- name: Поднять стенд из чистого clone
|
||
run: make up
|
||
|
||
- name: Публичный smoke через балансировщик
|
||
run: make test
|
||
|
||
- name: Вложение после остановки принявшей его реплики и при недоступном S3
|
||
run: |
|
||
make scenario SCENARIO=failover-upload
|
||
make scenario SCENARIO=s3-outage
|
||
|
||
- name: Приватный bucket, ограниченный ключ API и повторный bootstrap
|
||
run: make s3-check
|
||
|
||
- name: Негативный suite вложений, компенсация, уборка после grace, обрыв и зависание загрузки
|
||
run: make upload-faults
|
||
|
||
- name: Несколько реплик на одном токене и гонка одного ключа
|
||
run: make lb-check
|
||
|
||
- name: Остановка реплики под запросами, затем возврат
|
||
run: |
|
||
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||
docker compose ps -a api
|
||
make restore
|
||
|
||
- name: Рестарт LB, API и хранилищ с сохранением volumes
|
||
run: make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||
|
||
- name: Отказы Valkey и PostgreSQL, гонка и rollback
|
||
run: make test-faults
|
||
|
||
- name: Лимиты, порты, секреты, volumes и сети по политике
|
||
run: make limits
|
||
|
||
- name: Время обнаружения отказа балансировщиком (SIGTERM, kill, pause, PostgreSQL)
|
||
run: make detection
|
||
|
||
- name: Наружу опубликован только балансировщик
|
||
run: |
|
||
docker compose ps --format '{{.Service}} {{.Ports}}' | awk '$2 != "" && $1 != "lb" {print; bad=1} END {exit bad}'
|
||
|
||
- name: Процессы работают не от root
|
||
run: |
|
||
docker compose top | awk 'NR>1 && $3=="0" {print; bad=1} END {exit bad}'
|
||
|
||
- name: Корректная остановка реплик API по SIGTERM
|
||
run: |
|
||
start=$(date +%s)
|
||
docker compose kill --signal SIGTERM api
|
||
codes=$(docker wait $(docker compose ps -aq api) | sort -u)
|
||
elapsed=$(( $(date +%s) - start ))
|
||
echo "остановка за ${elapsed} с, коды завершения ${codes}"
|
||
test "$elapsed" -le 10 && test "$codes" = "0"
|
||
|
||
- name: Журналы стенда
|
||
if: always()
|
||
run: docker compose logs --tail 80
|