diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2018-08-09 22:15:59 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-09 22:15:59 +0800 |
commit | 45eaef24319897f5b1679c9d1aa7d88702cce905 (patch) | |
tree | 455e68de29b7ca83862a6f94f063a22124bdad74 /cmd/swarm/config_test.go | |
parent | 3bcb501c8fefeec1bc8aac26686460cae86f2ccb (diff) | |
download | go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar.gz go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar.bz2 go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar.lz go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar.xz go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.tar.zst go-tangerine-45eaef24319897f5b1679c9d1aa7d88702cce905.zip |
cmd/swarm: solve rare cases of using the same random port in tests (#17352)
Diffstat (limited to 'cmd/swarm/config_test.go')
-rw-r--r-- | cmd/swarm/config_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/swarm/config_test.go b/cmd/swarm/config_test.go index d5011e3a7..02198f878 100644 --- a/cmd/swarm/config_test.go +++ b/cmd/swarm/config_test.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "os" "os/exec" "testing" @@ -559,3 +560,16 @@ func TestValidateConfig(t *testing.T) { } } } + +func assignTCPPort() (string, error) { + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return "", err + } + l.Close() + _, port, err := net.SplitHostPort(l.Addr().String()) + if err != nil { + return "", err + } + return port, nil +} |