feat:report

This commit is contained in:
Оля Мороз
2026-10-23 18:10:07 +03:00
parent ae53d39ccc
commit f4500589c6
134 changed files with 5282 additions and 237 deletions
+13 -12
View File
@@ -1,12 +1,11 @@
#!/usr/bin/env python3
"""Rolling update одной реплики под нагрузкой (уровень 4)."""
import json
"""Rolling update одной реплики: остановить → восстановить под нагрузкой."""
import threading
import time
import uuid
from common import (
BASE_URL, Client, Failure, check, compose, print_pass,
BASE_URL, Client, Failure, check, print_pass, restore_api, stop_one,
)
@@ -41,10 +40,18 @@ def main():
base_err = stats['err']
print(' base: ok=%d err=%d' % (base_ok, base_err))
# Rolling update api1.
compose('up', '-d', '--no-deps', '--force-recreate', 'api1', timeout=180)
# 1) Выбрать одну реплику и остановить.
from common import observe_instances
seen = observe_instances(c, alice, n=30)
target = next(iter(seen))
print(' rolling target:', target)
stop_one(target)
time.sleep(15)
# 2) Восстановить.
restore_api()
time.sleep(10)
stop.set()
t.join(timeout=10)
@@ -54,17 +61,11 @@ def main():
% (delta_ok, delta_err, stats['instances']))
check(delta_ok > 0, 'rolling update остановил запись полностью')
# Ошибки допустимы кратковременно, но не должны доминировать.
check(delta_err <= max(5, delta_ok // 3),
'слишком много ошибок при rolling update: +%d ok / +%d err'
% (delta_ok, delta_err))
# После rolling обе реплики должны снова обслуживать.
seen_final = {}
for _ in range(40):
r = c.call('GET', '/api/v1/users/me', actor=alice, schema='User')
iid = r['headers']['X-Instance-Id']
seen_final[iid] = seen_final.get(iid, 0) + 1
seen_final = observe_instances(c, alice, n=40)
check(len(seen_final) >= 2,
'после rolling видна одна реплика: %r' % seen_final)
print(' final instances:', seen_final)