mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
## 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
20 lines
565 B
Go
20 lines
565 B
Go
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)
|
|
}
|
|
if result.DB != "nok" || result.Redis != "nok" || result.DocEngine != "nok" || result.Storage != "nok" {
|
|
t.Fatalf("unexpected health result: %+v", result)
|
|
}
|
|
if len(result.Meta) == 0 {
|
|
t.Fatal("expected failure metadata")
|
|
}
|
|
}
|