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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Runner сам получает короткоживущий JWT у локаль
`fake-calendar` доступен только в тестовом режиме и требует отдельный `X-Test-Key`; секреты не
хранятся в Git. Для одинакового запуска в Docker Desktop и Linux runner имя
`host.docker.internal` явно связывается со стандартным Docker `host-gateway`.
Если задан `DOCKER_NETWORK`, k6 подключается к существующей Compose-сети и принимает внутренние
имена `channel-gateway`, `action-service` и `calendar-mcp`. Сам `test-lab` эту сеть не создаёт.

Путь начинается с публичной границы `Channel Gateway`, затем проходит через Agent Runtime, Action
Service, Temporal и Calendar MCP. Один JWT передаётся по этому пути; каждый защищённый сервис
Expand Down
2 changes: 1 addition & 1 deletion scripts/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ foreach ($oldName in @("utterance", "tenant_id", "actor_id", "available_connecto
if ($calendarScript -match "/api/v1/proposals") { throw "Acceptance-test must start through Channel Gateway." }

$runner = Get-Content scripts/run-calendar.ps1 -Raw
foreach ($required in @("ACTION_TOKEN", "KEYCLOAK_URL", "OIDC_REALM", "OIDC_CLIENT_ID", "TEST_USERNAME", "TEST_PASSWORD", "protocol/openid-connect/token", "--add-host", "host.docker.internal:host-gateway")) {
foreach ($required in @("ACTION_TOKEN", "KEYCLOAK_URL", "OIDC_REALM", "OIDC_CLIENT_ID", "TEST_USERNAME", "TEST_PASSWORD", "protocol/openid-connect/token", "--add-host", "host.docker.internal:host-gateway", "DOCKER_NETWORK", "--network")) {
if ($runner -notmatch [regex]::Escape($required)) { throw "Calendar runner does not support $required." }
}

Expand Down
32 changes: 21 additions & 11 deletions scripts/run-calendar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ param(
[string]$ChannelUrl = "",
[string]$ActionUrl = "",
[string]$CalendarTestUrl = "",
[string]$KeycloakUrl = ""
[string]$KeycloakUrl = "",
[string]$DockerNetwork = ""
)

$ErrorActionPreference = "Stop"
Expand All @@ -23,11 +24,17 @@ function Get-Setting([string]$Name, [switch]$Secret) {

function Assert-LocalUrl([string]$Url) {
$uri = [Uri]$url
if ($uri.Scheme -ne "http" -or $uri.Host -notin @("localhost", "127.0.0.1", "host.docker.internal")) {
$allowedHosts = @("localhost", "127.0.0.1", "host.docker.internal")
if ($DockerNetwork) { $allowedHosts += @("channel-gateway", "action-service", "calendar-mcp") }
if ($uri.Scheme -ne "http" -or $uri.Host -notin $allowedHosts) {
throw "Calendar acceptance test allows local HTTP URLs only."
}
}

$DockerNetwork = if ($DockerNetwork) { $DockerNetwork } else { [Environment]::GetEnvironmentVariable("DOCKER_NETWORK") }
if ($DockerNetwork -and $DockerNetwork -notmatch '^[a-zA-Z0-9][a-zA-Z0-9_.-]+$') {
throw "DOCKER_NETWORK contains unsupported characters."
}
$ChannelUrl = if ($ChannelUrl) { $ChannelUrl } else { Get-Setting "CHANNEL_URL" }
$ActionUrl = if ($ActionUrl) { $ActionUrl } else { Get-Setting "ACTION_URL" }
$CalendarTestUrl = if ($CalendarTestUrl) { $CalendarTestUrl } else { Get-Setting "CALENDAR_TEST_URL" }
Expand All @@ -54,15 +61,18 @@ $parts = $token.Split('.')
if ($parts.Count -ne 3) { throw "ACTION_TOKEN is not a JWT." }
$calendarTestKey = Get-Setting "CALENDAR_TEST_API_KEY" -Secret
$k6Image = Get-Setting "K6_IMAGE"
$dockerArgs = @("run", "--rm", "--add-host", "host.docker.internal:host-gateway")
if ($DockerNetwork) { $dockerArgs += @("--network", $DockerNetwork) }
$dockerArgs += @(
"--volume", "${PWD}/tests:/tests:ro",
"--env", "CHANNEL_URL=$ChannelUrl",
"--env", "ACTION_URL=$ActionUrl",
"--env", "CALENDAR_TEST_URL=$CalendarTestUrl",
"--env", "CALENDAR_TEST_API_KEY=$calendarTestKey",
"--env", "ACTION_TOKEN=$token",
$k6Image, "run", "/tests/calendar-event.js"
)

& docker run --rm `
--add-host "host.docker.internal:host-gateway" `
--volume "${PWD}/tests:/tests:ro" `
--env "CHANNEL_URL=$ChannelUrl" `
--env "ACTION_URL=$ActionUrl" `
--env "CALENDAR_TEST_URL=$CalendarTestUrl" `
--env "CALENDAR_TEST_API_KEY=$calendarTestKey" `
--env "ACTION_TOKEN=$token" `
$k6Image run /tests/calendar-event.js
& docker @dockerArgs

if ($LASTEXITCODE -ne 0) { throw "Calendar acceptance scenario failed." }