feat(notify): 重构通信内核并补齐 stream/bulk/record/transfer 能力
- 引入 LogicalConn/TransportConn 分层,ClientConn 保留兼容适配层 - 新增 Stream、Bulk、RecordStream 三条数据面能力及对应控制路径 - 完成 transfer/file 传输内核与状态快照、诊断能力 - 补齐 reconnect、inbound dispatcher、modern psk 等基础模块 - 增加大规模回归、并发与基准测试覆盖 - 更新依赖库
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServerResolveOutboundTransportNilLogical(t *testing.T) {
|
||||
server := NewServer().(*ServerCommon)
|
||||
|
||||
if route := server.resolveOutboundRoute(nil); route.logical != nil || route.transport != nil {
|
||||
t.Fatalf("nil logical route mismatch: %+v", route)
|
||||
}
|
||||
if transport := server.resolveOutboundTransport(nil); transport != nil {
|
||||
t.Fatalf("resolveOutboundTransport(nil) = %+v, want nil", transport)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerResolveOutboundTransportUsesCurrentGeneration(t *testing.T) {
|
||||
server := NewServer().(*ServerCommon)
|
||||
|
||||
firstLeft, firstRight := net.Pipe()
|
||||
defer firstRight.Close()
|
||||
logical := server.bootstrapAcceptedLogical("outbound-route", nil, firstLeft)
|
||||
if logical == nil {
|
||||
t.Fatal("bootstrapAcceptedLogical should return logical")
|
||||
}
|
||||
|
||||
first := server.resolveOutboundTransport(logical)
|
||||
if first == nil {
|
||||
t.Fatal("initial outbound transport should exist")
|
||||
}
|
||||
if !first.IsCurrent() {
|
||||
t.Fatal("initial outbound transport should be current")
|
||||
}
|
||||
|
||||
secondLeft, secondRight := net.Pipe()
|
||||
defer secondLeft.Close()
|
||||
defer secondRight.Close()
|
||||
if err := server.attachAcceptedLogicalTransport(logical, secondLeft.RemoteAddr(), secondLeft); err != nil {
|
||||
t.Fatalf("attachAcceptedLogicalTransport failed: %v", err)
|
||||
}
|
||||
|
||||
second := server.resolveOutboundTransport(logical)
|
||||
if second == nil {
|
||||
t.Fatal("resolved outbound transport after reattach should exist")
|
||||
}
|
||||
if !second.IsCurrent() {
|
||||
t.Fatal("resolved outbound transport after reattach should be current")
|
||||
}
|
||||
if got, want := second.TransportGeneration(), logical.clientConnTransportGenerationSnapshot(); got != want {
|
||||
t.Fatalf("resolved outbound generation = %d, want %d", got, want)
|
||||
}
|
||||
if first.TransportGeneration() == second.TransportGeneration() {
|
||||
t.Fatalf("outbound generation should change after reattach: first=%d second=%d", first.TransportGeneration(), second.TransportGeneration())
|
||||
}
|
||||
if first.IsCurrent() {
|
||||
t.Fatal("first outbound transport should become stale after reattach")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user