refactor: Update component structure to use behavior and stack attributes, enhancing clarity and functionality across services, tools, and frontends
This commit is contained in:
@@ -92,7 +92,7 @@ def registry_path(tmp_path: Path, castle_root: Path) -> Generator[Path, None, No
|
||||
"TEST_SVC_DATA_DIR": "/data/castle/test-svc",
|
||||
},
|
||||
description="Test service",
|
||||
category="service",
|
||||
behavior="daemon",
|
||||
port=19000,
|
||||
health_path="/health",
|
||||
proxy_path="/test-svc",
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestComponents:
|
||||
assert svc["health_path"] == "/health"
|
||||
assert svc["proxy_path"] == "/test-svc"
|
||||
assert svc["managed"] is True
|
||||
assert svc["category"] == "service"
|
||||
assert svc["behavior"] == "daemon"
|
||||
|
||||
def test_tool_has_no_port(self, client: TestClient) -> None:
|
||||
"""Tool component has no port."""
|
||||
@@ -42,14 +42,14 @@ class TestComponents:
|
||||
data = response.json()
|
||||
tool = next(c for c in data if c["id"] == "test-tool")
|
||||
assert tool["port"] is None
|
||||
assert tool["category"] == "tool"
|
||||
assert tool["behavior"] == "tool"
|
||||
|
||||
def test_job_has_schedule(self, client: TestClient) -> None:
|
||||
"""Job component has schedule."""
|
||||
response = client.get("/components")
|
||||
data = response.json()
|
||||
job = next(c for c in data if c["id"] == "test-job")
|
||||
assert job["category"] == "job"
|
||||
assert job["behavior"] == "tool"
|
||||
assert job["schedule"] == "0 2 * * *"
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ def _make_registry() -> NodeRegistry:
|
||||
run_cmd=["uv", "run", "my-svc"],
|
||||
env={"PORT": "9001", "SECRET_KEY": "super-secret"},
|
||||
description="My service",
|
||||
category="service",
|
||||
behavior="daemon",
|
||||
stack="python-fastapi",
|
||||
port=9001,
|
||||
health_path="/health",
|
||||
proxy_path="/my-svc",
|
||||
@@ -25,7 +26,8 @@ def _make_registry() -> NodeRegistry:
|
||||
"my-job": DeployedComponent(
|
||||
runner="command",
|
||||
run_cmd=["my-job"],
|
||||
category="job",
|
||||
behavior="tool",
|
||||
stack="python-cli",
|
||||
schedule="0 2 * * *",
|
||||
),
|
||||
},
|
||||
@@ -54,6 +56,8 @@ class TestRegistrySerialization:
|
||||
assert svc.health_path == "/health"
|
||||
assert svc.proxy_path == "/my-svc"
|
||||
assert svc.managed is True
|
||||
assert svc.behavior == "daemon"
|
||||
assert svc.stack == "python-fastapi"
|
||||
|
||||
def test_job_fields_preserved(self) -> None:
|
||||
original = _make_registry()
|
||||
@@ -63,7 +67,8 @@ class TestRegistrySerialization:
|
||||
job = restored.deployed["my-job"]
|
||||
assert job.runner == "command"
|
||||
assert job.schedule == "0 2 * * *"
|
||||
assert job.category == "job"
|
||||
assert job.behavior == "tool"
|
||||
assert job.stack == "python-cli"
|
||||
|
||||
def test_optional_fields_omitted(self) -> None:
|
||||
"""Fields like port, health_path are None when not set."""
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestNodesList:
|
||||
runner="python",
|
||||
run_cmd=["svc"],
|
||||
port=9050,
|
||||
category="service",
|
||||
behavior="daemon",
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user