Files
mtusi2026lab3/bench/k6/prepare.js
T
ricoromaandClaude Opus 5.5 02fd3d8a36 feat: add track 1 scaling series to the bench stand
Series a/b/pool/ab/quick in bench/run.py: per-cell fresh stand with the
configuration's replicas and max_connections, open-model mixed profile
(k6/mixed.js), fixed levels and R* search by SLO, a sampler container
for cgroup, VM, HAProxy and PostgreSQL metrics, resume and a stand
lock. Pure helpers in bench/scaling.py, SVG plots in bench/plots.py,
series mode for bench_compare and bench_ab. Hypotheses H1-H3 go to
REPORT.md before the first series.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:28:36 +03:00

70 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Пользователи и чаты стенда: читаемый (сценарий 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) };
}