chore: add logging for coderdtest server lifecycle (#17376)

regarding https://github.com/coder/internal/issues/581

Adds logging around the lifecyle of the coderd HTTP server.
This commit is contained in:
Spike Curtis
2025-04-14 16:15:06 +04:00
committed by GitHub
parent 34752fa148
commit d8fcb062bc

View File

@ -421,6 +421,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
handler.ServeHTTP(w, r)
}
}))
t.Logf("coderdtest server listening on %s", srv.Listener.Addr().String())
srv.Config.BaseContext = func(_ net.Listener) context.Context {
return ctx
}
@ -433,7 +434,12 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
} else {
srv.Start()
}
t.Cleanup(srv.Close)
t.Logf("coderdtest server started on %s", srv.URL)
t.Cleanup(func() {
t.Logf("closing coderdtest server on %s", srv.Listener.Addr().String())
srv.Close()
t.Logf("closed coderdtest server on %s", srv.Listener.Addr().String())
})
tcpAddr, ok := srv.Listener.Addr().(*net.TCPAddr)
require.True(t, ok)