mirror of https://github.com/status-im/consul.git
Makes port selection atomic in unit tests.
This commit is contained in:
parent
d5191741a1
commit
4d05d692fc
|
@ -7,18 +7,17 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/testutil"
|
"github.com/hashicorp/consul/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var nextPort = 15000
|
var nextPort int32 = 15000
|
||||||
|
|
||||||
func getPort() int {
|
func getPort() int {
|
||||||
p := nextPort
|
return int(atomic.AddInt32(&nextPort, 1))
|
||||||
nextPort++
|
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func tmpDir(t *testing.T) string {
|
func tmpDir(t *testing.T) string {
|
||||||
|
|
Loading…
Reference in New Issue