feat: expose streaming test run results

This commit is contained in:
a.tolmachev
2026-04-07 18:30:08 +03:00
parent 35e9c8c754
commit 1a4f0ea6f3
9 changed files with 865 additions and 91 deletions
+96 -62
View File
@@ -264,11 +264,11 @@
## 8. Streaming operation test-runs
### `POST /api/admin/workspaces/{workspace_id}/operations/{operation_id}/stream-test-runs`
### `POST /api/admin/workspaces/{workspace_id}/operations/{operation_id}/test-runs`
Назначение:
- выполнить `window`, `session` или `async_job` test-run для draft version;
- выполнить `unary`, `window`, `session` или `async_job` test-run для draft version;
- показать оператору runtime behavior до publish.
Тело:
@@ -280,30 +280,57 @@
"service": "billing",
"level": "error"
},
"test_mode": "window",
"overrides": {
"streaming": {
"window_duration_ms": 3000,
"max_items": 50
}
"version": 4,
"input": {
"service": "billing",
"level": "error"
}
}
```
Успех для `unary`:
```json
{
"ok": true,
"mode": "unary",
"request_preview": {
"service": "billing",
"level": "error"
},
"response_preview": {
"summary": "completed"
},
"errors": [],
"window": null,
"stream_session": null,
"async_job": null
}
```
Успех для `window`:
```json
{
"run_id": "strun_01j0test",
"ok": true,
"mode": "window",
"status": "completed",
"window_complete": true,
"truncated": false,
"has_more": false,
"summary": {},
"items": [],
"cursor": null,
"duration_ms": 2871
"request_preview": {
"service": "billing",
"level": "error"
},
"response_preview": {
"summary": {},
"items": []
},
"errors": [],
"window": {
"window_complete": true,
"truncated": false,
"has_more": false,
"cursor": null
},
"stream_session": null,
"async_job": null
}
```
@@ -311,18 +338,29 @@
```json
{
"run_id": "strun_01j0test",
"ok": true,
"mode": "session",
"status": "running",
"session": {
"session_id": "sess_01j0stream",
"expires_at": "2026-04-06T12:05:00Z",
"poll_after_ms": 2000
"request_preview": {
"service": "billing",
"level": "error"
},
"preview": {
"response_preview": {
"summary": {},
"items": []
}
},
"errors": [],
"window": null,
"stream_session": {
"session_id": "sess_01j0stream",
"status": "running",
"expires_at": "2026-04-06T12:05:00Z",
"poll_after_ms": 2000,
"preview": {
"summary": {},
"items": []
}
},
"async_job": null
}
```
@@ -330,10 +368,19 @@
```json
{
"run_id": "strun_01j0test",
"ok": true,
"mode": "async_job",
"status": "running",
"job": {
"request_preview": {
"service": "billing",
"level": "error"
},
"response_preview": {
"job": "started"
},
"errors": [],
"window": null,
"stream_session": null,
"async_job": {
"job_id": "job_01j0deploy",
"status": "running",
"progress": {
@@ -343,47 +390,34 @@
}
```
### `POST /api/admin/workspaces/{workspace_id}/operations/{operation_id}/stream-test-runs/{run_id}/poll`
Назначение:
- продолжить session-oriented test-run.
Тело:
Ошибка:
```json
{
"session_id": "sess_01j0stream"
"ok": false,
"mode": "window",
"request_preview": {
"service": "billing",
"level": "error"
},
"response_preview": null,
"errors": [
{
"code": "runtime_test_failure",
"message": "upstream timeout"
}
],
"window": null,
"stream_session": null,
"async_job": null
}
```
Ответ:
Примечания:
```json
{
"run_id": "strun_01j0test",
"mode": "session",
"status": "running",
"window_complete": false,
"truncated": false,
"has_more": true,
"summary": {},
"items": [],
"cursor": "next_cursor"
}
```
### `POST /api/admin/workspaces/{workspace_id}/operations/{operation_id}/stream-test-runs/{run_id}/stop`
Назначение:
- остановить test session.
### `GET /api/admin/workspaces/{workspace_id}/operations/{operation_id}/stream-test-runs/{run_id}/result`
Назначение:
- получить финальный результат async-job test-run.
- endpoint не использует отдельные `stream-test-runs/*` subresources;
- session и async-job test-runs создают обычные runtime resources в `stream_sessions` и `async_jobs`;
- дальнейшее наблюдение идет через `GET /stream-sessions`, `GET /stream-sessions/{session_id}`, `POST /stream-sessions/{session_id}/stop`, `GET /async-jobs`, `GET /async-jobs/{job_id}`, `GET /async-jobs/{job_id}/result`, `POST /async-jobs/{job_id}/cancel`.
## 9. Runtime session resources