|
|
@ -31,6 +31,9 @@ func Test_NewBootstrapper(t *testing.T) {
|
|
|
|
if bs == nil {
|
|
|
|
if bs == nil {
|
|
|
|
t.Fatalf("failed to create a simple Bootstrapper")
|
|
|
|
t.Fatalf("failed to create a simple Bootstrapper")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootUnknown, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootDoneImmediately(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootDoneImmediately(t *testing.T) {
|
|
|
@ -46,6 +49,9 @@ func Test_BootstrapperBootDoneImmediately(t *testing.T) {
|
|
|
|
if err := bs.Boot("node1", "192.168.1.1:1234", done, 10*time.Second); err != nil {
|
|
|
|
if err := bs.Boot("node1", "192.168.1.1:1234", done, 10*time.Second); err != nil {
|
|
|
|
t.Fatalf("failed to boot: %s", err)
|
|
|
|
t.Fatalf("failed to boot: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootDone, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootTimeout(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootTimeout(t *testing.T) {
|
|
|
@ -66,6 +72,35 @@ func Test_BootstrapperBootTimeout(t *testing.T) {
|
|
|
|
if !errors.Is(err, ErrBootTimeout) {
|
|
|
|
if !errors.Is(err, ErrBootTimeout) {
|
|
|
|
t.Fatalf("wrong error returned")
|
|
|
|
t.Fatalf("wrong error returned")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootTimeout, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootSingleJoin(t *testing.T) {
|
|
|
|
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
if r.URL.Path != "/join" {
|
|
|
|
|
|
|
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
done := func() bool {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p := NewAddressProviderString([]string{ts.URL})
|
|
|
|
|
|
|
|
bs := NewBootstrapper(p, nil)
|
|
|
|
|
|
|
|
bs.Interval = time.Second
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := bs.Boot("node1", "192.168.1.1:1234", done, 60*time.Second)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("failed to boot: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootJoin, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootSingleNotify(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootSingleNotify(t *testing.T) {
|
|
|
@ -115,6 +150,10 @@ func Test_BootstrapperBootSingleNotify(t *testing.T) {
|
|
|
|
if got, exp := body["addr"], "192.168.1.1:1234"; got != exp {
|
|
|
|
if got, exp := body["addr"], "192.168.1.1:1234"; got != exp {
|
|
|
|
t.Fatalf("wrong address supplied, exp %s, got %s", exp, got)
|
|
|
|
t.Fatalf("wrong address supplied, exp %s, got %s", exp, got)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if exp, got := BootDone, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootSingleNotifyHTTPS(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootSingleNotifyHTTPS(t *testing.T) {
|
|
|
@ -175,6 +214,10 @@ func Test_BootstrapperBootSingleNotifyHTTPS(t *testing.T) {
|
|
|
|
if got, exp := body["addr"], "192.168.1.1:1234"; got != exp {
|
|
|
|
if got, exp := body["addr"], "192.168.1.1:1234"; got != exp {
|
|
|
|
t.Fatalf("wrong address supplied, exp %s, got %s", exp, got)
|
|
|
|
t.Fatalf("wrong address supplied, exp %s, got %s", exp, got)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if exp, got := BootDone, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootSingleNotifyAuth(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootSingleNotifyAuth(t *testing.T) {
|
|
|
@ -214,6 +257,9 @@ func Test_BootstrapperBootSingleNotifyAuth(t *testing.T) {
|
|
|
|
if tsNotified != true {
|
|
|
|
if tsNotified != true {
|
|
|
|
t.Fatalf("notify target not contacted")
|
|
|
|
t.Fatalf("notify target not contacted")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootDone, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func Test_BootstrapperBootMultiNotify(t *testing.T) {
|
|
|
|
func Test_BootstrapperBootMultiNotify(t *testing.T) {
|
|
|
@ -257,8 +303,10 @@ func Test_BootstrapperBootMultiNotify(t *testing.T) {
|
|
|
|
if ts1Join != true || ts2Join != true {
|
|
|
|
if ts1Join != true || ts2Join != true {
|
|
|
|
t.Fatalf("all join targets not contacted")
|
|
|
|
t.Fatalf("all join targets not contacted")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ts1Notified != true || ts2Notified != true {
|
|
|
|
if ts1Notified != true || ts2Notified != true {
|
|
|
|
t.Fatalf("all notify targets not contacted")
|
|
|
|
t.Fatalf("all notify targets not contacted")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if exp, got := BootDone, bs.Status(); exp != got {
|
|
|
|
|
|
|
|
t.Fatalf("wrong status, exp %s, got %s", exp, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|