decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project.
Some checks failed
ci / validate (push) Has been cancelled
Some checks failed
ci / validate (push) Has been cancelled
This commit is contained in:
@@ -2,17 +2,20 @@ import asyncio
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.models import MonitorCreate
|
from endpoint_monitor.models import MonitorCreate
|
||||||
from app.store import MonitorStore
|
from endpoint_monitor.store import Conflict, MonitorStore
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
async def test_concurrent_unique_name_is_atomic():
|
||||||
async def test_concurrent_creates_are_retained_and_results_are_copies() -> None:
|
store = MonitorStore(10)
|
||||||
state = MonitorStore()
|
data = MonitorCreate(name="same", url="https://example.com")
|
||||||
payload = MonitorCreate(name="same", url="https://example.com")
|
results = await asyncio.gather(store.create(data), store.create(data), return_exceptions=True)
|
||||||
created = await asyncio.gather(*(state.create(payload) for _ in range(25)))
|
assert sum(not isinstance(item, Exception) for item in results) == 1
|
||||||
assert len(await state.list()) == 25
|
assert sum(isinstance(item, Conflict) for item in results) == 1
|
||||||
created[0].name = "mutated"
|
|
||||||
persisted = await state.get(created[0].id)
|
|
||||||
assert persisted is not None
|
async def test_capacity():
|
||||||
assert persisted.name == "same"
|
store = MonitorStore(1)
|
||||||
|
await store.create(MonitorCreate(name="one", url="https://example.com"))
|
||||||
|
with pytest.raises(Conflict, match="capacity"):
|
||||||
|
await store.create(MonitorCreate(name="two", url="https://example.org"))
|
||||||
|
|||||||
Reference in New Issue
Block a user