chore: carry lab 3 over
- carry the lab 3 solution over from mtusi2026lab3-safronov (solution/bvt2301-safronov, ce89eba): src, migrations, student-tests, bench, openspec, .claude, infra/haproxy and infra/valkey, own scripts, Dockerfile, compose, pyproject and uv lock - merge Makefile, .gitignore and .dockerignore (the lab 3 versions only add lines to the skeleton, which is the same in lab 4) and .env.example (lab 4 skeleton names listed in the header) - rename the compose project to mtusi-lab4 and the image to :lab4 so the stand does not reuse the lab 3 containers and volumes - update AGENTS.md for lab 4: current lab, origin commit, contract and test files of the new skeleton Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// Повтор неподтверждённых записей фазы отказа с тем же ключом и тем же
|
||||
// телом до 201 (решение 7 design change graceful-failover). Номера — в
|
||||
// retry.json рабочего каталога; итог — retry-result.json: сколько
|
||||
// получили 201 и какие нет. Ключ и текст строятся так же, как в
|
||||
// failover.js, поэтому повтор после неопределённого исхода (kill, 504)
|
||||
// возвращает сохранённое сообщение или пишет его впервые — без дубля.
|
||||
import { sleep } from "k6";
|
||||
|
||||
import { WORK_DIR, sendMessage, syntheticText } from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const items = JSON.parse(open(`${WORK_DIR}/retry.json`)).items;
|
||||
const RUN = __ENV.RUN;
|
||||
const PHASE = Number(__ENV.PHASE);
|
||||
const ATTEMPTS = 5;
|
||||
|
||||
export const options = {
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
setupTimeout: "5m",
|
||||
};
|
||||
|
||||
export function setup() {
|
||||
let ok = 0;
|
||||
const failed = [];
|
||||
for (const n of items) {
|
||||
const sender = fixture.memberIds[n % fixture.memberIds.length];
|
||||
let status = 0;
|
||||
for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
|
||||
const res = sendMessage(
|
||||
fixture.writeChatId,
|
||||
fixture.tokens[sender],
|
||||
syntheticText(`f${PHASE}`, n),
|
||||
`${RUN}.${PHASE}.${n}`,
|
||||
);
|
||||
status = res.status;
|
||||
if (status === 201) {
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
if (status === 201) {
|
||||
ok += 1;
|
||||
} else {
|
||||
failed.push({ n, status });
|
||||
}
|
||||
}
|
||||
return { ok, failed };
|
||||
}
|
||||
|
||||
export default function () {}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return { [`${WORK_DIR}/retry-result.json`]: JSON.stringify(data.setup_data) };
|
||||
}
|
||||
Reference in New Issue
Block a user