lab3: доказательства уровня 4 и контроль пробы на финальной сборке, документация

This commit is contained in:
2026-10-16 22:44:22 +03:00
parent 1b4aac7587
commit 91de084d7a
76 changed files with 2493 additions and 2484 deletions
+6 -4
View File
@@ -245,9 +245,11 @@ scripts/start-replica.sh # вернуть остано
- **Проба LB — тот же `/health/ready`**, что и healthcheck контейнера: реплика,
потерявшая обязательную зависимость (свой путь к PostgreSQL или Redis),
выходит из ротации, и трафик уходит на здоровые реплики. Проба с зависимостями
ограничена `HEALTH_TIMEOUT_MS=400` на реплику (per-query `query_timeout` для
`SELECT 1` и `AbortSignal.timeout` для `PING`), поэтому она укладывается в
`timeout check 500ms` HAProxy. Когда недоступна общая для всех зависимость,
ограничена общим дедлайном `HEALTH_TIMEOUT_MS=400` на реплику; проверка
PostgreSQL (`SELECT 1`) идёт по отдельному соединению, а не из общего пула
бизнес-запросов, а для `PING` Redis стоит `AbortSignal.timeout`, поэтому проба
укладывается в `timeout check 500ms` HAProxy и не реагирует на перегрузку.
Когда недоступна общая для всех зависимость,
неготовыми становятся все реплики, и клиент получает `503` от самого LB: это
честный ответ «готовых узлов нет» вместо маскировки отказа.
- `/health/live` зависимостей не касается: он отвечает `200`, пока жив процесс,
@@ -288,7 +290,7 @@ PostgreSQL (`57014`, `40001`, `40P01`) и обрывы соединения от
## Харнесс экспериментов
Уровни 3/4 и трек 1 обслуживает `../scripts/lab3/lab3.py` (только stdlib) и
профили k6 в `../scripts/load/`: `run`, `sweep`, `growth`, `failover`,
профили k6 в `../scripts/load/`: `run`, `sweep`, `track1-extras`, `failover`,
`rolling-update`, `ab`, `analyze`, `watch`, `check`, `quiesce`, `track1`.
Сырые результаты прогонов, манифесты условий измерения и графики складываются в
`../evidence/track1/`. Подробности — в `../REPORT.md` и
-16
View File
@@ -56,7 +56,6 @@ const runId = randomUUID().replaceAll('-', '').slice(0, 12);
// timeout, so every outage step costs up to DATABASE_CONNECTION_TIMEOUT_MS.
const outagedRequestBudgetMs = 180_000;
const slotBudgetMs = 20_000;
// Rotation is checked with HTTP reads through the LB, not with check counters.
const readyReads = 16;
const saturatingWrites = 60; // больше, чем replicas × DATABASE_POOL_MAX (2 × 10)
@@ -173,8 +172,6 @@ async function waitFor(
}
}
// Contract of the bounded unavailable error, checked both on the API replica
// (JSON body with request_id) and through the load balancer.
function expectBoundedError(
status: number,
text: string,
@@ -485,7 +482,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
expect(sent.response.status).toBe(201);
message = sent.body;
replicas = await apiContainers();
// Partial removal from rotation needs a healthy peer to compare with.
expect(replicas.length).toBeGreaterThanOrEqual(2);
await waitForSlot(
(slots) => upSlots(slots).length === replicas.length,
@@ -555,9 +551,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
await compose('stop', redisService);
const replica = replicas[0];
// The replica itself stays bounded: liveness is unaffected, readiness
// and business requests report the missing dependency with an API
// error body.
expect((await probeReplica(replica, '/health/live')).status).toBe(
200,
);
@@ -584,9 +577,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
(JSON.parse(anonymous.text) as ApiErrorBody).error.code,
).toBe('unauthorized');
// The shared dependency is missing for every replica: a client keeps
// getting 503 (from a replica first, then from the LB itself), and
// once all backends have left rotation the answer is the LB's own.
expectUnavailableThroughLb(
await request<ApiErrorBody>('/api/v1/users/me', {
headers: bearer(token),
@@ -676,8 +666,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
registration.requestId,
);
// Every replica loses the shared database; a client keeps getting 503,
// first from a replica and then from the LB itself.
expectUnavailableThroughLb(
await request<ApiErrorBody>('/api/v1/users/me', {
headers: bearer(token),
@@ -740,7 +728,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
await applyReplicaDatabaseReject(selectedIp);
const faultAt = Date.now();
// The selected replica reports the loss, the healthy one does not.
await waitForReplicaReadiness(selected, 503, 30_000);
expect(
(await probeReplica(healthy, '/health/ready')).status,
@@ -766,8 +753,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
slots.find((slot) => slot.addr === selectedAddress)?.status,
).toBe('DOWN');
// Traffic through the LB stays on the healthy replica: no errors
// and no request served by the replica that lost its database.
const served = new Set<string>();
for (let index = 0; index < readyReads; index += 1) {
const read = await historyOf(chat.id, token);
@@ -782,7 +767,6 @@ describe.skipIf(!enabled)('dependency outages', () => {
await restoreDatabaseAccess();
}
// The restored replica answers again and returns to rotation.
await waitForReplicaReadiness(selected, 200, 30_000);
await waitForSlot(
(slots) =>