fix(backend): harden office-disabled cron, title limits, and dead-runtime cleanup (#2206)
This commit is contained in:
@@ -52,6 +52,21 @@ func freePort(t *testing.T) int {
|
||||
return port
|
||||
}
|
||||
|
||||
// requireLoopbackAlias skips the test when host cannot be bound. Linux treats
|
||||
// all of 127.0.0.0/8 as loopback, but macOS only configures 127.0.0.1 by
|
||||
// default, so multi-loopback binding tests are unrunnable there without an
|
||||
// explicit lo0 alias.
|
||||
func requireLoopbackAlias(t *testing.T, host string) {
|
||||
t.Helper()
|
||||
ln, err := net.Listen("tcp", net.JoinHostPort(host, "0"))
|
||||
if err != nil {
|
||||
t.Skipf("loopback alias %s not available on this host: %v", host, err)
|
||||
}
|
||||
if err := ln.Close(); err != nil {
|
||||
t.Fatalf("close loopback probe listener: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func noContentServer() *http.Server {
|
||||
return &http.Server{
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
@@ -109,6 +124,7 @@ func shutdown(t *testing.T, listeners *serverListeners, server *http.Server) {
|
||||
}
|
||||
|
||||
func TestStartHTTPServersMultipleLoopbackAddresses(t *testing.T) {
|
||||
requireLoopbackAlias(t, "127.0.0.2")
|
||||
log := testLogger(t)
|
||||
port := freePort(t)
|
||||
server := noContentServer()
|
||||
@@ -152,6 +168,7 @@ func TestStartHTTPServersAllFailIsFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartHTTPServersPartialFailSelfHeals(t *testing.T) {
|
||||
requireLoopbackAlias(t, "127.0.0.2")
|
||||
defer goleak.VerifyNone(t)
|
||||
|
||||
// Shorten the retry cadence for the test and restore it after.
|
||||
|
||||
Reference in New Issue
Block a user