Wait for clients to be terminated before destroying hub in tests.

This should help with the flaky test failures on CI.
This commit is contained in:
Joachim Bauch
2021-04-23 15:12:09 +02:00
parent cc0004d60c
commit 8052df4ef5
2 changed files with 18 additions and 5 deletions
+4 -1
View File
@@ -147,7 +147,9 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
h.ru.Lock()
rooms := len(h.rooms)
h.ru.Unlock()
if clients == 0 && rooms == 0 && sessions == 0 {
readActive := atomic.LoadUint32(&h.readPumpActive)
writeActive := atomic.LoadUint32(&h.writePumpActive)
if clients == 0 && rooms == 0 && sessions == 0 && readActive == 0 && writeActive == 0 {
break
}
@@ -163,6 +165,7 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
time.Sleep(time.Millisecond)
}
}
}
func validateBackendChecksum(t *testing.T, f func(http.ResponseWriter, *http.Request, *BackendClientRequest) *BackendClientResponse) func(http.ResponseWriter, *http.Request) {