Implemented handshake and heartbeat

Implemented handshake in json server and handoff to endpoint

Endpoint handles connector handshake accept/decline then launches both
its IO threads alongside its heartbeat thread which contains simple
timeout logic, timeout calls connection handles to close, subsequently
killing the endpoint
This commit is contained in:
2026-08-04 22:11:53 +01:00
parent 98814b122c
commit f3b1a537f0
17 changed files with 1030 additions and 96 deletions
+23 -7
View File
@@ -1,3 +1,5 @@
import logging
import pytest
from dynalab_core import Core
from dynalab_core.config import CoreConfig
@@ -5,14 +7,28 @@ from dynalab_core.errors import CoreStateMismatchError
from test.common import find_available_port
def test_core_cannot_start_twice() -> None:
def test_core_cannot_start_twice(caplog: pytest.LogCaptureFixture) -> None:
port = find_available_port(8765)
core = Core(CoreConfig(port=port))
core.start()
with caplog.at_level(logging.DEBUG, logger="dynalab_core"):
core.start()
try:
with pytest.raises(CoreStateMismatchError):
core.start()
finally:
core.stop()
try:
with pytest.raises(CoreStateMismatchError):
core.start()
finally:
core.stop()
events = [getattr(record, "event", None) for record in caplog.records]
assert events.count("core.starting") == 1
assert "core.start_rejected" in events
assert "core.stopped" in events
rejection = next(
record
for record in caplog.records
if getattr(record, "event", None) == "core.start_rejected"
)
assert rejection.levelno == logging.WARNING
assert rejection.core_state == "started"