Skip to content

Commit

Permalink
command: Fixing more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Apr 11, 2014
1 parent 657da8e commit 6fd3f81
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion command/force_leave_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestForceLeaveCommandRun(t *testing.T) {
defer a1.Shutdown()
defer a2.Shutdown()

addr := fmt.Sprintf("127.0.0.1:%d", a2.config.SerfLanPort)
addr := fmt.Sprintf("127.0.0.1:%d", a2.config.Ports.SerfLan)
_, err := a1.agent.JoinLAN([]string{addr})
if err != nil {
t.Fatalf("err: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions command/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestJoinCommandRun(t *testing.T) {
c := &JoinCommand{Ui: ui}
args := []string{
"-rpc-addr=" + a1.addr,
fmt.Sprintf("127.0.0.1:%d", a2.config.SerfLanPort),
fmt.Sprintf("127.0.0.1:%d", a2.config.Ports.SerfLan),
}

code := c.Run(args)
Expand All @@ -45,7 +45,7 @@ func TestJoinCommandRun_wan(t *testing.T) {
args := []string{
"-rpc-addr=" + a1.addr,
"-wan",
fmt.Sprintf("127.0.0.1:%d", a2.config.SerfWanPort),
fmt.Sprintf("127.0.0.1:%d", a2.config.Ports.SerfWan),
}

code := c.Run(args)
Expand Down
2 changes: 1 addition & 1 deletion command/members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestMembersCommandRun_WAN(t *testing.T) {
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
}

if !strings.Contains(ui.OutputWriter.String(), fmt.Sprintf("%d", a1.config.SerfWanPort)) {
if !strings.Contains(ui.OutputWriter.String(), fmt.Sprintf("%d", a1.config.Ports.SerfWan)) {
t.Fatalf("bad: %#v", ui.OutputWriter.String())
}
}
Expand Down
15 changes: 8 additions & 7 deletions command/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ func testAgent(t *testing.T) *agentWrapper {
}

func nextConfig() *agent.Config {
idx := atomic.AddUint64(&offset, 1)
idx := int(atomic.AddUint64(&offset, 1))
conf := agent.DefaultConfig()

conf.Bootstrap = true
conf.Datacenter = "dc1"
conf.NodeName = fmt.Sprintf("Node %d", idx)
conf.HTTPAddr = fmt.Sprintf("127.0.0.1:%d", 10000+10*idx)
conf.RPCAddr = fmt.Sprintf("127.0.0.1:%d", 10100+10*idx)
conf.SerfBindAddr = "127.0.0.1"
conf.SerfLanPort = int(10201 + 10*idx)
conf.SerfWanPort = int(10202 + 10*idx)
conf.BindAddr = "127.0.0.1"
conf.Server = true
conf.ServerAddr = fmt.Sprintf("127.0.0.1:%d", 10300+10*idx)

conf.Ports.HTTP = 10000 + 10*idx
conf.Ports.RPC = 10100 + 10*idx
conf.Ports.SerfLan = 10201 + 10*idx
conf.Ports.SerfWan = 10202 + 10*idx
conf.Ports.Server = 10300 + 10*idx

cons := consul.DefaultConfig()
conf.ConsulConfig = cons
Expand Down

1 comment on commit 6fd3f81

@mitchellh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.