feat: add reconcile strategies, deep check, rate limit and cost profile
- reconcile --strategy head, --deep (checksum_mismatch), restore needs the same SHA-256 - [reconciler] max_objects_per_second (2000), pause interrupted by signal - --apply stops rechecks once the limit is exceeded (unchecked) - pass cost in the summary: S3 objects and requests, bytes, DB sessions, phases - S3 client counters, cleaner exits with os._exit after main() - fault tests, hook args, driver reconcile-signal --pace - bench profile reconcile / reconcile_quick: fill outside the API, gateway metrics, background load - sync spec deltas, rules, AGENTS.md, PLAN.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
// Фоновая нагрузка профиля сверки (design change track2-reconcile-cost,
|
||||
// решение 10): открытая модель, три сценария constant-arrival-rate через
|
||||
// LB — скачивания оригиналов вложений набора (`/work/downloads.json` от
|
||||
// run.py; читатель фикстуры — владелец и участник чата набора), запись
|
||||
// сообщений в чат записи и чтение его первой страницы истории. Каждый
|
||||
// запрос — строка «bg,<d|w|r>,<отправка мс>,<длительность мс>,<статус>» в
|
||||
// файл консоли k6; run.py делит их на окна до, во время и после прохода
|
||||
// сверки и сверяет число строк с итерациями сценариев. Оркестратор
|
||||
// останавливает прогон сигналом SIGINT, когда блок проходов закончен:
|
||||
// итог (handleSummary) k6 пишет и тогда.
|
||||
import exec from "k6/execution";
|
||||
import http from "k6/http";
|
||||
import { SharedArray } from "k6/data";
|
||||
|
||||
import {
|
||||
API,
|
||||
PAGE_LIMIT,
|
||||
SUMMARY_THRESHOLDS,
|
||||
SUMMARY_TREND_STATS,
|
||||
WORK_DIR,
|
||||
authHeaders,
|
||||
messageHeaders,
|
||||
summaryFiles,
|
||||
syntheticText,
|
||||
} from "./lib.js";
|
||||
|
||||
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
|
||||
const ids = new SharedArray(
|
||||
"downloads",
|
||||
() => JSON.parse(open(`${WORK_DIR}/downloads.json`)),
|
||||
);
|
||||
const DURATION = __ENV.DURATION || "1h";
|
||||
const PRE_VUS = Number(__ENV.PRE_VUS || 100);
|
||||
const MAX_VUS = Number(__ENV.MAX_VUS || 600);
|
||||
const TIMEOUT = __ENV.TIMEOUT || "15s";
|
||||
const READER = authHeaders(fixture.tokens[fixture.readerId]);
|
||||
const WRITE_URL = `${API}/chats/${fixture.writeChatId}/messages`;
|
||||
|
||||
function scenario(fn, rate) {
|
||||
return {
|
||||
executor: "constant-arrival-rate",
|
||||
exec: fn,
|
||||
rate,
|
||||
timeUnit: "1s",
|
||||
duration: DURATION,
|
||||
preAllocatedVUs: PRE_VUS,
|
||||
maxVUs: MAX_VUS,
|
||||
gracefulStop: "5s",
|
||||
};
|
||||
}
|
||||
|
||||
export const options = {
|
||||
scenarios: {
|
||||
download: scenario("download", Number(__ENV.DOWNLOAD_RATE)),
|
||||
write: scenario("write", Number(__ENV.WRITE_RATE)),
|
||||
read: scenario("read", Number(__ENV.READ_RATE)),
|
||||
},
|
||||
summaryTrendStats: SUMMARY_TREND_STATS,
|
||||
// пороги всегда выполняются: подметрики итераций по сценариям попадают
|
||||
// в итог, и run.py сверяет с ними число строк о запросах
|
||||
thresholds: {
|
||||
...SUMMARY_THRESHOLDS,
|
||||
"iterations{scenario:download}": ["count>=0"],
|
||||
"iterations{scenario:write}": ["count>=0"],
|
||||
"iterations{scenario:read}": ["count>=0"],
|
||||
},
|
||||
};
|
||||
|
||||
// длительность — по монотонным таймингам k6 (как в failover.js), с точностью
|
||||
// 0,01 мс: p95 чтения истории — единицы миллисекунд, и целые мс огрубляли
|
||||
// бы отношение r; без ответа (status 0) — разность часов
|
||||
function report(kind, start, res) {
|
||||
const t = res.timings;
|
||||
const measured = t.blocked + t.connecting + t.tls_handshaking + t.duration;
|
||||
const duration = Math.max(
|
||||
0,
|
||||
Math.round((res.status === 0 ? Date.now() - start : measured) * 100) / 100,
|
||||
);
|
||||
console.log(`bg,${kind},${start},${duration},${res.status}`);
|
||||
}
|
||||
|
||||
export function download() {
|
||||
const n = exec.scenario.iterationInTest;
|
||||
const id = ids[n % ids.length];
|
||||
const start = Date.now();
|
||||
const res = http.get(`${API}/attachments/${id}/content`, {
|
||||
headers: READER,
|
||||
responseType: "none",
|
||||
timeout: TIMEOUT,
|
||||
responseCallback: http.expectedStatuses(200),
|
||||
});
|
||||
report("d", start, res);
|
||||
}
|
||||
|
||||
export function write() {
|
||||
const n = exec.scenario.iterationInTest;
|
||||
const sender = fixture.memberIds[n % fixture.memberIds.length];
|
||||
const start = Date.now();
|
||||
const res = http.post(
|
||||
WRITE_URL,
|
||||
JSON.stringify({ text: syntheticText("bg", n) }),
|
||||
{
|
||||
headers: messageHeaders(fixture.tokens[sender]),
|
||||
responseType: "none",
|
||||
timeout: TIMEOUT,
|
||||
responseCallback: http.expectedStatuses(201),
|
||||
},
|
||||
);
|
||||
report("w", start, res);
|
||||
}
|
||||
|
||||
export function read() {
|
||||
const start = Date.now();
|
||||
const res = http.get(`${WRITE_URL}?limit=${PAGE_LIMIT}`, {
|
||||
headers: READER,
|
||||
responseType: "none",
|
||||
timeout: TIMEOUT,
|
||||
responseCallback: http.expectedStatuses(200),
|
||||
});
|
||||
report("r", start, res);
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return summaryFiles(data);
|
||||
}
|
||||
Reference in New Issue
Block a user