Skip to content

Commit 740873f

Browse files
committed
Add more parameterized test cases
1 parent f05f636 commit 740873f

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

bwe_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ func TestMain(m *testing.M) {
6767

6868
func TestBWE(t *testing.T) {
6969
networks := map[string]vnetFactory{
70-
"constant_capacity": createVirtualNetwork(),
70+
"constant_capacity_1mbps_very_low_latency": createVirtualNetwork(1_000_000, 80_000, 50*time.Millisecond),
71+
"constant_capacity_5mbps_very_low_latency": createVirtualNetwork(5_000_000, 80_000, 50*time.Millisecond),
72+
"constant_capacity_1mbps_low_latency": createVirtualNetwork(1_000_000, 80_000, 50*time.Millisecond),
73+
"constant_capacity_5mbps_low_latency": createVirtualNetwork(5_000_000, 80_000, 50*time.Millisecond),
74+
"constant_capacity_1mbps_medium_latency": createVirtualNetwork(1_000_000, 80_000, 150*time.Millisecond),
75+
"constant_capacity_5mbps_medium_latency": createVirtualNetwork(5_000_000, 80_000, 150*time.Millisecond),
76+
"constant_capacity_1mbps_high_latency": createVirtualNetwork(1_000_000, 80_000, 300*time.Millisecond),
77+
"constant_capacity_5mbps_high_latency": createVirtualNetwork(5_000_000, 80_000, 300*time.Millisecond),
7178
}
7279
for name, vnf := range networks {
7380
t.Run(name, func(t *testing.T) {
@@ -86,7 +93,6 @@ func TestBWE(t *testing.T) {
8693
receiver, err := newPeer(
8794
registerDefaultCodecs(),
8895
setVNet(network.left, []string{"10.0.1.1"}),
89-
registerTWCC(),
9096
onRemoteTrack(func(track *webrtc.TrackRemote) {
9197
close(onTrack)
9298
go func() {
@@ -152,7 +158,7 @@ func TestBWE(t *testing.T) {
152158

153159
select {
154160
case <-onTrack:
155-
case <-time.After(time.Second):
161+
case <-time.After(5 * time.Second):
156162
assert.Fail(t, "on track not called")
157163
}
158164

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/pion/logging v0.2.4
88
github.com/pion/rtcp v1.2.16
99
github.com/pion/rtp v1.8.24
10-
github.com/pion/transport/v3 v3.0.8
10+
github.com/pion/transport/v3 v3.0.9-0.20251018195250-6c2e33524ea2
1111
github.com/pion/webrtc/v4 v4.1.4
1212
github.com/stretchr/testify v1.11.1
1313
)
@@ -32,5 +32,3 @@ require (
3232
golang.org/x/sys v0.30.0 // indirect
3333
gopkg.in/yaml.v3 v3.0.1 // indirect
3434
)
35-
36-
replace github.com/pion/transport/v3 v3.0.8 => ../transport

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/pion/srtp/v3 v3.0.7 h1:QUElw0A/FUg3MP8/KNMZB3i0m8F9XeMnTum86F7S4bs=
3232
github.com/pion/srtp/v3 v3.0.7/go.mod h1:qvnHeqbhT7kDdB+OGB05KA/P067G3mm7XBfLaLiaNF0=
3333
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
3434
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU=
35-
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
36-
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
35+
github.com/pion/transport/v3 v3.0.9-0.20251018195250-6c2e33524ea2 h1:03XFM07X4ZukGIeIWZ7nfe0LHvqoA3tjG6DDypHugLg=
36+
github.com/pion/transport/v3 v3.0.9-0.20251018195250-6c2e33524ea2/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
3737
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc=
3838
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8=
3939
github.com/pion/webrtc/v4 v4.1.4 h1:/gK1ACGHXQmtyVVbJFQDxNoODg4eSRiFLB7t9r9pg8M=

peer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func registerCCFB() option {
122122

123123
func initGCC(onRateUpdate func(int)) option {
124124
return func(p *peer) (err error) {
125-
p.estimator, err = gcc.NewSendSideController(1_000_000, 128_000, 5_000_000)
125+
p.estimator, err = gcc.NewSendSideController(1_000_000, 128_000, 50_000_000)
126126
if err != nil {
127127
return err
128128
}

virtual_network_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (n *virtualNetwork) Close() error {
3636
)
3737
}
3838

39-
func createVirtualNetwork() func(*testing.T) *virtualNetwork {
39+
func createVirtualNetwork(rate, burst int, delay time.Duration) func(*testing.T) *virtualNetwork {
4040
return func(t *testing.T) *virtualNetwork {
4141
t.Helper()
4242

@@ -58,10 +58,14 @@ func createVirtualNetwork() func(*testing.T) *virtualNetwork {
5858
})
5959
assert.NoError(t, err)
6060

61-
leftTBF, err := vnet.NewTokenBucketFilter(leftRouter, vnet.TBFRate(1_000_000), vnet.TBFMaxBurst(80_000))
61+
leftTBF, err := vnet.NewTokenBucketFilter(
62+
leftRouter,
63+
vnet.TBFRate(rate),
64+
vnet.TBFMaxBurst(burst),
65+
)
6266
assert.NoError(t, err)
6367

64-
leftDelay, err := vnet.NewDelayFilter(leftTBF, 10*time.Millisecond)
68+
leftDelay, err := vnet.NewDelayFilter(leftTBF, delay)
6569
assert.NoError(t, err)
6670

6771
err = wan.AddNet(leftDelay)
@@ -82,10 +86,14 @@ func createVirtualNetwork() func(*testing.T) *virtualNetwork {
8286
})
8387
assert.NoError(t, err)
8488

85-
rightTBF, err := vnet.NewTokenBucketFilter(rightRouter, vnet.TBFRate(1_000_000), vnet.TBFMaxBurst(80_000))
89+
rightTBF, err := vnet.NewTokenBucketFilter(
90+
rightRouter,
91+
vnet.TBFRate(rate),
92+
vnet.TBFMaxBurst(burst),
93+
)
8694
assert.NoError(t, err)
8795

88-
rightDelay, err := vnet.NewDelayFilter(rightTBF, 10*time.Millisecond)
96+
rightDelay, err := vnet.NewDelayFilter(rightTBF, delay)
8997
assert.NoError(t, err)
9098

9199
err = wan.AddNet(rightDelay)

0 commit comments

Comments
 (0)