mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-04-24 18:30:28 +02:00
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:
parent
cc0004d60c
commit
8052df4ef5
18
hub.go
18
hub.go
|
@ -105,8 +105,10 @@ type Hub struct {
|
|||
info *HelloServerMessageServer
|
||||
infoInternal *HelloServerMessageServer
|
||||
|
||||
stopped int32
|
||||
stopChan chan bool
|
||||
stopped int32
|
||||
stopChan chan bool
|
||||
readPumpActive uint32
|
||||
writePumpActive uint32
|
||||
|
||||
roomUpdated chan *BackendServerRoomRequest
|
||||
roomDeleted chan *BackendServerRoomRequest
|
||||
|
@ -1858,6 +1860,14 @@ func (h *Hub) serveWs(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
h.processNewClient(client)
|
||||
go client.WritePump()
|
||||
go client.ReadPump()
|
||||
go func(h *Hub) {
|
||||
atomic.AddUint32(&h.writePumpActive, 1)
|
||||
defer atomic.AddUint32(&h.writePumpActive, ^uint32(0))
|
||||
client.WritePump()
|
||||
}(h)
|
||||
go func(h *Hub) {
|
||||
atomic.AddUint32(&h.readPumpActive, 1)
|
||||
defer atomic.AddUint32(&h.readPumpActive, ^uint32(0))
|
||||
client.ReadPump()
|
||||
}(h)
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue