The update watchdog verifies archied's restart, so archied has to be what answers. It was probing the dashboard's /healthz, which belongs to the dashboard: switch [web] off and nothing answers, and in the extracted UI topology that endpoint reports a different process entirely, which would confirm a release while the daemon it was meant to verify is down. [health].listen (127.0.0.1:8485, defaulted, always on) serves /healthz, /health and /health/detailed for the life of the process. Liveness answers 503 until the daemon reaches its run loop: the listener binds before the subsystems do, so an unconditional 200 would tell the watchdog a half-booted release came up. Failing to bind is fatal, because a daemon nothing can probe gets every update rolled back. The State Store's readiness surface now shares the listener plumbing, keeping its log and error text verbatim. Closes archie-core-exbz, which asked which of two bad options to take when the dashboard is off. Neither: the daemon owns its own liveness. Also deletes TestInstallUpdateDetachesInstallerFromCallbackContext. It has failed intermittently under load more than once, racing its fake bot server's multipart parse against the cancellation it induces.
59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
package configuration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestLoadGatewayServiceTarget(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name, section, wantTarget string
|
|
}{
|
|
{name: "default", wantTarget: "127.0.0.1:8585"},
|
|
{name: "explicit target", section: "[services.gateway]\ntarget = 'dns:///gateway:8443'", wantTarget: "dns:///gateway:8443"},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "config.toml")
|
|
if err := os.WriteFile(path, []byte("bot_user = 'widget'\n"+tt.section), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cfg, err := loadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.Services.Gateway.Target != tt.wantTarget {
|
|
t.Fatalf("target = %q, want %q", cfg.Services.Gateway.Target, tt.wantTarget)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// TestLoadHealthListen: the daemon's liveness surface is not optional. The
|
|
// update watchdog restarts archied and asks whether it came back, and only
|
|
// archied can answer that -- the dashboard's /healthz belongs to the
|
|
// dashboard, which can be switched off and moves to its own process
|
|
// (archie-core-1r4g, archie-core-exbz).
|
|
func TestLoadHealthListen(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
name, section, wantListen string
|
|
}{
|
|
{name: "default", wantListen: "127.0.0.1:8485"},
|
|
{name: "explicit listen", section: "[health]\nlisten = '127.0.0.1:9500'", wantListen: "127.0.0.1:9500"},
|
|
} {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "config.toml")
|
|
if err := os.WriteFile(path, []byte("bot_user = 'widget'\n"+tt.section), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cfg, err := loadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.Health.Listen != tt.wantListen {
|
|
t.Fatalf("health listen = %q, want %q", cfg.Health.Listen, tt.wantListen)
|
|
}
|
|
})
|
|
}
|
|
}
|