Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- цель теста приходит через переменную, настоящий production запрещён;
- chaos выключен по умолчанию и требует отдельную метку namespace;
- тест обязан иметь понятный порог успеха;
- секреты test API передаются только переменными окружения и не хранятся в Git;
- документация на русском, имена в коде — простой английский.

## Команды
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pwsh ./scripts/run-load.ps1

```powershell
$env:ACTION_TOKEN = "<local-test-token>"
$env:CALENDAR_TEST_API_KEY = "<тот же локальный секрет, что у Calendar MCP>"
pwsh ./scripts/run-calendar.ps1
```

Скрипт принимает только локальные HTTP-адреса. Проверочный API `fake-calendar` доступен только в
тестовом режиме.
тестовом режиме и требует отдельный `X-Test-Key`; секрет не хранится в Git.
2 changes: 1 addition & 1 deletion scripts/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ foreach ($required in @("TARGET_URL", "thresholds", "http_req_failed", "http_req
if ($script -notmatch $required) { throw "В k6-тесте нет $required." }
}
$calendarScript = Get-Content tests/calendar-event.js -Raw
foreach ($required in @("AWAITING_APPROVAL", "SUCCEEDED", "payloadHash", "requestKey", "result?.eventId", "http_req_failed")) {
foreach ($required in @("AWAITING_APPROVAL", "SUCCEEDED", "payloadHash", "requestKey", "result?.eventId", "http_req_failed", "CALENDAR_TEST_API_KEY", "X-Test-Key")) {
if ($calendarScript -notmatch [regex]::Escape($required)) { throw "В calendar acceptance-тесте нет $required." }
}
Write-Host "Быстрые проверки test-lab прошли."
Expand Down
2 changes: 2 additions & 0 deletions scripts/run-calendar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ foreach ($url in @($AgentUrl, $ActionUrl, $CalendarTestUrl)) {
}
}
if (-not $env:ACTION_TOKEN) { throw "Укажи ACTION_TOKEN с JWT тестового пользователя." }
if (-not $env:CALENDAR_TEST_API_KEY) { throw "Укажи CALENDAR_TEST_API_KEY локального Calendar MCP." }
$parts = $env:ACTION_TOKEN.Split('.')
if ($parts.Count -ne 3) { throw "ACTION_TOKEN не похож на JWT." }
$payload = $parts[1].Replace('-', '+').Replace('_', '/')
Expand All @@ -32,6 +33,7 @@ if (-not $claims.sub -or -not $claims.tenant_id) {
--env "AGENT_URL=$AgentUrl" `
--env "ACTION_URL=$ActionUrl" `
--env "CALENDAR_TEST_URL=$CalendarTestUrl" `
--env "CALENDAR_TEST_API_KEY=$env:CALENDAR_TEST_API_KEY" `
--env "ACTION_TOKEN=$env:ACTION_TOKEN" `
--env "TEST_TENANT_ID=$($claims.tenant_id)" `
--env "TEST_ACTOR_ID=$($claims.sub)" `
Expand Down
2 changes: 2 additions & 0 deletions tests/calendar-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { check, fail, sleep } from 'k6';
const agentUrl = requiredUrl('AGENT_URL');
const actionUrl = requiredUrl('ACTION_URL');
const calendarTestUrl = requiredUrl('CALENDAR_TEST_URL');
const calendarTestKey = required('CALENDAR_TEST_API_KEY');
const actionToken = required('ACTION_TOKEN');
const tenantId = required('TEST_TENANT_ID');
const actorId = required('TEST_ACTOR_ID');
Expand Down Expand Up @@ -135,6 +136,7 @@ function waitForDone(actionId) {
function findEvents(requestKey) {
const response = http.get(
`${calendarTestUrl}/test/events?requestKey=${encodeURIComponent(requestKey)}`,
{ headers: { 'X-Test-Key': calendarTestKey } },
);
expectStatus(response, 200, 'fake-calendar test API is not available');
return response.json().events;
Expand Down