lab3: исправить rolling update, данные трека 1 (прогон 1), серии C и E

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 17:47:27 +03:00
co-authored by Claude Opus 5.5
parent fe4b4cf556
commit 0a3718134b
14 changed files with 257 additions and 36 deletions
+9 -4
View File
@@ -33,7 +33,7 @@ step "smoke"
$PY tests/smoke.py --base-url "$BASE" | tee evidence/smoke.txt
step "конкурентная идемпотентность"
$PY tests/idempotency_concurrent.py --base-url "$BASE" --output evidence/idempotency_concurrent.json | tail -1
$PY student-tests/idempotency_concurrent.py --base-url "$BASE" --output evidence/idempotency_concurrent.json | tail -1
step "публичный failover (2 прогона, между ними restore)"
for n in 1 2; do
@@ -51,13 +51,18 @@ step "persistence (restart всего стенда с volumes)"
cat evidence/persistence.txt
step "серия отказов каждой реплики под нагрузкой (уровень 4)"
$PY tests/failover_series.py --base-url "$BASE" --output evidence/failover_series.json | tail -1
$PY student-tests/failover_series.py --base-url "$BASE" --output evidence/failover_series.json | tail -1
step "rolling update под нагрузкой (уровень 4)"
$PY tests/load.py --base-url "$BASE" --duration 60 --concurrency 4 --output evidence/rolling_update_load.json > /dev/null &
# Образ собираем ДО нагрузки, чтобы в окно нагрузки попала именно замена реплик.
docker compose build -q api
{ echo "-- до:"; docker compose ps api --format '{{.Name}} {{.ID}} {{.Status}}'; } > evidence/rolling_update.txt
$PY tests/load.py --base-url "$BASE" --duration 90 --concurrency 4 --output evidence/rolling_update_load.json > /dev/null &
LOAD=$!
sleep 5
sh scripts/rolling-update.sh > evidence/rolling_update.txt 2>&1
start=$(date +%s)
sh scripts/rolling-update.sh >> evidence/rolling_update.txt 2>&1
echo "-- замена заняла $(( $(date +%s) - start )) s (внутри 90 s нагрузки)" >> evidence/rolling_update.txt
wait $LOAD
cat evidence/rolling_update.txt evidence/rolling_update_load.json
+5 -3
View File
@@ -13,8 +13,10 @@ wait_healthy() {
want=$1; deadline=$(( $(date +%s) + 90 ))
while :; do
n=0
for cid in $(docker compose ps -q api); do
[ "$(docker inspect -f '{{.State.Health.Status}}' "$cid")" = healthy ] && n=$((n+1))
# Своё имя переменной: в sh у функций общая область видимости, и `cid`
# перезаписал бы переменную внешнего цикла (тогда удалялась бы новая реплика).
for c in $(docker compose ps -q api); do
[ "$(docker inspect -f '{{.State.Health.Status}}' "$c")" = healthy ] && n=$((n+1))
done
[ $n -ge "$want" ] && return 0
[ "$(date +%s)" -lt $deadline ] || { echo "new replica not healthy in 90s" >&2; return 1; }
@@ -32,4 +34,4 @@ for cid in $old; do
docker rm "$cid" >/dev/null
echo "replaced $name"
done
docker compose ps api --format '{{.Name}} {{.Image}} {{.Status}}'
docker compose ps api --format '{{.Name}} {{.ID}} {{.Image}} {{.Status}}'