Files
cleveragents-core/robot/server_lifecycle.robot
freemo c6ccb85bb8 feat(server): ASGI endpoint via uvicorn
Implement FastAPI-based ASGI application served by uvicorn for
the CleverAgents server mode. Add health check endpoint, A2A
JSON-RPC routing, configurable host:port binding, and graceful
shutdown handling. Server launches via `agents server start`.

- Add FastAPI ASGI app factory at infrastructure/server/asgi_app.py
  with /.well-known/agent.json (Agent Card), /health (liveness),
  and /a2a (A2A JSON-RPC 2.0 dispatch via A2aLocalFacade)
- Add ServerLifecycle class at infrastructure/server/server_lifecycle.py
  wrapping uvicorn.Server with SIGTERM/SIGINT graceful shutdown
- Add `agents server start` CLI command with --host, --port, --log-level
  options, resolving defaults from Settings
- Add fastapi>=0.115.0 dependency to pyproject.toml (uvicorn already present)
- Add Behave BDD tests (features/server_lifecycle.feature, 20 scenarios)
- Add Robot Framework integration tests (robot/server_lifecycle.robot)
- Update CHANGELOG.md and vulture_whitelist.py

ISSUES CLOSED: #862
2026-05-29 05:08:08 -04:00

62 lines
2.7 KiB
Plaintext

*** Settings ***
Documentation Integration tests for ASGI server lifecycle
...
... Tests verify that the ASGI application, health endpoint,
... agent card, A2A dispatch, and ServerLifecycle construction
... all work end-to-end through real imports and instantiation.
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} ${CURDIR}/helper_server_lifecycle.py
*** Test Cases ***
Create ASGI Application
[Documentation] create_asgi_app returns a FastAPI instance
${result}= Run Process ${PYTHON} ${HELPER} create-app cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} create-app-ok
Health Endpoint Returns Healthy
[Documentation] GET /health returns 200 with status healthy
${result}= Run Process ${PYTHON} ${HELPER} health-endpoint cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} health-endpoint-ok
Agent Card Discovery Endpoint
[Documentation] GET /.well-known/agent.json returns valid agent card
${result}= Run Process ${PYTHON} ${HELPER} agent-card cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} agent-card-ok
A2A JSON-RPC Dispatch
[Documentation] POST /a2a dispatches health check operation via facade
${result}= Run Process ${PYTHON} ${HELPER} a2a-dispatch cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} a2a-dispatch-ok
ServerLifecycle Construction
[Documentation] ServerLifecycle construction sets host, port, and initial state
${result}= Run Process ${PYTHON} ${HELPER} lifecycle-construction cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} lifecycle-construction-ok
ServerLifecycle Graceful Shutdown
[Documentation] request_shutdown sets the should_exit flag
${result}= Run Process ${PYTHON} ${HELPER} lifecycle-shutdown cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} lifecycle-shutdown-ok