Complete migration from FastAPI/HTTP to gRPC: Proto definition (proto/daena/v1/daena.proto): - Daena service with 9 RPCs: GetStatus, GetHealth, GetConfig, ListPlugins, GetQueueState, ListPendingRecords, ListDeadRecords, ListSinks, ReloadConfig - Messages for all request/response types with proper field types gRPC server (src/daena/api/grpc_server.py): - Async gRPC aio server with DaenaServicer implementation - DaenaGRPCServer with start/stop/serve_forever lifecycle - All endpoints delegate to DaenaRuntime gRPC client (src/daena/cli/main.py): - CLI now uses grpc.insecure_channel + DaenaStub - Same commands: status, health, queue, sinks, plugins, config, version Config changes: - Remove FastAPI/uvicorn/http config, replace with grpc config - GRPCConfig with host/port/max_workers Dependency changes: - Remove fastapi, uvicorn, starlette, anyio - Add grpcio, grpcio-tools, protobuf - Keep httpx for HTTP sink forwarding (separate from management API) Tests: - 8 new gRPC integration tests (test_grpc.py) - All 31 tests passing, ruff clean
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from daena.config import DaenaConfig, load_config
|
|
|
|
|
|
def test_minimal_config_has_defaults() -> None:
|
|
config = DaenaConfig()
|
|
assert config.data_dir == "/var/lib/daena"
|
|
assert config.logging.level == "info"
|
|
assert config.api.grpc.port == 8642
|
|
assert config.pipeline.batch_size == 100
|
|
|
|
|
|
def test_load_config_from_file(config_file: Path) -> None:
|
|
config = load_config(str(config_file))
|
|
assert config.data_dir == "/tmp/daena_data"
|
|
assert config.logging.level == "debug"
|
|
assert len(config.sources) == 1
|
|
assert config.sources[0].name == "test"
|
|
assert config.sources[0].type == "dummy"
|
|
|
|
|
|
def test_load_config_nonexistent_file() -> None:
|
|
try:
|
|
load_config("/nonexistent/daena.yaml")
|
|
raise AssertionError("Expected FileNotFoundError") # noqa: B011
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
|
|
def test_config_can_set_persistence_backend() -> None:
|
|
config = DaenaConfig()
|
|
assert config.persistence.backend == "lmdb"
|
|
assert config.persistence.lmdb.map_size == 104_857_600
|
|
|
|
|
|
def test_config_source_options(minimal_config: DaenaConfig) -> None:
|
|
cfg = minimal_config
|
|
assert cfg.sources == []
|
|
assert cfg.processors == []
|
|
assert cfg.sinks == []
|