feat(pool): add authenticated worker heartbeat protocol

This commit is contained in:
冰朔 2026-09-11 14:39:01 +08:00
commit bdb82e35dd
2 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import importlib.util, json, tempfile, unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parents[2]
spec=importlib.util.spec_from_file_location('entry',ROOT/'server-tools/persona-compute-pool/entry_service.py'); M=importlib.util.module_from_spec(spec); assert spec.loader; spec.loader.exec_module(M)
class EntryServiceTests(unittest.TestCase):
def test_mother_node_is_forbidden(self):
with tempfile.TemporaryDirectory() as tmp:
old=M.STATE; M.STATE=Path(tmp)/'state.json'; M.write_state(M.read_state()); self.assertFalse('JD-FD-PRIMARY' in M.read_state()['workers']); M.STATE=old
def test_state_has_authority_false(self):
value=M.read_state(); self.assertFalse(value['authority_granted'])
if __name__=='__main__': unittest.main()