Browse Source

server: remove func barrier

It could be replaced by func watch.
Yicheng Qin 11 years ago
parent
commit
d120962959
1 changed files with 3 additions and 23 deletions
  1. 3 23
      etcd/v2_http_endpoint_test.go

+ 3 - 23
etcd/v2_http_endpoint_test.go

@@ -10,7 +10,6 @@ import (
 	"sort"
 	"sort"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
-	"time"
 
 
 	"github.com/coreos/etcd/config"
 	"github.com/coreos/etcd/config"
 	"github.com/coreos/etcd/store"
 	"github.com/coreos/etcd/store"
@@ -183,6 +182,7 @@ func TestPutAdminConfigEndPoint(t *testing.T) {
 	for i, tt := range tests {
 	for i, tt := range tests {
 		es, hs := buildCluster(3, false)
 		es, hs := buildCluster(3, false)
 		waitCluster(t, es)
 		waitCluster(t, es)
+		index := es[0].p.Index()
 
 
 		r, err := NewTestClient().Put(hs[0].URL+v2adminConfigPrefix, "application/json", bytes.NewBufferString(tt.c))
 		r, err := NewTestClient().Put(hs[0].URL+v2adminConfigPrefix, "application/json", bytes.NewBufferString(tt.c))
 		if err != nil {
 		if err != nil {
@@ -197,14 +197,13 @@ func TestPutAdminConfigEndPoint(t *testing.T) {
 			t.Errorf("#%d: put result = %s, want %s", i, b, wbody)
 			t.Errorf("#%d: put result = %s, want %s", i, b, wbody)
 		}
 		}
 
 
-		barrier(t, 0, es)
-
 		for j := range es {
 		for j := range es {
-			e, err := es[j].p.Get(v2configKVPrefix, false, false)
+			w, err := es[j].p.Watch(v2configKVPrefix, false, false, index)
 			if err != nil {
 			if err != nil {
 				t.Errorf("%v", err)
 				t.Errorf("%v", err)
 				continue
 				continue
 			}
 			}
+			e := <-w.EventChan
 			if g := *e.Node.Value; g != tt.wc {
 			if g := *e.Node.Value; g != tt.wc {
 				t.Errorf("#%d.%d: %s = %s, want %s", i, j, v2configKVPrefix, g, tt.wc)
 				t.Errorf("#%d.%d: %s = %s, want %s", i, j, v2configKVPrefix, g, tt.wc)
 			}
 			}
@@ -318,25 +317,6 @@ func TestGetAdminMachinesEndPoint(t *testing.T) {
 	afterTest(t)
 	afterTest(t)
 }
 }
 
 
-// barrier ensures that all servers have made further progress on applied index
-// compared to the base one.
-func barrier(t *testing.T, base int, es []*Server) {
-	applied := es[base].p.node.Applied()
-	// time used for goroutine scheduling
-	time.Sleep(5 * time.Millisecond)
-	for i, e := range es {
-		for j := 0; ; j++ {
-			if e.p.node.Applied() >= applied {
-				break
-			}
-			time.Sleep(defaultHeartbeat * defaultTickDuration)
-			if j == 2 {
-				t.Fatalf("#%d: applied = %d, want >= %d", i, e.p.node.Applied(), applied)
-			}
-		}
-	}
-}
-
 // int64Slice implements sort interface
 // int64Slice implements sort interface
 type machineSlice []*machineMessage
 type machineSlice []*machineMessage