diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 2901d67bc2..a00d5cc117 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -2,15 +2,16 @@ package agent import ( "fmt" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" - "github.com/hashicorp/consul/testutil" "io" "io/ioutil" "os" "sync/atomic" "testing" "time" + + "github.com/hashicorp/consul/consul" + "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/testutil" ) var offset uint64 @@ -24,12 +25,12 @@ func nextConfig() *Config { conf.Datacenter = "dc1" conf.NodeName = fmt.Sprintf("Node %d", idx) conf.BindAddr = "127.0.0.1" - conf.Ports.DNS = 18600 + idx - conf.Ports.HTTP = 18500 + idx - conf.Ports.RPC = 18400 + idx + conf.Ports.DNS = 19000 + idx + conf.Ports.HTTP = 18800 + idx + conf.Ports.RPC = 18600 + idx conf.Ports.SerfLan = 18200 + idx - conf.Ports.SerfWan = 18300 + idx - conf.Ports.Server = 18100 + idx + conf.Ports.SerfWan = 18400 + idx + conf.Ports.Server = 18000 + idx conf.Server = true conf.ACLDatacenter = "dc1" conf.ACLMasterToken = "root" diff --git a/command/agent/http.go b/command/agent/http.go index e5804ae1dd..a7a3c4d587 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -81,9 +81,7 @@ func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPS // Start the server go http.Serve(list, mux) - - servers := make([]*HTTPServer, 1) - servers[0] = srv + servers = append(servers, srv) } if config.Ports.HTTP > 0 { @@ -116,14 +114,7 @@ func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPS // Start the server go http.Serve(list, mux) - - if servers != nil { - // we already have the https server in servers, append - servers = append(servers, srv) - } else { - servers := make([]*HTTPServer, 1) - servers[0] = srv - } + servers = append(servers, srv) } return servers, nil diff --git a/command/agent/http_test.go b/command/agent/http_test.go index c52b822d76..d38b644ac5 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -25,16 +25,12 @@ func makeHTTPServer(t *testing.T) (string, *HTTPServer) { if err := os.Mkdir(uiDir, 755); err != nil { t.Fatalf("err: %v", err) } - conf.Addresses.HTTP = "" - conf.Ports.HTTP = agent.config.Ports.HTTP - conf.Ports.HTTPS = -1 - addr, _ := agent.config.ClientListener("", agent.config.Ports.HTTP) servers, err := NewHTTPServers(agent, conf, agent.logOutput) if err != nil { t.Fatalf("err: %v", err) } - if servers == nil || len(servers) == 0 { - t.Fatalf(fmt.Sprintf("Could not create HTTP server to listen on: %s", addr.String())) + if len(servers) == 0 { + t.Fatalf(fmt.Sprintf("Failed to make HTTP server")) } return dir, servers[0] }