Source: mtusi2026lab5-safronov, solution/bvt2301-safronov, 046ec9e. Contracts, public tests and evidence of lab 5 are not carried over. The compose project, image and CI prefix are renamed to lab6; the first broker start defect is recorded in KNOWN_ISSUES.md; PLAN.md outlines the OpenSpec changes of lab 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
JavaScript
49 lines
1.8 KiB
JavaScript
// Проверка после блока read: читаемый чат не изменился. Дочитывает
|
|
// историю от последнего курсора пула до конца и считает сообщения. Новое
|
|
// сообщение встало бы в конец, поэтому хвоста достаточно.
|
|
import http from "k6/http";
|
|
import { fail } from "k6";
|
|
|
|
import { API, WORK_DIR, authHeaders } from "./lib.js";
|
|
|
|
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
|
const pool = JSON.parse(open(`${WORK_DIR}/cursors.json`));
|
|
const WALK_LIMIT = Number(__ENV.WALK_LIMIT || 100);
|
|
|
|
export const options = {
|
|
vus: 1,
|
|
iterations: 1,
|
|
setupTimeout: "30m",
|
|
};
|
|
|
|
export function setup() {
|
|
const url = `${API}/chats/${fixture.readChatId}/messages`;
|
|
const params = { headers: authHeaders(fixture.tokens[fixture.readerId]) };
|
|
// пустой пул (история короче страницы обхода) — читаем с начала
|
|
const hasPool = pool.cursors.length > 0;
|
|
let cursor = hasPool ? pool.cursors[pool.cursors.length - 1] : null;
|
|
let tail = 0;
|
|
for (;;) {
|
|
const query = cursor === null
|
|
? `?limit=${WALK_LIMIT}`
|
|
: `?limit=${WALK_LIMIT}&cursor=${encodeURIComponent(cursor)}`;
|
|
const res = http.get(url + query, params);
|
|
if (res.status !== 200) {
|
|
fail(`history tail after ${tail}: ${res.status} ${res.body}`);
|
|
}
|
|
const body = res.json();
|
|
tail += body.items.length;
|
|
if (body.next_cursor === null) {
|
|
break;
|
|
}
|
|
cursor = body.next_cursor;
|
|
}
|
|
return { from_after: hasPool ? pool.last_after : 0, tail };
|
|
}
|
|
|
|
export default function () {}
|
|
|
|
export function handleSummary(data) {
|
|
return { [`${WORK_DIR}/tail.json`]: JSON.stringify(data.setup_data) };
|
|
}
|