Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion v1/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,10 @@ func (rt *Runtime) Addrs() []string {
// listening on (when in server mode). Returns an empty list if it hasn't
// started listening.
func (rt *Runtime) DiagnosticAddrs() []string {
if rt.server == nil {
rt.serverInitMtx.RLock()
defer rt.serverInitMtx.RUnlock()

if rt.serverStatus < ServerInitialized {
return nil
}

Expand Down
12 changes: 11 additions & 1 deletion v1/test/e2e/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (t *TestRuntime) WaitForServer() error {
retries := 100 // 10 seconds before we give up
for range retries {
// First make sure it has started listening and we have an address
if t.URL() != "" {
if t.URL() != "" && t.diagnosticAddrsReady() {
// Then make sure it has started serving
err := t.HealthCheck(t.URL())
if err == nil {
Expand All @@ -322,6 +322,16 @@ func (t *TestRuntime) WaitForServer() error {
return errors.New("API Server not ready in time")
}

// diagnosticAddrsReady reports whether every configured diagnostic address has
// been bound. Listeners bind on their own goroutines, so the diagnostic one can
// still be unbound once the main one is serving.
func (t *TestRuntime) diagnosticAddrsReady() bool {
if t.Params.DiagnosticAddrs == nil {
return true
}
return len(t.Runtime.DiagnosticAddrs()) >= len(*t.Params.DiagnosticAddrs)
}

func (t *TestRuntime) WaitForServerStatus(status runtime.ServerStatus) error {
delay := time.Duration(100) * time.Millisecond
retries := 100 // 10 seconds before we give up
Expand Down