Persist QUIC fabric closed evictions
This commit is contained in:
@@ -235,6 +235,51 @@ func TestQUICFabricTransportPrunesIdleConnections(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQUICFabricTransportSnapshotPersistsClosedEvictions(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)
|
||||
defer transport.Close()
|
||||
target := FabricTransportTarget{
|
||||
PeerID: "node-b",
|
||||
Endpoint: server.Addr().String(),
|
||||
TLSConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
NextProtos: []string{fabricQUICNextProto},
|
||||
},
|
||||
Timeout: time.Second,
|
||||
}
|
||||
session, err := transport.Connect(ctx, target)
|
||||
if err != nil {
|
||||
t.Fatalf("connect: %v", err)
|
||||
}
|
||||
defer session.Close()
|
||||
key := quicFabricConnKey(target)
|
||||
transport.mu.Lock()
|
||||
entry := transport.conns[key]
|
||||
transport.mu.Unlock()
|
||||
if entry == nil || entry.conn == nil {
|
||||
t.Fatalf("cached connection missing")
|
||||
}
|
||||
_ = entry.conn.CloseWithError(0, "test closed")
|
||||
<-entry.conn.Context().Done()
|
||||
|
||||
first := transport.Snapshot()
|
||||
second := transport.Snapshot()
|
||||
if first.Stats.ClosedEvicted != 1 || second.Stats.ClosedEvicted != 1 {
|
||||
t.Fatalf("closed eviction stats were not persisted: first=%+v second=%+v", first, second)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQUICFabricTransportLimitsStreamsPerConnection(t *testing.T) {
|
||||
server, err := StartQUICFabricServer(context.Background(), QUICFabricServerConfig{
|
||||
ListenAddr: "127.0.0.1:0",
|
||||
|
||||
Reference in New Issue
Block a user