Shard VPN fabric session streams
This commit is contained in:
@@ -227,6 +227,42 @@ func TestFabricSessionPacketTransportSendsDataFrame(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricSessionPacketTransportShardsStreamsByTrafficClass(t *testing.T) {
|
||||
sender := &captureFabricSessionSender{}
|
||||
transport := &FabricSessionPacketTransport{
|
||||
Sender: sender,
|
||||
StreamID: 700,
|
||||
VPNConnectionID: "vpn-1",
|
||||
SendDirection: FabricDirectionClientToGateway,
|
||||
StreamIDsByTrafficClass: map[string][]uint64{
|
||||
FabricTrafficClassInteractive: []uint64{801, 802},
|
||||
FabricTrafficClassBulk: []uint64{901, 902},
|
||||
},
|
||||
}
|
||||
bulkPacket := testIPv4TCPPacket([4]byte{10, 77, 0, 2}, [4]byte{192, 168, 200, 95}, 51000, 443)
|
||||
controlPacket := testIPv4TCPPacket([4]byte{10, 77, 0, 2}, [4]byte{192, 168, 200, 95}, 51001, 3389)
|
||||
controlPacket[33] = 0x02
|
||||
|
||||
if err := transport.SendGatewayPacketBatch(context.Background(), [][]byte{bulkPacket}); err != nil {
|
||||
t.Fatalf("send bulk packet: %v", err)
|
||||
}
|
||||
if err := transport.SendGatewayPacketBatch(context.Background(), [][]byte{controlPacket}); err != nil {
|
||||
t.Fatalf("send control packet: %v", err)
|
||||
}
|
||||
if len(sender.frames) != 2 {
|
||||
t.Fatalf("sent frames = %d, want 2", len(sender.frames))
|
||||
}
|
||||
if sender.frames[0].TrafficClass != fabricproto.TrafficClassBulk || sender.frames[0].StreamID < 901 || sender.frames[0].StreamID > 902 {
|
||||
t.Fatalf("bulk frame did not use bulk shard: %+v", sender.frames[0])
|
||||
}
|
||||
if sender.frames[1].TrafficClass != fabricproto.TrafficClassInteractive || sender.frames[1].StreamID < 801 || sender.frames[1].StreamID > 802 {
|
||||
t.Fatalf("control frame did not use interactive shard: %+v", sender.frames[1])
|
||||
}
|
||||
if sender.frames[0].Sequence != 1 || sender.frames[1].Sequence != 1 {
|
||||
t.Fatalf("per-stream sequences = %d/%d, want 1/1", sender.frames[0].Sequence, sender.frames[1].Sequence)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFabricSessionPacketTransportRunFrameIngressDeliversInbox(t *testing.T) {
|
||||
inbox := NewFabricPacketInbox(4)
|
||||
receiver := memoryFabricSessionReceiver{
|
||||
|
||||
Reference in New Issue
Block a user