Makes port selection atomic in unit tests.

This commit is contained in:
James Phillips 2016-09-01 01:01:28 -07:00
parent d5191741a1
commit 4d05d692fc
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 3 additions and 4 deletions

View File

@ -7,18 +7,17 @@ import (
"net"
"os"
"strings"
"sync/atomic"
"testing"
"time"
"github.com/hashicorp/consul/testutil"
)
var nextPort = 15000
var nextPort int32 = 15000
func getPort() int {
p := nextPort
nextPort++
return p
return int(atomic.AddInt32(&nextPort, 1))
}
func tmpDir(t *testing.T) string {