From 6acc152f0c7c4e9bf7dfdd5599aaeb34bfe48fd6 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Wed, 17 Dec 2014 19:21:06 -0800 Subject: [PATCH] backpressure: explanation + more rounds --- net/backpressure/backpressure_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/net/backpressure/backpressure_test.go b/net/backpressure/backpressure_test.go index 7a92101cd..c7bea5626 100644 --- a/net/backpressure/backpressure_test.go +++ b/net/backpressure/backpressure_test.go @@ -354,6 +354,7 @@ func TestStBackpressureStreamWrite(t *testing.T) { stop <- struct{}{} contTime := time.Now().Sub(contStart) + // now compare! continuous should've been faster AND larger if roundsTime < contTime { t.Error("continuous should have been faster") } @@ -362,10 +363,17 @@ func TestStBackpressureStreamWrite(t *testing.T) { t.Error("continuous should have been larger, too!") } - <-time.After(300 * time.Millisecond) - writeStats() - testSenderWrote(0) - testSenderWrote(0) + // and a couple rounds more for good measure ;) + for i := 0; i < 3; i++ { + // let the sender fill its buffers, it will stop sending. + <-time.After(300 * time.Millisecond) + b, _ := writeStats() + testSenderWrote(0) + testSenderWrote(0) + + // drain it all, wait again + receive(s, b) + } // this doesn't work :(: // // now for the sugar on top: let's tear down the receiver. it should