Skip to content

Commit

Permalink
Merge pull request #1201 from hashicorp/f-dyn-server-list
Browse files Browse the repository at this point in the history
Dynamic Server Lists/Client Bootstrapping via consul.
  • Loading branch information
sean- authored Jun 11, 2016
2 parents a3b1eac + 006d1a3 commit 9b6e720
Show file tree
Hide file tree
Showing 70 changed files with 4,146 additions and 1,531 deletions.
33 changes: 0 additions & 33 deletions api/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,39 +124,6 @@ func TestAgent_ForceLeave(t *testing.T) {
// TODO: test force-leave on an existing node
}

func TestAgent_SetServers(t *testing.T) {
c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
c.Client.Enabled = true
c.Server.BootstrapExpect = 0
})
defer s.Stop()
a := c.Agent()

// Attempting to set an empty list errors
err := a.SetServers([]string{})
if err == nil {
t.Fatalf("expected error, got nothing")
}

// Setting a valid list works
err = a.SetServers([]string{"foo", "bar"})
if err != nil {
t.Fatalf("err: %s", err)
}

// Returns the proper list of servers
out, err := a.Servers()
if err != nil {
t.Fatalf("err: %s", err)
}
if n := len(out); n != 2 {
t.Fatalf("expected 2 servers, got: %d", n)
}
if out[0] != "foo:4647" || out[1] != "bar:4647" {
t.Fatalf("bad server list: %v", out)
}
}

func (a *AgentMember) String() string {
return "{Name: " + a.Name + " Region: " + a.Tags["region"] + " DC: " + a.Tags["dc"] + "}"
}
Expand Down
3 changes: 1 addition & 2 deletions api/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestNodes_PrefixList(t *testing.T) {
var err error

// Get the node ID
var nodeID, dc string
var nodeID string
testutil.WaitForResult(func() (bool, error) {
out, _, err := nodes.List(nil)
if err != nil {
Expand All @@ -60,7 +60,6 @@ func TestNodes_PrefixList(t *testing.T) {
return false, fmt.Errorf("expected 1 node, got: %d", n)
}
nodeID = out[0].ID
dc = out[0].Datacenter
return true, nil
}, func(err error) {
t.Fatalf("err: %s", err)
Expand Down
3 changes: 2 additions & 1 deletion client/alloc_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"

"github.com/hashicorp/nomad/client/config"
ctestutil "github.com/hashicorp/nomad/client/testutil"
)

Expand All @@ -25,7 +26,7 @@ func (m *MockAllocStateUpdater) Update(alloc *structs.Allocation) {

func testAllocRunner(restarts bool) (*MockAllocStateUpdater, *AllocRunner) {
logger := testLogger()
conf := DefaultConfig()
conf := config.DefaultConfig()
conf.StateDir = os.TempDir()
conf.AllocDir = os.TempDir()
upd := &MockAllocStateUpdater{}
Expand Down
Loading

0 comments on commit 9b6e720

Please sign in to comment.