Browse Source

etcd: rename initTestServer -> newUnstartedTestServer

Xiang Li 11 years ago
parent
commit
8e2557697f
3 changed files with 20 additions and 20 deletions
  1. 6 6
      etcd/etcd_functional_test.go
  2. 8 8
      etcd/etcd_start_test.go
  3. 6 6
      etcd/etcd_test.go

+ 6 - 6
etcd/etcd_functional_test.go

@@ -58,7 +58,7 @@ func TestKillLeader(t *testing.T) {
 			c.DataDir = es[lead].cfg.DataDir
 			c.Addr = hs[lead].Listener.Addr().String()
 			id := es[lead].id
-			e, h := initTestServer(c, id, false)
+			e, h := newUnstartedTestServer(c, id, false)
 			err := startServer(t, e)
 			if err != nil {
 				t.Fatalf("#%d.%d: %v", i, j, err)
@@ -100,7 +100,7 @@ func TestKillRandom(t *testing.T) {
 				c.DataDir = es[k].cfg.DataDir
 				c.Addr = hs[k].Listener.Addr().String()
 				id := es[k].id
-				e, h := initTestServer(c, id, false)
+				e, h := newUnstartedTestServer(c, id, false)
 				err := startServer(t, e)
 				if err != nil {
 					t.Fatal(err)
@@ -126,7 +126,7 @@ func TestJoinThroughFollower(t *testing.T) {
 			if i > 0 {
 				c.Peers = []string{hs[i-1].URL}
 			}
-			es[i], hs[i] = initTestServer(c, int64(i), false)
+			es[i], hs[i] = newUnstartedTestServer(c, int64(i), false)
 		}
 
 		go es[0].Run()
@@ -167,7 +167,7 @@ func TestClusterConfigReload(t *testing.T) {
 			c.DataDir = es[k].cfg.DataDir
 			c.Addr = hs[k].Listener.Addr().String()
 			id := es[k].id
-			e, h := initTestServer(c, id, false)
+			e, h := newUnstartedTestServer(c, id, false)
 			err := startServer(t, e)
 			if err != nil {
 				t.Fatal(err)
@@ -207,7 +207,7 @@ func TestMultiNodeKillOne(t *testing.T) {
 			c.DataDir = es[idx].cfg.DataDir
 			c.Addr = hs[idx].Listener.Addr().String()
 			id := es[idx].id
-			e, h := initTestServer(c, id, false)
+			e, h := newUnstartedTestServer(c, id, false)
 			err := startServer(t, e)
 			if err != nil {
 				t.Fatalf("#%d.%d: %v", i, j, err)
@@ -249,7 +249,7 @@ func TestMultiNodeKillAllAndRecovery(t *testing.T) {
 			c.DataDir = es[k].cfg.DataDir
 			c.Addr = hs[k].Listener.Addr().String()
 			id := es[k].id
-			e, h := initTestServer(c, id, false)
+			e, h := newUnstartedTestServer(c, id, false)
 			err := startServer(t, e)
 			if err != nil {
 				t.Fatalf("#%d.%d: %v", i, k, err)

+ 8 - 8
etcd/etcd_start_test.go

@@ -57,7 +57,7 @@ func TestBadDiscoveryService(t *testing.T) {
 
 	c := conf.New()
 	c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
-	e, h := initTestServer(c, bootstrapId, false)
+	e, h := newUnstartedTestServer(c, bootstrapId, false)
 	err := startServer(t, e)
 	w := `discovery service error`
 	if err == nil || !strings.HasPrefix(err.Error(), w) {
@@ -85,7 +85,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
 	c := conf.New()
 	c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
 	c.Peers = []string{hs[0].URL}
-	e, h := initTestServer(c, bootstrapId, false)
+	e, h := newUnstartedTestServer(c, bootstrapId, false)
 	err := startServer(t, e)
 	w := `discovery service error`
 	if err == nil || !strings.HasPrefix(err.Error(), w) {
@@ -101,7 +101,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
 func TestBootstrapByEmptyPeers(t *testing.T) {
 	c := conf.New()
 	id := genId()
-	e, h := initTestServer(c, id, false)
+	e, h := newUnstartedTestServer(c, id, false)
 	err := startServer(t, e)
 
 	if err != nil {
@@ -115,12 +115,12 @@ func TestBootstrapByEmptyPeers(t *testing.T) {
 }
 
 func TestBootstrapByDiscoveryService(t *testing.T) {
-	de, dh := initTestServer(conf.New(), genId(), false)
+	de, dh := newUnstartedTestServer(conf.New(), genId(), false)
 	err := startServer(t, de)
 
 	c := conf.New()
 	c.Discovery = dh.URL + "/v2/keys/_etcd/registry/1"
-	e, h := initTestServer(c, bootstrapId, false)
+	e, h := newUnstartedTestServer(c, bootstrapId, false)
 	err = startServer(t, e)
 	if err != nil {
 		t.Fatalf("build server err = %v, want nil", err)
@@ -137,7 +137,7 @@ func TestRunByAdvisedPeers(t *testing.T) {
 
 	c := conf.New()
 	c.Peers = []string{hs[0].URL}
-	e, h := initTestServer(c, bootstrapId, false)
+	e, h := newUnstartedTestServer(c, bootstrapId, false)
 	err := startServer(t, e)
 	if err != nil {
 		t.Fatalf("build server err = %v, want nil", err)
@@ -153,7 +153,7 @@ func TestRunByAdvisedPeers(t *testing.T) {
 }
 
 func TestRunByDiscoveryService(t *testing.T) {
-	de, dh := initTestServer(conf.New(), genId(), false)
+	de, dh := newUnstartedTestServer(conf.New(), genId(), false)
 	err := startServer(t, de)
 
 	tc := NewTestClient()
@@ -174,7 +174,7 @@ func TestRunByDiscoveryService(t *testing.T) {
 
 	c := conf.New()
 	c.Discovery = dh.URL + "/v2/keys/_etcd/registry/1"
-	e, h := initTestServer(c, bootstrapId, false)
+	e, h := newUnstartedTestServer(c, bootstrapId, false)
 	err = startServer(t, e)
 	if err != nil {
 		t.Fatalf("build server err = %v, want nil", err)

+ 6 - 6
etcd/etcd_test.go

@@ -94,7 +94,7 @@ func TestAdd(t *testing.T) {
 			if i > 0 {
 				c.Peers = []string{hs[0].URL}
 			}
-			es[i], hs[i] = initTestServer(c, int64(i), false)
+			es[i], hs[i] = newUnstartedTestServer(c, int64(i), false)
 		}
 
 		go es[0].Run()
@@ -322,7 +322,7 @@ func TestSingleNodeRecovery(t *testing.T) {
 	}
 	c := conf.New()
 	c.DataDir = dataDir
-	e, h := initTestServer(c, id, false)
+	e, h := newUnstartedTestServer(c, id, false)
 	startServer(t, e)
 	key := "/foo"
 
@@ -351,7 +351,7 @@ func TestSingleNodeRecovery(t *testing.T) {
 
 	c = conf.New()
 	c.DataDir = dataDir
-	e, h = initTestServer(c, id, false)
+	e, h = newUnstartedTestServer(c, id, false)
 	startServer(t, e)
 
 	waitLeader([]*Server{e})
@@ -399,7 +399,7 @@ func TestRestoreSnapshotFromLeader(t *testing.T) {
 	// create one to join the cluster
 	c := conf.New()
 	c.Peers = []string{hs[0].URL}
-	e, h := initTestServer(c, 1, false)
+	e, h := newUnstartedTestServer(c, 1, false)
 	go e.Run()
 	waitMode(participantMode, e)
 
@@ -451,7 +451,7 @@ func buildCluster(number int, tls bool) ([]*Server, []*httptest.Server) {
 		if seed != "" {
 			c.Peers = []string{seed}
 		}
-		es[i], hs[i] = initTestServer(c, int64(i), tls)
+		es[i], hs[i] = newUnstartedTestServer(c, int64(i), tls)
 
 		if i == bootstrapper {
 			seed = hs[i].URL
@@ -470,7 +470,7 @@ func buildCluster(number int, tls bool) ([]*Server, []*httptest.Server) {
 	return es, hs
 }
 
-func initTestServer(c *conf.Config, id int64, tls bool) (e *Server, h *httptest.Server) {
+func newUnstartedTestServer(c *conf.Config, id int64, tls bool) (e *Server, h *httptest.Server) {
 	if c.DataDir == "" {
 		n, err := ioutil.TempDir(os.TempDir(), "etcd")
 		if err != nil {