|
|
@ -2,12 +2,12 @@ package command
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/testutil"
|
|
|
|
"github.com/hashicorp/serf/serf"
|
|
|
|
"github.com/hashicorp/serf/serf"
|
|
|
|
"github.com/hashicorp/serf/testutil"
|
|
|
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestForceLeaveCommand_implements(t *testing.T) {
|
|
|
|
func TestForceLeaveCommand_implements(t *testing.T) {
|
|
|
@ -26,13 +26,9 @@ func TestForceLeaveCommandRun(t *testing.T) {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
testutil.Yield()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Forcibly shutdown a2 so that it appears "failed" in a1
|
|
|
|
// Forcibly shutdown a2 so that it appears "failed" in a1
|
|
|
|
a2.Shutdown()
|
|
|
|
a2.Shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
c := &ForceLeaveCommand{Ui: ui}
|
|
|
|
c := &ForceLeaveCommand{Ui: ui}
|
|
|
|
args := []string{
|
|
|
|
args := []string{
|
|
|
@ -50,9 +46,14 @@ func TestForceLeaveCommandRun(t *testing.T) {
|
|
|
|
t.Fatalf("should have 2 members: %#v", m)
|
|
|
|
t.Fatalf("should have 2 members: %#v", m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if m[1].Status != serf.StatusLeft {
|
|
|
|
testutil.WaitForResult(func() (bool, error) {
|
|
|
|
t.Fatalf("should be left: %#v", m[1])
|
|
|
|
m = a1.agent.LANMembers()
|
|
|
|
}
|
|
|
|
success := m[1].Status == serf.StatusLeft
|
|
|
|
|
|
|
|
err := errors.New(m[1].Status.String())
|
|
|
|
|
|
|
|
return success, err
|
|
|
|
|
|
|
|
}, func(err error) {
|
|
|
|
|
|
|
|
t.Fatalf("member status is %v, not left", err)
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestForceLeaveCommandRun_noAddrs(t *testing.T) {
|
|
|
|
func TestForceLeaveCommandRun_noAddrs(t *testing.T) {
|
|
|
|