Close VPN fabric session stream shards
This commit is contained in:
@@ -126,6 +126,7 @@ type memoryPacketTransport struct {
|
||||
type captureFabricSessionSender struct {
|
||||
err error
|
||||
frames []fabricproto.Frame
|
||||
closed bool
|
||||
}
|
||||
|
||||
func (s *captureFabricSessionSender) Send(_ context.Context, frame fabricproto.Frame) error {
|
||||
@@ -136,6 +137,11 @@ func (s *captureFabricSessionSender) Send(_ context.Context, frame fabricproto.F
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *captureFabricSessionSender) Close() error {
|
||||
s.closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
type memoryFabricSessionReceiver struct {
|
||||
frames chan fabricproto.Frame
|
||||
errors chan error
|
||||
@@ -278,6 +284,35 @@ func TestFabricSessionPacketTransportShardsStreamsByTrafficClass(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricSessionPacketTransportClosesAllStreamShards(t *testing.T) {
|
||||
sender := &captureFabricSessionSender{}
|
||||
transport := &FabricSessionPacketTransport{
|
||||
Sender: sender,
|
||||
StreamID: 700,
|
||||
StreamIDsByTrafficClass: map[string][]uint64{
|
||||
FabricTrafficClassInteractive: []uint64{801, 802},
|
||||
FabricTrafficClassBulk: []uint64{901, 902},
|
||||
},
|
||||
}
|
||||
if err := transport.Close(); err != nil {
|
||||
t.Fatalf("close transport: %v", err)
|
||||
}
|
||||
if !sender.closed {
|
||||
t.Fatal("underlying fabric session was not closed")
|
||||
}
|
||||
closed := map[uint64]bool{}
|
||||
for _, frame := range sender.frames {
|
||||
if frame.Type == fabricproto.FrameCloseStream {
|
||||
closed[frame.StreamID] = true
|
||||
}
|
||||
}
|
||||
for _, streamID := range []uint64{700, 801, 802, 901, 902} {
|
||||
if !closed[streamID] {
|
||||
t.Fatalf("stream %d was not closed; frames=%+v", streamID, sender.frames)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricSessionPacketTransportRunFrameIngressDeliversInbox(t *testing.T) {
|
||||
inbox := NewFabricPacketInbox(4)
|
||||
receiver := memoryFabricSessionReceiver{
|
||||
|
||||
Reference in New Issue
Block a user