mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Consul test server fork without porter/rpc.ports
This commit is contained in:
43
vendor/github.com/hashicorp/consul/testutil/server.go
generated
vendored
43
vendor/github.com/hashicorp/consul/testutil/server.go
generated
vendored
@@ -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.
|
||||
|
||||
4
vendor/github.com/hashicorp/consul/testutil/server_methods.go
generated
vendored
4
vendor/github.com/hashicorp/consul/testutil/server_methods.go
generated
vendored
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user