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:
2026-10-20 17:32:33 +03:00
co-authored by Claude Opus 5.5
parent ec540a1a72
commit 5d5d8f9d2a
365 changed files with 64878 additions and 19 deletions
+69
View File
@@ -0,0 +1,69 @@
// Пользователи и чаты стенда: читаемый (сценарий read), чат записи
// (сценарий write) и фоновые чаты неравномерных размеров (трек 2). Каждый
// пользователь регистрируется с паролем и входит по Basic; в фикстуру идут
// id и Bearer-токены, пароли — нет. Итог — fixture.json в рабочем каталоге:
// оркестратор удаляет его в конце прогона.
import { WORK_DIR, createChat, register } from "./lib.js";
const MEMBERS = Number(__ENV.MEMBERS || 10);
// чатов записи (Profile.write_chats): у прежних профилей один
const WRITE_CHATS = Math.max(1, Number(__ENV.WRITE_CHATS || 1));
// уровни фоновых чатов: «10x5000,100x400» — число чатов x сообщений в чате
const BACKGROUND = (__ENV.BACKGROUND || "")
.split(",")
.filter((tier) => tier !== "")
.map((tier) => tier.split("x").map(Number));
export const options = {
vus: 1,
iterations: 1,
setupTimeout: "5m",
};
export function setup() {
// размер начинается с пустой базы, поэтому имени хватает времени
const stamp = Date.now().toString(36);
const tokens = {};
const reader = register(`b${stamp}_reader`, "Bench reader");
tokens[reader.id] = reader.token;
const memberIds = [];
for (let i = 0; i < MEMBERS; i++) {
const member = register(`b${stamp}_m${i}`, `Bench member ${i}`);
tokens[member.id] = member.token;
memberIds.push(member.id);
}
const everyone = [reader.id, ...memberIds];
// фоновые чаты в порядке уровней: номер чата в расписании наполнения —
// 1 + индекс в этом списке (0 — читаемый чат)
const bgChats = [];
for (const [count, size] of BACKGROUND) {
for (let i = 0; i < count; i++) {
const title = `bench bg ${size} #${i}`;
bgChats.push({ id: createChat(reader.token, title, everyone), size });
}
}
const readChatId = createChat(reader.token, "bench read", everyone);
// чаты записи со всеми пользователями: серии трека 1 делят вставки на
// WRITE_CHATS правых краёв индекса истории (решение 2 design change
// scaling-bench); прежние сценарии пишут в первый — writeChatId
const writeChatIds = [];
for (let i = 0; i < WRITE_CHATS; i++) {
const title = i === 0 ? "bench write" : `bench write #${i}`;
writeChatIds.push(createChat(reader.token, title, everyone));
}
return {
readerId: reader.id,
memberIds,
tokens,
readChatId,
writeChatId: writeChatIds[0],
writeChatIds,
bgChats,
};
}
export default function () {}
export function handleSummary(data) {
return { [`${WORK_DIR}/fixture.json`]: JSON.stringify(data.setup_data) };
}