The watchdog polled http://127.0.0.1:8420/healthz. Nothing binds 8420: the daemon serves /healthz on [web].listen (127.0.0.1:8484 by default), so every dashboard- or Telegram-initiated update waited out the 60s health timeout and rolled back a release that had come up fine. The daemon is the only process that knows which address it binds, so it now derives the probe URL from its own config and hands it to the installer; CommandInstaller exports ARCHIE_HEALTH_URL and the install script forwards it into the watchdog unit, whose remaining default matches the dashboard's. The suite never dialled the URL: every watchdog test faked curl as an immediate failure, so only the unhealthy branch existed. One test now runs the real curl against a real listener, and another pins the script default.
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package webui
|
|
|
|
import "testing"
|
|
|
|
func TestDashboardURL(t *testing.T) {
|
|
for _, tc := range []struct{ listen, token, want string }{
|
|
{"0.0.0.0:8484", "abc", "http://localhost:8484/?t=abc"},
|
|
{":8484", "abc", "http://localhost:8484/?t=abc"},
|
|
{"[::]:8484", "abc", "http://localhost:8484/?t=abc"},
|
|
{"127.0.0.1:8484", "", "http://127.0.0.1:8484/"},
|
|
{"100.64.1.2:8484", "x", "http://100.64.1.2:8484/?t=x"},
|
|
} {
|
|
if got := DashboardURL(tc.listen, tc.token); got != tc.want {
|
|
t.Errorf("DashboardURL(%q) = %q, want %q", tc.listen, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestHealthURL pins what out-of-process tooling probes after restarting
|
|
// archied. A wrong address here reads as an unhealthy release and triggers a
|
|
// rollback of one that came up fine (archie-core-1r4g).
|
|
func TestHealthURL(t *testing.T) {
|
|
for _, tc := range []struct{ listen, want string }{
|
|
{"127.0.0.1:8484", "http://127.0.0.1:8484"},
|
|
{"localhost:8484", "http://localhost:8484"},
|
|
{"0.0.0.0:8484", "http://localhost:8484"},
|
|
{":8484", "http://localhost:8484"},
|
|
{"[::]:8484", "http://localhost:8484"},
|
|
{"100.64.1.2:9000", "http://100.64.1.2:9000"},
|
|
{" 127.0.0.1:8484 ", "http://127.0.0.1:8484"},
|
|
{"off", ""},
|
|
{"", ""},
|
|
} {
|
|
if got := HealthURL(tc.listen); got != tc.want {
|
|
t.Errorf("HealthURL(%q) = %q, want %q", tc.listen, got, tc.want)
|
|
}
|
|
}
|
|
}
|