Files
cleveragents-core/features/server_lifecycle_coverage_boost.feature
freemo 9c4655fd5c feat(server): container/devcontainer support lifecycle
Implement server-side container and devcontainer lifecycle management
for the CleverAgents server infrastructure.

New modules in src/cleveragents/infrastructure/server/containers/:
- DevcontainerSpec: Pydantic model for devcontainer.json parsing and
  validation (image, build, features, mounts, env vars, ports,
  hostRequirements, postCreateCommand, remoteUser, workspaceFolder).
- ResourceLimits: CPU, memory, storage, and PID limits model with
  Docker CLI argument generation and hostRequirements conversion.
- ContainerManager: Server-side lifecycle orchestration with
  create/start/stop/destroy operations using pluggable Docker CLI
  runner (mocked for tests).
- HealthMonitor: Periodic container health probing via docker
  inspect with background thread management and probe history.
- ContainerStatus enum: pending/created/running/stopped/destroyed/error
  with validated state transitions.

Tests:
- Behave BDD: 67 scenarios covering spec parsing, resource limits,
  lifecycle operations, health monitoring, and error handling
  (features/container_lifecycle.feature).
- Robot Framework: 13 integration test cases with mock Docker
  runner (robot/container_lifecycle_server.robot).

ISSUES CLOSED: #865
2026-03-23 22:50:51 +00:00

60 lines
2.8 KiB
Gherkin

Feature: Server lifecycle coverage boost
Extra scenarios to exercise error paths, edge cases, and helper
functions that are not covered by the main server_lifecycle.feature
or container_lifecycle.feature suites.
Scenario: run_server resolves settings defaults
Given a mock run_server environment that captures lifecycle args
When I invoke run_server with no overrides
Then the run_server resolved host should match the Settings default
And the run_server resolved port should match the Settings default
Scenario: run_server applies explicit host and port overrides
Given a mock run_server environment that captures lifecycle args
When I invoke run_server with host "127.0.0.1" and port 9090
Then the run_server resolved host should be "127.0.0.1"
And the run_server resolved port should be 9090
Scenario: run_server forwards a custom facade parameter
Given a mock run_server environment that captures lifecycle args
And a custom A2aLocalFacade for run_server
When I invoke run_server with the custom facade
Then the run_server captured facade should be the custom instance
Scenario: run_server forwards a log_level override
Given a mock run_server environment that captures lifecycle args
When I invoke run_server with log_level "debug"
Then the run_server captured log_level should be "debug"
Scenario: request_shutdown on lifecycle without a running server is safe
Given a ServerLifecycle that was never started
When I call request_shutdown on that lifecycle
Then the shutdown call should complete without error
Scenario: _install_signal_handlers executes on the main thread
Given a ServerLifecycle for signal handler testing
When I invoke _install_signal_handlers on it
Then signal handlers should be installed successfully
Scenario: _build_agent_card populates server URL
When I build an agent card with host "myhost" and port 7777
Then the agent card url field should be "http://myhost:7777/a2a"
Scenario: _extract_container_id parses JSON containerId
When I extract a container id from valid devcontainer JSON output
Then the extracted container id should be "abc123def"
Scenario: _extract_container_id returns empty for non-JSON input
When I extract a container id from non-JSON output
Then the extracted container id should be empty
Scenario: ManagedContainer model_dump includes all expected fields
Given a test ManagedContainer named "dump-test"
When I call model_dump on it
Then the model dump should include key "name"
And the model dump should include key "status"
And the model dump should include key "container_id"
Scenario: ContainerStatus enum covers all expected states
Then the ContainerStatus enum should include pending created running stopped error destroyed