Prune idle QUIC fabric connections

This commit is contained in:
2026-05-16 11:33:48 +03:00
parent 39a5e01a7b
commit 650b309686
3 changed files with 94 additions and 20 deletions
@@ -197,6 +197,42 @@ func TestQUICFabricTransportReusesConnectionForPeerEndpoint(t *testing.T) {
}
}
func TestQUICFabricTransportPrunesIdleConnections(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.IdleTTL = time.Nanosecond
defer transport.Close()
session, err := transport.Connect(ctx, FabricTransportTarget{
PeerID: "node-b",
Endpoint: server.Addr().String(),
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{fabricQUICNextProto},
},
Timeout: time.Second,
})
if err != nil {
t.Fatalf("connect: %v", err)
}
defer session.Close()
time.Sleep(time.Millisecond)
snapshot := transport.Snapshot()
if snapshot.ActiveCount != 0 || snapshot.Stats.IdleEvicted != 1 {
t.Fatalf("idle connection was not pruned: %+v", snapshot)
}
}
func TestQUICFabricServerHandlesFabricFrames(t *testing.T) {
var events []FabricSessionEventLogEntry
server, err := StartQUICFabricServer(context.Background(), QUICFabricServerConfig{