5c5f21088c
This should cut down on test flakiness. Problems handled: - If you had enough parallel test cases running, the former circular approach to handling the port block could hand out the same port to multiple cases before they each had a chance to bind them, leading to one of the two tests to fail. - The freeport library would allocate out of the ephemeral port range. This has been corrected for Linux (which should cover CI). - The library now waits until a formerly-in-use port is verified to be free before putting it back into circulation.
19 lines
332 B
Go
19 lines
332 B
Go
//+build linux
|
|
|
|
package freeport
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGetEphemeralPortRange(t *testing.T) {
|
|
min, max, err := getEphemeralPortRange()
|
|
if err != nil {
|
|
t.Fatalf("err: %v", err)
|
|
}
|
|
if min <= 0 || max <= 0 || min > max {
|
|
t.Fatalf("unexpected values: min=%d, max=%d", min, max)
|
|
}
|
|
t.Logf("min=%d, max=%d", min, max)
|
|
}
|