Merge pull request #2128 from hashicorp/b-stable-test-portnumbers

Use stable, monotonically increasing port numbers for tests
This commit is contained in:
Sean Chittenden 2016-06-20 22:54:50 -07:00 committed by GitHub
commit 755c3647c8
1 changed files with 22 additions and 8 deletions

View File

@ -19,10 +19,24 @@ import (
"github.com/hashicorp/consul/testutil"
)
var offset uint64
const (
basePortNumber = 10000
portOffsetDNS = iota
portOffsetHTTP
portOffsetRPC
portOffsetSerfLan
portOffsetSerfWan
portOffsetServer
// Must be last in list
numPortsPerIndex
)
var offset uint64 = basePortNumber
func nextConfig() *Config {
idx := int(atomic.AddUint64(&offset, 1))
idx := int(atomic.AddUint64(&offset, numPortsPerIndex))
conf := DefaultConfig()
conf.Version = "a.b"
@ -32,12 +46,12 @@ func nextConfig() *Config {
conf.Datacenter = "dc1"
conf.NodeName = fmt.Sprintf("Node %d", idx)
conf.BindAddr = "127.0.0.1"
conf.Ports.DNS = 19000 + idx
conf.Ports.HTTP = 18800 + idx
conf.Ports.RPC = 18600 + idx
conf.Ports.SerfLan = 18200 + idx
conf.Ports.SerfWan = 18400 + idx
conf.Ports.Server = 18000 + idx
conf.Ports.DNS = basePortNumber + idx + portOffsetDNS
conf.Ports.HTTP = basePortNumber + idx + portOffsetHTTP
conf.Ports.RPC = basePortNumber + idx + portOffsetRPC
conf.Ports.SerfLan = basePortNumber + idx + portOffsetSerfLan
conf.Ports.SerfWan = basePortNumber + idx + portOffsetSerfWan
conf.Ports.Server = basePortNumber + idx + portOffsetServer
conf.Server = true
conf.ACLDatacenter = "dc1"
conf.ACLMasterToken = "root"