Go: implement system healthz API (#15307)
## Summary
- Add Go REST support for `GET /api/v1/system/healthz`.
- Return Python-compatible `ok`/`nok` dependency fields for DB, Redis,
document engine, and storage.
- Return HTTP 200 only when all checks pass; otherwise return HTTP 500
with `_meta` failure details.
- Add focused service coverage for the unhealthy dependency response
when Go dependencies are not initialized.
## Scope
This is a small, isolated slice of #15240. It avoids current open
connector PRs (#15274, #15300, #15265, #15264), tenant/member PRs
(#15295, #15301, #15276), MCP PRs (#15281, #15253, #15254, #15260,
#15261, #15262), and the memory-message PR (#15256).
Refs #15240
2026-05-27 19:30:22 -10:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestSystemServiceHealthzReportsUnhealthyDependencies(t *testing.T) {
|
|
|
|
|
result, allOK := NewSystemService().Healthz(t.Context())
|
|
|
|
|
if allOK {
|
|
|
|
|
t.Fatal("allOK=true, want false without initialized dependencies")
|
|
|
|
|
}
|
|
|
|
|
if result.Status != "nok" {
|
|
|
|
|
t.Fatalf("status=%q, want nok", result.Status)
|
|
|
|
|
}
|
2026-07-11 19:37:57 +08:00
|
|
|
if result.DB != "nok" || result.Redis != "nok" || result.DocEngine != "nok" || result.Storage != "nok" || result.MessageQueue != "nok" {
|
Go: implement system healthz API (#15307)
## Summary
- Add Go REST support for `GET /api/v1/system/healthz`.
- Return Python-compatible `ok`/`nok` dependency fields for DB, Redis,
document engine, and storage.
- Return HTTP 200 only when all checks pass; otherwise return HTTP 500
with `_meta` failure details.
- Add focused service coverage for the unhealthy dependency response
when Go dependencies are not initialized.
## Scope
This is a small, isolated slice of #15240. It avoids current open
connector PRs (#15274, #15300, #15265, #15264), tenant/member PRs
(#15295, #15301, #15276), MCP PRs (#15281, #15253, #15254, #15260,
#15261, #15262), and the memory-message PR (#15256).
Refs #15240
2026-05-27 19:30:22 -10:00
|
|
|
t.Fatalf("unexpected health result: %+v", result)
|
|
|
|
|
}
|
|
|
|
|
if len(result.Meta) == 0 {
|
|
|
|
|
t.Fatal("expected failure metadata")
|
|
|
|
|
}
|
|
|
|
|
}
|