Files
mtusi2026lab4/bench/k6/explain.js
T
ricoromaandClaude Opus 5.5 5d5d8f9d2a 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>
2026-10-20 17:32:33 +03:00

42 lines
1.7 KiB
JavaScript

// Этап плана: страницы истории из plan_pages.json подряд, пока в Postgres
// стенда включён auto_explain. Для читаемого чата и первого чата каждого
// фонового уровня — первая, средняя и последняя полная страница (у
// короткого чата — первая). Порядок запросов = порядок планов в журнале:
// оркестратор сопоставляет их по нему.
import http from "k6/http";
import { check, fail } from "k6";
import { API, PAGE_LIMIT, WORK_DIR, authHeaders } from "./lib.js";
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
const pages = JSON.parse(open(`${WORK_DIR}/plan_pages.json`));
export const options = {
vus: 1,
iterations: 1,
};
export default function () {
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
for (const page of pages) {
const name = `${page.chat} ${page.page}`;
const query = page.cursor === null
? `?limit=${PAGE_LIMIT}`
: `?limit=${PAGE_LIMIT}&cursor=${encodeURIComponent(page.cursor)}`;
const res = http.get(`${API}/chats/${page.chat_id}/messages${query}`, params);
const ok = check(res, {
[`${name} 200`]: (r) => r.status === 200,
[`${name} ${page.items} items`]: (r) =>
r.status === 200 && r.json("items.#") === page.items,
});
if (!ok) {
fail(`explain page ${name}: ${res.status}`);
}
}
}
// итог не нужен: планы оркестратор берёт из журнала Postgres
export function handleSummary() {
return {};
}