Skip to content

Integration test: WebSocket /v1/events/openstack (FastAPI TestClient) #2407

Description

@berendt

Part of #2400. Follow-up to #2368. Requires the shared httpx prerequisite (see the meta issue).

What

Cover the WebSocket endpoint /v1/events/openstack (osism/api.py:631) and the in-process WebSocketManager (osism/services/websocket_manager.py): connect, set filters, broadcast an event, receive it. The manager broadcasts in-process via an asyncio queue, so this needs no extra service beyond the TestClient.

Scope

  • TestClient.websocket_connect("/v1/events/openstack") accepts the connection.
  • Sending a filter message updates the connection's filters and is acknowledged.
  • An event pushed through the websocket manager is delivered to a connected client; an event that does not match the client's filters is not.
  • Disconnect cleans up the connection (manager connection count drops).

Notes / Where

New file tests/integration/test_api_websocket.py. Strictly this path is in-process and does not require Redis, but it shares the FastAPI / httpx setup with the facts-endpoint test and belongs in the same Tier 2 batch. Mark it integration for consistency. Add httpx to [dev-packages] in Pipfile if not already done for the facts test.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions