[FIXED] Flapping TestMQTTLockedSession

This commit is contained in:
Lev Brouk
2023-09-28 11:10:53 -07:00
parent f5803ef20e
commit 4b59efd6e7

View File

@@ -4667,6 +4667,19 @@ func TestMQTTLockedSession(t *testing.T) {
t.Fatalf("account session manager not found")
}
// It is possible, however unlikely, to have received CONNACK while
// mqttProcessConnect is still running, and the session remains locked. Wait
// for it to finish.
stillLocked := true
for stillLocked {
asm.mu.RLock()
_, stillLocked = asm.sessLocked["sub"]
asm.mu.RUnlock()
if stillLocked {
time.Sleep(1 * time.Millisecond)
}
}
// Get the session for "sub"
cli := testMQTTGetClient(t, s, "sub")
sess := cli.mqtt.sess