add drop tests with stochastically dropped packets

This commit is contained in:
Marten Seemann
2017-09-11 12:09:00 +02:00
parent 142abb08b3
commit 1993ce7228

View File

@@ -3,6 +3,7 @@ package gquic_test
import (
"bytes"
"fmt"
mrand "math/rand"
"os/exec"
"strconv"
@@ -56,6 +57,13 @@ var _ = Describe("Drop tests", func() {
return (p % interval) < dropInARow
}
stochasticDropper := func(p protocol.PacketNumber, freq int) bool {
if p <= 10 { // don't interfere with the crypto handshake
return false
}
return mrand.Int63n(int64(freq)) == 0
}
for _, v := range protocol.SupportedVersions {
version := v
@@ -69,6 +77,12 @@ var _ = Describe("Drop tests", func() {
}, version)
})
It(fmt.Sprintf("downloads a file when 1/5th of all packet are dropped randomly in %s direction", d), func() {
runDropTest(func(d quicproxy.Direction, p protocol.PacketNumber) bool {
return d.Is(direction) && stochasticDropper(p, 5)
}, version)
})
It(fmt.Sprintf("downloads a file when 10 packets every 100 packet are dropped in %s direction", d), func() {
runDropTest(func(d quicproxy.Direction, p uint64) bool {
return d.Is(direction) && deterministicDropper(p, 100, 10)