Consul test server fork without porter/rpc.ports

This commit is contained in:
Michael Schurter 2017-10-16 16:58:41 -07:00
parent c01efb0a6d
commit 84f480528a
4 changed files with 39 additions and 21 deletions

View File

@ -150,7 +150,8 @@ deps: ## Install build and development dependencies
go get -u github.com/elazarl/go-bindata-assetfs/...
go get -u github.com/hashicorp/vault
go get -u github.com/a8m/tree/cmd/tree
go get -u github.com/hashicorp/consul/test/porter/cmd/porter
## Unneeded since we use Consul's no-porter branch
##go get -u github.com/hashicorp/consul/test/porter/cmd/porter
.PHONY: check
check: ## Lint the source code

View File

@ -27,7 +27,6 @@ import (
"testing"
"time"
"github.com/hashicorp/consul/test/porter"
"github.com/hashicorp/consul/testutil/retry"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/go-uuid"
@ -48,6 +47,9 @@ type TestPortConfig struct {
SerfLan int `json:"serf_lan,omitempty"`
SerfWan int `json:"serf_wan,omitempty"`
Server int `json:"server,omitempty"`
// Deprecated
RPC int `json:"rpc,omitempty"`
}
// TestAddressConfig contains the bind addresses for various
@ -111,12 +113,8 @@ func defaultServerConfig() *TestServerConfig {
panic(err)
}
ports, err := porter.RandomPorts(6)
if err != nil {
panic(err)
}
return &TestServerConfig{
NodeName: "node-" + nodeID,
NodeName: fmt.Sprintf("node%d", randomPort()),
NodeID: nodeID,
DisableCheckpoint: true,
Performance: &TestPerformanceConfig{
@ -128,17 +126,28 @@ func defaultServerConfig() *TestServerConfig {
Bind: "127.0.0.1",
Addresses: &TestAddressConfig{},
Ports: &TestPortConfig{
DNS: ports[0],
HTTP: ports[1],
HTTPS: ports[2],
SerfLan: ports[3],
SerfWan: ports[4],
Server: ports[5],
DNS: randomPort(),
HTTP: randomPort(),
HTTPS: randomPort(),
SerfLan: randomPort(),
SerfWan: randomPort(),
Server: randomPort(),
//RPC: randomPort(),
},
ReadyTimeout: 10 * time.Second,
}
}
// randomPort asks the kernel for a random port to use.
func randomPort() int {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
panic(err)
}
defer l.Close()
return l.Addr().(*net.TCPAddr).Port
}
// TestService is used to serialize a service definition.
type TestService struct {
ID string `json:",omitempty"`
@ -191,7 +200,15 @@ func NewTestServerConfig(cb ServerConfigCallback) (*TestServer, error) {
// configuring or starting the server, the server will NOT be running when the
// function returns (thus you do not need to stop it).
func NewTestServerConfigT(t *testing.T, cb ServerConfigCallback) (*TestServer, error) {
return newTestServerConfigT(t, cb)
var server *TestServer
retry.Run(t, func(r *retry.R) {
var err error
server, err = newTestServerConfigT(t, cb)
if err != nil {
r.Fatalf("failed starting test server: %v", err)
}
})
return server, nil
}
// newTestServerConfigT is the internal helper for NewTestServerConfigT.

View File

@ -25,13 +25,13 @@ const (
// JoinLAN is used to join local datacenters together.
func (s *TestServer) JoinLAN(t *testing.T, addr string) {
resp := s.put(t, "/v1/agent/join/"+addr, nil)
resp := s.get(t, "/v1/agent/join/"+addr)
defer resp.Body.Close()
}
// JoinWAN is used to join remote datacenters together.
func (s *TestServer) JoinWAN(t *testing.T, addr string) {
resp := s.put(t, "/v1/agent/join/"+addr+"?wan=1", nil)
resp := s.get(t, "/v1/agent/join/"+addr+"?wan=1")
resp.Body.Close()
}

10
vendor/vendor.json vendored
View File

@ -767,16 +767,16 @@
"revisionTime": "2017-10-16T16:22:40Z"
},
{
"checksumSHA1": "srD5fzGnxoAqvR6oIE4JBJ1OuT8=",
"checksumSHA1": "AZh3opzONxPrOi+4Io2+OomdKgM=",
"path": "github.com/hashicorp/consul/testutil",
"revision": "51ea240df8476e02215d53fbfad5838bf0d44d21",
"revisionTime": "2017-10-16T16:22:40Z"
"revision": "745fd38728f28061c9f5bfe323d68ee25f2cd07b",
"revisionTime": "2017-10-16T23:19:35Z"
},
{
"checksumSHA1": "J8TTDc84MvAyXE/FrfgS+xc/b6s=",
"path": "github.com/hashicorp/consul/testutil/retry",
"revision": "51ea240df8476e02215d53fbfad5838bf0d44d21",
"revisionTime": "2017-10-16T16:22:40Z"
"revision": "745fd38728f28061c9f5bfe323d68ee25f2cd07b",
"revisionTime": "2017-10-16T23:19:35Z"
},
{
"path": "github.com/hashicorp/errwrap",