ncw/swift

Fix unreliable test

ncw opened this issue · 5 comments

ncw commented

This keeps failing :-(

$ go test
Waiting for server to start .. Started
--- FAIL: TestWatchdogReaderOnSlowNetwork (1.23s)
	watchdog_reader_test.go:53: Timer should not have fired
FAIL
exit status 1
zhsj commented

Hi,

It's also reported at https://bugs.debian.org/923804, and

failure rate is so high (40%)

Could you help looking at this issue recently? It's a blocking issue in Debian to keep this library and many reverse dependencies :(

I tried reading the code, but I'm lost with the different time durations in this test.

Thanks

ncw commented

I can't make this happen locally and it hasn't happened in the travis builds for ages :-(

Can you see if this fixes it?

diff --git a/watchdog_reader_test.go b/watchdog_reader_test.go
index 8e8f013..08dabff 100644
--- a/watchdog_reader_test.go
+++ b/watchdog_reader_test.go
@@ -98,7 +98,7 @@ func TestWatchdogReaderOnSlowNetwork(t *testing.T) {
 		delayPerByte: 200 * time.Millisecond / time.Duration(len(byteString)),
 	}
 
-	timer, firedChan := setupTimer(10 * time.Millisecond)
+	timer, firedChan := setupTimer(100 * time.Millisecond)
 	wr := newWatchdogReader(reader, 190*time.Millisecond, timer)
 
 	//use io.ReadFull instead of ioutil.ReadAll here because ReadAll already does
zhsj commented

@ncw thanks for the patched. I've built 100 times, and 0 failure with this patch, compared to 42/100 failures for the origin one.

ncw commented

I've committed that patch and tagged a release with it in v1.0.45

Thank you for testing :-)

ncw commented

The commit is 3623852 - this didn't get autolinked for some reason...