mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
Three faults, one mechanism each, that together let the oracle suite report a verdict it never reached. The address. lane_url handed out the runner's compose service name, but the stack's containers resolve through the deployment's CoreDNS, which never learns one: getent hosts tools answers nothing inside them, so every check that asked the lane from there skipped itself. The bring-up now writes the runner's address, picked as the one inside INFINITO_SUBNET because the runner sits on every network it was ever brought up on, and the checks read it from there. It is rewritten on both paths, because a restart gives the runner a new one. The readiness. serving judged the engine alone, so a lane whose engine make i18n had already brought up counted as up while System One was down. It now probes every role the caller names, which is why the runner republishes System One's port: a container IP is unreachable from the host that decides whether to deploy. The verdict. A silent lane made the suite skip, and a skip exits green. Only a deploy that is already running leaves the stack alone and exits 0 now; a crashed deploy and a deployed-but-silent role both exit 1. The override's third :? guard is added to the gate that decides whether the file is layered in at all, next to the one that was already missing. Without it an .env written before these keys aborts every compose command, down to compose-down, instead of dropping the lane. A test now keeps that list and the override's guards in step. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
"""Unit tests for utils.inventory.tools.serving."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
from utils.inventory import tools
|
|
from utils.inventory.tools import LIBRETRANSLATE_ROLE, S1_ROLE, serving
|
|
|
|
ROOT = Path("/nowhere")
|
|
ENGINE_LANGUAGES = b'[{"code": "de"}, {"code": "en"}]'
|
|
|
|
|
|
class TestServing(unittest.TestCase):
|
|
def _run(self, answers: dict[str, bytes | None], roles: tuple[str, ...]) -> bool:
|
|
with (
|
|
patch.object(tools, "host_url", lambda root, role, key: f"http://{role}"),
|
|
patch.object(tools, "_answers", answers.get),
|
|
):
|
|
return serving(ROOT, ["de"], roles)
|
|
|
|
def test_engine_alone_does_not_speak_for_system_one(self) -> None:
|
|
self.assertFalse(
|
|
self._run(
|
|
{f"http://{LIBRETRANSLATE_ROLE}/languages": ENGINE_LANGUAGES},
|
|
(LIBRETRANSLATE_ROLE, S1_ROLE),
|
|
)
|
|
)
|
|
|
|
def test_both_answering_is_serving(self) -> None:
|
|
self.assertTrue(
|
|
self._run(
|
|
{
|
|
f"http://{LIBRETRANSLATE_ROLE}/languages": ENGINE_LANGUAGES,
|
|
f"http://{S1_ROLE}/health": b"ok",
|
|
},
|
|
(LIBRETRANSLATE_ROLE, S1_ROLE),
|
|
)
|
|
)
|
|
|
|
def test_a_role_nobody_asked_for_is_not_probed(self) -> None:
|
|
self.assertTrue(self._run({f"http://{S1_ROLE}/health": b"ok"}, (S1_ROLE,)))
|
|
|
|
def test_a_missing_language_still_fails_the_engine(self) -> None:
|
|
self.assertFalse(
|
|
self._run(
|
|
{
|
|
f"http://{LIBRETRANSLATE_ROLE}/languages": b'[{"code": "en"}]',
|
|
f"http://{S1_ROLE}/health": b"ok",
|
|
},
|
|
(LIBRETRANSLATE_ROLE, S1_ROLE),
|
|
)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|