fix: 完成 broker 复审 B-03 至 B-12
每连接异步下发与背压、写出后断开、校验当前连接与订阅、生命周期串行、登录条件更新、闲置按在线计、认证超时并发与 Shutdown 0x8B。
This commit is contained in:
@@ -3,6 +3,7 @@ package broker
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
@@ -81,7 +82,16 @@ func TestLargeFrameQuotaReleasedOnDisconnect(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cancel()
|
||||
if len(b.largeSem) == 0 {
|
||||
held := false
|
||||
deadline := time.Now().Add(2 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if len(b.largeSem) > 0 {
|
||||
held = true
|
||||
break
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
if !held {
|
||||
t.Fatal("expected a held large slot before disconnect")
|
||||
}
|
||||
_ = w.Close()
|
||||
@@ -90,7 +100,7 @@ func TestLargeFrameQuotaReleasedOnDisconnect(t *testing.T) {
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("client attach did not return")
|
||||
}
|
||||
deadline := time.Now().Add(2 * time.Second)
|
||||
deadline = time.Now().Add(2 * time.Second)
|
||||
for time.Now().Before(deadline) {
|
||||
if len(b.largeSem) == 0 {
|
||||
return
|
||||
@@ -119,11 +129,11 @@ func TestLargeFrameQuotaReleasedWithoutSubscriber(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
err := b.PublishDown(ctx, "ep-large-nosub", "", payload, port.PublishOpts{QoS: 1})
|
||||
cancel()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
if !errors.Is(err, ErrNotSubscribed) {
|
||||
t.Fatalf("err=%v want ErrNotSubscribed", err)
|
||||
}
|
||||
if n := len(b.largeSem); n != 0 {
|
||||
t.Fatalf("held slots without subscriber: %d", n)
|
||||
if len(b.largeSem) != 0 {
|
||||
t.Fatalf("held slots without subscriber: %d", len(b.largeSem))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user