mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Run 34421944328 web-app-litellm#1 (README host-mode replay) answered
every health probe on llm.ai.infinito.test with 502: litellm
crash-looped on "P1000: Authentication failed against database server
at postgres" while postgres logged 'Role "litellm" does not exist'. The
README inventory has no svc-db-postgres group, so sys-svc-rdbms skipped
the central provisioning, yet svc-ai-litellm pinned postgres.shared to
true and kept consuming a shared database nobody had created its role in.
postgres.shared now reads "{{ 'svc-db-postgres' in group_names }}":
an inventory with the central group keeps the shared database, the
README inventory gets a dedicated one.
That dedicated instance, rendered by sys-svc-rdbms postgres.yml.j2,
joins only the compose default network, and the networks renderer
dropped default from every svc-db-*/svc-ai-* role. A local variant-1
deploy measured litellm-database on litellm_default alone and litellm on
the shared litellm network alone. _suppress_default now keeps default
when the role's database is local. The variants pin shared to true (0)
and false (1) so the matrix exercises both paths, and the generated
READMEs show the postgres relation as 0..1.
The three attachment helpers move from render.py to attachments.py,
which render.py re-exports, and test_render.py splits along the same
seams into five files plus _render_helpers.py with every test id kept.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
204 lines
6.2 KiB
Python
204 lines
6.2 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from typing import ClassVar
|
|
|
|
from utils.networks.render import _coerce_bool, _is_consumer
|
|
|
|
from ._render_helpers import (
|
|
_const_lookup_config,
|
|
_const_lookup_database,
|
|
_role_lookup_config,
|
|
)
|
|
|
|
|
|
class TestCoerceBool(unittest.TestCase):
|
|
def test_bool_passthrough(self):
|
|
self.assertTrue(_coerce_bool(True))
|
|
self.assertFalse(_coerce_bool(False))
|
|
|
|
def test_string_truthy_set(self):
|
|
for v in ("true", "True", "TRUE", "1", "yes", "Yes"):
|
|
self.assertTrue(_coerce_bool(v), msg=v)
|
|
|
|
def test_string_falsy_set(self):
|
|
for v in ("false", "no", "0", "", "anything-else"):
|
|
self.assertFalse(_coerce_bool(v), msg=v)
|
|
|
|
def test_none_is_false(self):
|
|
self.assertFalse(_coerce_bool(None))
|
|
|
|
def test_other_truthy(self):
|
|
self.assertTrue(_coerce_bool(1))
|
|
self.assertTrue(_coerce_bool([0]))
|
|
self.assertFalse(_coerce_bool(0))
|
|
self.assertFalse(_coerce_bool([]))
|
|
|
|
|
|
class TestMcpClientConsumer(unittest.TestCase):
|
|
"""Only a client the provider admitted joins its network."""
|
|
|
|
ADMITTED: ClassVar[dict] = {"services.qdrant.mcp_consumer": True}
|
|
|
|
def _consumer(self, **flags):
|
|
entry = {
|
|
"role": "web-app-homeassistant",
|
|
"overlay": {"consumer": {"kind": "mcp_client"}},
|
|
}
|
|
return _is_consumer(
|
|
entry,
|
|
"svc-db-qdrant",
|
|
_const_lookup_config(**flags),
|
|
_const_lookup_database(),
|
|
)
|
|
|
|
def test_client_joins(self):
|
|
self.assertTrue(
|
|
self._consumer(
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "client",
|
|
**self.ADMITTED,
|
|
}
|
|
)
|
|
)
|
|
|
|
def test_both_joins(self):
|
|
self.assertTrue(
|
|
self._consumer(
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "both",
|
|
**self.ADMITTED,
|
|
}
|
|
)
|
|
)
|
|
|
|
def test_server_stays_out(self):
|
|
self.assertFalse(
|
|
self._consumer(
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "server",
|
|
}
|
|
),
|
|
"a provider on another provider's network is the mesh this kind removes",
|
|
)
|
|
|
|
def test_disabled_stays_out(self):
|
|
self.assertFalse(self._consumer(**{"mcp.direction": "client"}))
|
|
|
|
def test_a_client_that_never_declared_itself_stays_out(self):
|
|
self.assertFalse(
|
|
self._consumer(
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "client",
|
|
}
|
|
),
|
|
"being a client is not an admission; the self-declaration decides",
|
|
)
|
|
|
|
def test_a_provider_that_states_nothing_admits_a_declared_client(self):
|
|
"""Only an explicit false refuses; an unset flag inherits the client's
|
|
own declaration, and the accessor answers an unset path with false."""
|
|
entry = {
|
|
"role": "web-app-gitlab",
|
|
"overlay": {"consumer": {"kind": "mcp_client"}},
|
|
}
|
|
self.assertTrue(
|
|
_is_consumer(
|
|
entry,
|
|
"web-app-openwebui",
|
|
_role_lookup_config(
|
|
{"web-app-openwebui": {"services.openwebui.mcp_consumer": True}},
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "client",
|
|
},
|
|
),
|
|
_const_lookup_database(),
|
|
)
|
|
)
|
|
|
|
def test_a_provider_override_refuses_a_declared_client(self):
|
|
entry = {
|
|
"role": "web-app-homeassistant",
|
|
"overlay": {"consumer": {"kind": "mcp_client"}},
|
|
}
|
|
self.assertFalse(
|
|
_is_consumer(
|
|
entry,
|
|
"svc-db-qdrant",
|
|
_role_lookup_config(
|
|
{"web-app-homeassistant": {"services.qdrant.mcp_consumer": False}},
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "client",
|
|
"services.qdrant.mcp_consumer": True,
|
|
},
|
|
),
|
|
_const_lookup_database(),
|
|
)
|
|
)
|
|
|
|
|
|
class TestConsumerKindList(unittest.TestCase):
|
|
"""A provider serving two kinds of consumer declares both on one overlay.
|
|
|
|
Qdrant is the case: applications consume it as a vector database through the
|
|
services flags, and MCP clients must reach its adapter. One overlay per role
|
|
means a single `kind` cannot express both, and the second consumer silently
|
|
has no route.
|
|
"""
|
|
|
|
ENTRY: ClassVar[dict] = {
|
|
"role": "svc-db-qdrant",
|
|
"entity_name": "qdrant",
|
|
"overlay": {
|
|
"consumer": {"kind": ["services_flags", "mcp_client"], "key": "qdrant"}
|
|
},
|
|
}
|
|
|
|
def _consumer(self, application_id, **flags):
|
|
return _is_consumer(
|
|
self.ENTRY,
|
|
application_id,
|
|
_const_lookup_config(**flags),
|
|
_const_lookup_database(),
|
|
)
|
|
|
|
def test_a_service_consumer_still_joins(self):
|
|
self.assertTrue(
|
|
self._consumer(
|
|
"web-app-openwebui",
|
|
**{"services.qdrant.enabled": True, "services.qdrant.shared": True},
|
|
)
|
|
)
|
|
|
|
def test_an_admitted_mcp_client_joins(self):
|
|
self.assertTrue(
|
|
self._consumer(
|
|
"web-app-hermes",
|
|
**{
|
|
"mcp.enabled": True,
|
|
"mcp.shared": True,
|
|
"mcp.direction": "client",
|
|
"services.hermes.mcp_consumer": True,
|
|
},
|
|
)
|
|
)
|
|
|
|
def test_a_role_matching_neither_kind_stays_out(self):
|
|
self.assertFalse(self._consumer("web-app-unrelated"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|