From 1993ce72282ec188de8ffd9021e6e96b22679cde Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 11 Sep 2017 12:09:00 +0200 Subject: [PATCH] add drop tests with stochastically dropped packets --- integrationtests/gquic/drop_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/integrationtests/gquic/drop_test.go b/integrationtests/gquic/drop_test.go index 1e0534b8..533edccc 100644 --- a/integrationtests/gquic/drop_test.go +++ b/integrationtests/gquic/drop_test.go @@ -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)