Track QUIC fabric stream capacity
This commit is contained in:
@@ -224,7 +224,9 @@ func TestQUICFabricTransportPrunesIdleConnections(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("connect: %v", err)
|
||||
}
|
||||
defer session.Close()
|
||||
if err := session.Close(); err != nil {
|
||||
t.Fatalf("close session: %v", err)
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
snapshot := transport.Snapshot()
|
||||
@@ -233,6 +235,51 @@ func TestQUICFabricTransportPrunesIdleConnections(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQUICFabricTransportLimitsStreamsPerConnection(t *testing.T) {
|
||||
server, err := StartQUICFabricServer(context.Background(), QUICFabricServerConfig{
|
||||
ListenAddr: "127.0.0.1:0",
|
||||
TLSConfig: testQUICTLSConfig(t),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("start quic fabric server: %v", err)
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
transport := NewQUICFabricTransport(nil)
|
||||
transport.MaxStreamsPerConn = 1
|
||||
defer transport.Close()
|
||||
target := FabricTransportTarget{
|
||||
PeerID: "node-b",
|
||||
Endpoint: server.Addr().String(),
|
||||
TLSConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
NextProtos: []string{fabricQUICNextProto},
|
||||
},
|
||||
Timeout: time.Second,
|
||||
}
|
||||
first, err := transport.Connect(ctx, target)
|
||||
if err != nil {
|
||||
t.Fatalf("first connect: %v", err)
|
||||
}
|
||||
if _, err := transport.Connect(ctx, target); err == nil {
|
||||
t.Fatal("second connect succeeded past stream limit")
|
||||
}
|
||||
snapshot := transport.Snapshot()
|
||||
if snapshot.ActiveStreams != 1 || snapshot.Stats.StreamLimitRejects != 1 {
|
||||
t.Fatalf("unexpected stream limit snapshot: %+v", snapshot)
|
||||
}
|
||||
if err := first.Close(); err != nil {
|
||||
t.Fatalf("close first stream: %v", err)
|
||||
}
|
||||
second, err := transport.Connect(ctx, target)
|
||||
if err != nil {
|
||||
t.Fatalf("connect after release: %v", err)
|
||||
}
|
||||
defer second.Close()
|
||||
}
|
||||
|
||||
func TestQUICFabricServerHandlesFabricFrames(t *testing.T) {
|
||||
var events []FabricSessionEventLogEntry
|
||||
server, err := StartQUICFabricServer(context.Background(), QUICFabricServerConfig{
|
||||
|
||||
Reference in New Issue
Block a user