integration: fix TestV3WatchFutureRevision

Fix https://github.com/coreos/etcd/issues/4730.

Previously we put keys async and there might be a race when
the watch triggers before the put receives the response. When that
happens, put might fails to get the response since we shutdown the server
when watch triggers.
This commit is contained in:
Xiang Li 2016-03-09 09:55:49 -08:00
parent 86e43b4173
commit 39d307572e

View File

@ -319,8 +319,6 @@ func TestV3WatchFutureRevision(t *testing.T) {
t.Fatal("create = %v, want %v", cresp.Created, true) t.Fatal("create = %v, want %v", cresp.Created, true)
} }
// asynchronously create keys
go func() {
kvc := toGRPC(clus.RandClient()).KV kvc := toGRPC(clus.RandClient()).KV
for { for {
req := &pb.PutRequest{Key: wkey, Value: []byte("bar")} req := &pb.PutRequest{Key: wkey, Value: []byte("bar")}
@ -329,10 +327,9 @@ func TestV3WatchFutureRevision(t *testing.T) {
t.Fatalf("couldn't put key (%v)", rerr) t.Fatalf("couldn't put key (%v)", rerr)
} }
if resp.Header.Revision == wrev { if resp.Header.Revision == wrev {
return break
} }
} }
}()
// ensure watcher request created a new watcher // ensure watcher request created a new watcher
cresp, err = wStream.Recv() cresp, err = wStream.Recv()