mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-05 23:56:50 +08:00
🐞 Eliminate flaky test failures
Integration tests would fail approximately 11% of the time (4/35) when run in parallel (on my 8-core MacBook Air). The fix was to lengthen the amount of time (1ms → 2ms) a port was held to make sure it was really, truly free. After change, the tests ran 32 times without a failure. Fixes, during `ginkgo -r -p --until-it-fails .` ``` I couldn't bind to any IPs on port 1974, so I'm exiting ... Waiting for: Ready to answer queries In [JustBeforeEach] at: /Volumes/workspace/sslip.io/src/sslip.io-dns-server/integration_flags_test.go:28 @ 11/11/22 10:38:02.045 ```
This commit is contained in:
@@ -486,7 +486,7 @@ func isPortFree(port int) bool {
|
||||
// we must Sleep() in order to avoid a race condition when tests
|
||||
// are run in parallel (`ginkgo -p`) and the `ListenUDP()` and `Close()`
|
||||
// we sleep for a millisecond because the port is randomized based on the millisecond.
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
time.Sleep(2 * time.Millisecond)
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
log.Printf("I couldn't close port %d", port)
|
||||
|
Reference in New Issue
Block a user