spaider-cli 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/PKG-INFO +1 -1
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/pyproject.toml +2 -2
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/doctor.py +14 -6
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/api.py +10 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/stack.py +1 -1
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/stack/.env.example +11 -1
- spaider_cli-0.2.1/src/spaider_cli/stack/clickhouse/system-logs.xml +35 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/stack/docker-compose.yml +7 -1
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/PKG-INFO +1 -1
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/SOURCES.txt +2 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_commands.py +15 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_doctor.py +16 -16
- spaider_cli-0.2.1/tests/test_doctor_health.py +46 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/LICENSE +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/README.md +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/setup.cfg +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/__init__.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/__init__.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/agent.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/governance.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/init.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/mcp.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/memory.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/commands/ops.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/__init__.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/client.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/clients.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/config.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/docker.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/env.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/llm.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/lib/mcp.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/main.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/skills/__init__.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/skills/claude_code.md +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli/stack/gateway/kong.yml +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/dependency_links.txt +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/entry_points.txt +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/requires.txt +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/src/spaider_cli.egg-info/top_level.txt +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_agent.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_env.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_init.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_mcp.py +0 -0
- {spaider_cli-0.2.0 → spaider_cli-0.2.1}/tests/test_smoke.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "spaider-cli"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "SpAIder install wizard, agent management, and Claude Code skill installer"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -50,7 +50,7 @@ spaider = "spaider_cli.main:app"
|
|
|
50
50
|
where = ["src"]
|
|
51
51
|
|
|
52
52
|
[tool.setuptools.package-data]
|
|
53
|
-
"spaider_cli" = ["skills/*.md", "stack/docker-compose.yml", "stack/.env.example", "stack/gateway/*"]
|
|
53
|
+
"spaider_cli" = ["skills/*.md", "stack/docker-compose.yml", "stack/.env.example", "stack/gateway/*", "stack/clickhouse/*"]
|
|
54
54
|
|
|
55
55
|
[tool.ruff]
|
|
56
56
|
line-length = 120
|
|
@@ -109,12 +109,20 @@ def check_llm_key(repo: Path) -> CheckResult:
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
def check_backend_health() -> CheckResult:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
report = api_client.health_report()
|
|
113
|
+
if report is None:
|
|
114
|
+
return _fail(
|
|
115
|
+
"backend /health",
|
|
116
|
+
"not reachable. Run `make dev` or `docker compose up -d backend-api`.",
|
|
117
|
+
)
|
|
118
|
+
# "disabled" means switched off on purpose (the Lite profile). Only a
|
|
119
|
+
# service that is switched on and does not answer is a problem.
|
|
120
|
+
broken = sorted(name for name, state in report.get("services", {}).items() if state == "unavailable")
|
|
121
|
+
if report.get("healthy") is False:
|
|
122
|
+
return _fail("backend /health", "not healthy: " + (", ".join(broken) or "see /health"))
|
|
123
|
+
if broken:
|
|
124
|
+
return _warn("backend /health", "answers, but not available: " + ", ".join(broken))
|
|
125
|
+
return _ok("backend /health", "healthy on :8000")
|
|
118
126
|
|
|
119
127
|
|
|
120
128
|
def check_login() -> CheckResult:
|
|
@@ -85,6 +85,16 @@ def health() -> bool:
|
|
|
85
85
|
return False
|
|
86
86
|
|
|
87
87
|
|
|
88
|
+
def health_report() -> dict | None:
|
|
89
|
+
"""The full /health body, or None when the API does not answer."""
|
|
90
|
+
try:
|
|
91
|
+
with httpx.Client(timeout=2.0) as c:
|
|
92
|
+
resp = c.get(f"{api_base().rsplit('/api', 1)[0]}/health")
|
|
93
|
+
return resp.json() if resp.status_code == 200 else None
|
|
94
|
+
except Exception:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
|
|
88
98
|
def embedding_health() -> dict | None:
|
|
89
99
|
"""GET /health/embedding — embedding-dimension consistency report.
|
|
90
100
|
|
|
@@ -6,7 +6,7 @@ import subprocess
|
|
|
6
6
|
from importlib import resources
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
-
_FILES = ("docker-compose.yml", ".env.example", "gateway/kong.yml")
|
|
9
|
+
_FILES = ("docker-compose.yml", ".env.example", "gateway/kong.yml", "clickhouse/system-logs.xml")
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def stack_home() -> Path:
|
|
@@ -165,7 +165,17 @@ NEXT_PUBLIC_API_URL=http://localhost:8080/api/v1
|
|
|
165
165
|
# -----------------------------------------------------------------------------
|
|
166
166
|
# Rate Limiting
|
|
167
167
|
# -----------------------------------------------------------------------------
|
|
168
|
-
RATE_LIMIT_REQUESTS_PER_MINUTE=
|
|
168
|
+
RATE_LIMIT_REQUESTS_PER_MINUTE=600
|
|
169
|
+
|
|
170
|
+
# -----------------------------------------------------------------------------
|
|
171
|
+
# Browser access
|
|
172
|
+
# -----------------------------------------------------------------------------
|
|
173
|
+
# Web origins allowed to call the API directly from a browser (comma separated).
|
|
174
|
+
# The defaults cover the Studio on localhost. Set it when the Studio is served
|
|
175
|
+
# from another host or port, and set NEXT_PUBLIC_BACKEND_URL for the Studio build
|
|
176
|
+
# if the API is not on the same host at port 8000 (it is read when the image is built).
|
|
177
|
+
# CORS_ORIGINS=https://studio.example.com
|
|
178
|
+
# NEXT_PUBLIC_BACKEND_URL=https://api.example.com/api/v1
|
|
169
179
|
|
|
170
180
|
# -----------------------------------------------------------------------------
|
|
171
181
|
# MCP Server (SpAIder-as-MCP-server)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<clickhouse>
|
|
2
|
+
<!--
|
|
3
|
+
ClickHouse writes its own diagnostics to system.* tables and never deletes them. On a stack that
|
|
4
|
+
runs for weeks they outgrow the audit data by thousands of times: about 0.5 GB a day, 6.3 GB of
|
|
5
|
+
a 6.9 GB volume after 13 days, against about 1 MB of audit rows. A table's TTL removes the old
|
|
6
|
+
rows. Three days is plenty to look at what just happened; the busy logs get the short time, the
|
|
7
|
+
small ones keep two weeks.
|
|
8
|
+
|
|
9
|
+
Only logs that are on by default are listed. Naming a log that is off here would switch it on.
|
|
10
|
+
-->
|
|
11
|
+
<text_log>
|
|
12
|
+
<ttl>event_date + INTERVAL 3 DAY DELETE</ttl>
|
|
13
|
+
</text_log>
|
|
14
|
+
<trace_log>
|
|
15
|
+
<ttl>event_date + INTERVAL 3 DAY DELETE</ttl>
|
|
16
|
+
</trace_log>
|
|
17
|
+
<metric_log>
|
|
18
|
+
<ttl>event_date + INTERVAL 3 DAY DELETE</ttl>
|
|
19
|
+
</metric_log>
|
|
20
|
+
<asynchronous_metric_log>
|
|
21
|
+
<ttl>event_date + INTERVAL 3 DAY DELETE</ttl>
|
|
22
|
+
</asynchronous_metric_log>
|
|
23
|
+
<query_log>
|
|
24
|
+
<ttl>event_date + INTERVAL 14 DAY DELETE</ttl>
|
|
25
|
+
</query_log>
|
|
26
|
+
<part_log>
|
|
27
|
+
<ttl>event_date + INTERVAL 14 DAY DELETE</ttl>
|
|
28
|
+
</part_log>
|
|
29
|
+
<processors_profile_log>
|
|
30
|
+
<ttl>event_date + INTERVAL 14 DAY DELETE</ttl>
|
|
31
|
+
</processors_profile_log>
|
|
32
|
+
<error_log>
|
|
33
|
+
<ttl>event_date + INTERVAL 14 DAY DELETE</ttl>
|
|
34
|
+
</error_log>
|
|
35
|
+
</clickhouse>
|
|
@@ -112,6 +112,8 @@ services:
|
|
|
112
112
|
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
|
|
113
113
|
volumes:
|
|
114
114
|
- clickhouse_data:/var/lib/clickhouse
|
|
115
|
+
# Old rows of ClickHouse's own system logs are deleted after a few days; see docs/operations.md.
|
|
116
|
+
- ./clickhouse/system-logs.xml:/etc/clickhouse-server/config.d/system-logs.xml:ro
|
|
115
117
|
ulimits:
|
|
116
118
|
nofile:
|
|
117
119
|
soft: 262144
|
|
@@ -255,6 +257,7 @@ services:
|
|
|
255
257
|
context: ./frontend
|
|
256
258
|
args:
|
|
257
259
|
BACKEND_API_URL: "http://kong:8000/api"
|
|
260
|
+
NEXT_PUBLIC_BACKEND_URL: "${NEXT_PUBLIC_BACKEND_URL:-}"
|
|
258
261
|
container_name: spaider-frontend
|
|
259
262
|
ports:
|
|
260
263
|
- "${SPAIDER_BIND:-127.0.0.1}:3000:3000"
|
|
@@ -266,7 +269,6 @@ services:
|
|
|
266
269
|
environment:
|
|
267
270
|
BACKEND_API_URL: "http://kong:8000/api"
|
|
268
271
|
BACKEND_HEALTH_URL: "http://spaider-backend-api:8000"
|
|
269
|
-
NEXT_PUBLIC_API_URL: "http://localhost:8080/api"
|
|
270
272
|
restart: unless-stopped
|
|
271
273
|
|
|
272
274
|
kong:
|
|
@@ -283,6 +285,10 @@ services:
|
|
|
283
285
|
KONG_PROXY_ERROR_LOG: /dev/stderr
|
|
284
286
|
KONG_ADMIN_ERROR_LOG: /dev/stderr
|
|
285
287
|
KONG_ADMIN_LISTEN: "127.0.0.1:8001"
|
|
288
|
+
# Docker gives a recreated container a new IP. Kong keeps the old address for
|
|
289
|
+
# the lifetime of the DNS record, which is minutes, and answers 502 until then.
|
|
290
|
+
KONG_DNS_VALID_TTL: "5"
|
|
291
|
+
KONG_DNS_STALE_TTL: "5"
|
|
286
292
|
volumes:
|
|
287
293
|
- ./gateway/kong.yml:/etc/kong/kong.yml:ro
|
|
288
294
|
depends_on:
|
|
@@ -31,10 +31,12 @@ src/spaider_cli/skills/__init__.py
|
|
|
31
31
|
src/spaider_cli/skills/claude_code.md
|
|
32
32
|
src/spaider_cli/stack/.env.example
|
|
33
33
|
src/spaider_cli/stack/docker-compose.yml
|
|
34
|
+
src/spaider_cli/stack/clickhouse/system-logs.xml
|
|
34
35
|
src/spaider_cli/stack/gateway/kong.yml
|
|
35
36
|
tests/test_agent.py
|
|
36
37
|
tests/test_commands.py
|
|
37
38
|
tests/test_doctor.py
|
|
39
|
+
tests/test_doctor_health.py
|
|
38
40
|
tests/test_env.py
|
|
39
41
|
tests/test_init.py
|
|
40
42
|
tests/test_mcp.py
|
|
@@ -182,6 +182,8 @@ def test_mcp_add_rejects_unknown_clients(api):
|
|
|
182
182
|
def test_bundled_stack_unpacks(tmp_path):
|
|
183
183
|
root = stack.locate()
|
|
184
184
|
assert (root / "docker-compose.yml").exists() and (root / "gateway/kong.yml").exists()
|
|
185
|
+
# The compose file mounts this one; without it Docker would create a directory in its place.
|
|
186
|
+
assert (root / "clickhouse/system-logs.xml").read_text(encoding="utf-8").lstrip().startswith("<clickhouse>")
|
|
185
187
|
assert (root / ".env").exists()
|
|
186
188
|
|
|
187
189
|
|
|
@@ -255,3 +257,16 @@ def test_mcp_skill_refreshes_without_touching_keys(tmp_path):
|
|
|
255
257
|
assert result.exit_code == 0, result.output
|
|
256
258
|
assert "spaider.recall" in (tmp_path / ".claude/skills/spaider.md").read_text(encoding="utf-8")
|
|
257
259
|
assert config_file.read_text(encoding="utf-8") == '{"mcpServers": {"spaider": {"url": "x"}}}'
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def test_every_bundled_stack_file_is_listed_in_the_package_data():
|
|
263
|
+
# The editable install in development finds any file under stack/. The wheel carries only what the
|
|
264
|
+
# package-data patterns name, so a file missing there works in tests and is absent for users.
|
|
265
|
+
import fnmatch
|
|
266
|
+
import tomllib
|
|
267
|
+
from pathlib import Path
|
|
268
|
+
|
|
269
|
+
pyproject = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
270
|
+
patterns = tomllib.loads(pyproject.read_text(encoding="utf-8"))["tool"]["setuptools"]["package-data"]["spaider_cli"]
|
|
271
|
+
for name in stack._FILES:
|
|
272
|
+
assert any(fnmatch.fnmatch(f"stack/{name}", pattern) for pattern in patterns), f"stack/{name} would not ship"
|
|
@@ -69,8 +69,8 @@ class TestDoctorAllGreen:
|
|
|
69
69
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
70
70
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
71
71
|
), patch(
|
|
72
|
-
"spaider_cli.commands.doctor.api_client.
|
|
73
|
-
return_value=True,
|
|
72
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
73
|
+
return_value={"healthy": True, "services": {}},
|
|
74
74
|
), patch(
|
|
75
75
|
"spaider_cli.commands.doctor.api_client.embedding_health",
|
|
76
76
|
return_value={
|
|
@@ -98,8 +98,8 @@ class TestDoctorRedItems:
|
|
|
98
98
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
99
99
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
100
100
|
), patch(
|
|
101
|
-
"spaider_cli.commands.doctor.api_client.
|
|
102
|
-
return_value=
|
|
101
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
102
|
+
return_value=None,
|
|
103
103
|
):
|
|
104
104
|
result = runner.invoke(app, ["doctor", "--repo", str(repo)])
|
|
105
105
|
|
|
@@ -118,8 +118,8 @@ class TestDoctorRedItems:
|
|
|
118
118
|
"spaider_cli.commands.doctor.docker_lib.check_docker_available",
|
|
119
119
|
return_value=_good_docker(),
|
|
120
120
|
), patch(
|
|
121
|
-
"spaider_cli.commands.doctor.api_client.
|
|
122
|
-
return_value=True,
|
|
121
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
122
|
+
return_value={"healthy": True, "services": {}},
|
|
123
123
|
):
|
|
124
124
|
result = runner.invoke(app, ["doctor", "--repo", str(repo)])
|
|
125
125
|
|
|
@@ -135,8 +135,8 @@ class TestDoctorRedItems:
|
|
|
135
135
|
"spaider_cli.commands.doctor.docker_lib.check_docker_available",
|
|
136
136
|
return_value=_good_docker(),
|
|
137
137
|
), patch(
|
|
138
|
-
"spaider_cli.commands.doctor.api_client.
|
|
139
|
-
return_value=
|
|
138
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
139
|
+
return_value=None,
|
|
140
140
|
):
|
|
141
141
|
result = runner.invoke(app, ["doctor", "--repo", str(tmp_path)])
|
|
142
142
|
|
|
@@ -159,8 +159,8 @@ class TestDoctorEmbeddingDimensions:
|
|
|
159
159
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
160
160
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
161
161
|
), patch(
|
|
162
|
-
"spaider_cli.commands.doctor.api_client.
|
|
163
|
-
return_value=True,
|
|
162
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
163
|
+
return_value={"healthy": True, "services": {}},
|
|
164
164
|
), patch(
|
|
165
165
|
"spaider_cli.commands.doctor.api_client.embedding_health",
|
|
166
166
|
return_value={
|
|
@@ -187,8 +187,8 @@ class TestDoctorEmbeddingDimensions:
|
|
|
187
187
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
188
188
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
189
189
|
), patch(
|
|
190
|
-
"spaider_cli.commands.doctor.api_client.
|
|
191
|
-
return_value=True,
|
|
190
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
191
|
+
return_value={"healthy": True, "services": {}},
|
|
192
192
|
), patch(
|
|
193
193
|
"spaider_cli.commands.doctor.api_client.embedding_health",
|
|
194
194
|
return_value={
|
|
@@ -218,8 +218,8 @@ class TestDoctorWarnings:
|
|
|
218
218
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
219
219
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
220
220
|
), patch(
|
|
221
|
-
"spaider_cli.commands.doctor.api_client.
|
|
222
|
-
return_value=True,
|
|
221
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
222
|
+
return_value={"healthy": True, "services": {}},
|
|
223
223
|
):
|
|
224
224
|
result = runner.invoke(app, ["doctor", "--repo", str(repo)])
|
|
225
225
|
|
|
@@ -240,8 +240,8 @@ class TestDoctorWarnings:
|
|
|
240
240
|
"spaider_cli.commands.doctor.llm_lib.validate_openai_key",
|
|
241
241
|
return_value=KeyCheckResult(ok=True, detail=""),
|
|
242
242
|
), patch(
|
|
243
|
-
"spaider_cli.commands.doctor.api_client.
|
|
244
|
-
return_value=True,
|
|
243
|
+
"spaider_cli.commands.doctor.api_client.health_report",
|
|
244
|
+
return_value={"healthy": True, "services": {}},
|
|
245
245
|
):
|
|
246
246
|
result = runner.invoke(app, ["doctor", "--repo", str(repo)])
|
|
247
247
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""`spaider doctor` must not say "All clear" while a service is broken."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from unittest.mock import patch
|
|
5
|
+
|
|
6
|
+
from spaider_cli.commands import doctor
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _body(**services):
|
|
10
|
+
return {"status": "degraded", "healthy": True, "services": services}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_a_service_that_is_down_is_reported_even_though_the_api_answers():
|
|
14
|
+
body = _body(neo4j="ok", redis="ok", kafka="unavailable", vector_index="ok")
|
|
15
|
+
|
|
16
|
+
with patch.object(doctor.api_client, "health_report", return_value=body):
|
|
17
|
+
result = doctor.check_backend_health()
|
|
18
|
+
|
|
19
|
+
assert result.status != "ok"
|
|
20
|
+
assert "kafka" in result.detail
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_a_missing_vector_index_is_reported():
|
|
24
|
+
body = _body(neo4j="ok", redis="ok", kafka="ok", vector_index="unavailable")
|
|
25
|
+
|
|
26
|
+
with patch.object(doctor.api_client, "health_report", return_value=body):
|
|
27
|
+
result = doctor.check_backend_health()
|
|
28
|
+
|
|
29
|
+
assert result.status != "ok"
|
|
30
|
+
assert "vector_index" in result.detail
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_services_that_are_switched_off_are_not_a_problem():
|
|
34
|
+
body = {"status": "ok", "healthy": True, "services": {"neo4j": "ok", "kafka": "disabled", "vector_index": "ok"}}
|
|
35
|
+
|
|
36
|
+
with patch.object(doctor.api_client, "health_report", return_value=body):
|
|
37
|
+
result = doctor.check_backend_health()
|
|
38
|
+
|
|
39
|
+
assert result.status == "ok"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_an_unreachable_api_is_still_a_failure():
|
|
43
|
+
with patch.object(doctor.api_client, "health_report", return_value=None):
|
|
44
|
+
result = doctor.check_backend_health()
|
|
45
|
+
|
|
46
|
+
assert result.status == "fail"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|