|
|
|
@ -2,7 +2,9 @@ package master_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@ -19,6 +21,10 @@ func TestNewServiceWithEtcd(t *testing.T) {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
cfg := embed.NewConfig()
|
|
|
|
|
lpurl, _ := url.Parse("http://localhost:0")
|
|
|
|
|
lcurl, _ := url.Parse("http://localhost:0")
|
|
|
|
|
cfg.LPUrls = []url.URL{*lpurl}
|
|
|
|
|
cfg.LCUrls = []url.URL{*lcurl}
|
|
|
|
|
cfg.Dir = etcdDir
|
|
|
|
|
e, err := embed.StartEtcd(cfg)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -30,15 +36,13 @@ func TestNewServiceWithEtcd(t *testing.T) {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
select {
|
|
|
|
|
case <-e.Server.ReadyNotify():
|
|
|
|
|
t.Log("Server is ready!")
|
|
|
|
|
case <-time.After(60 * time.Second):
|
|
|
|
|
e.Server.Stop() // trigger a shutdown
|
|
|
|
|
t.Fatal("Server took too long to start!")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ep := []string{"127.0.0.1:2379"}
|
|
|
|
|
<-e.Server.ReadyNotify()
|
|
|
|
|
|
|
|
|
|
port := strings.Split(e.Clients[0].Addr().String(), ":")[1]
|
|
|
|
|
endpoint := "127.0.0.1:" + port
|
|
|
|
|
|
|
|
|
|
ep := []string{endpoint}
|
|
|
|
|
masterAddr := "127.0.0.1:3306"
|
|
|
|
|
store, err := master.NewEtcdClient(ep, masterAddr, master.DefaultLockPath, master.DefaultAddrPath, master.DefaultStatePath, 30)
|
|
|
|
|
if err != nil {
|
|
|
|
|