integration: use WaitResponse for watch tests

This commit is contained in:
Gyu-Ho Lee
2016-01-17 14:11:30 -08:00
parent 98dfdebf13
commit f9b505ae56

View File

@ -412,20 +412,9 @@ func TestV3WatchFromCurrentRevision(t *testing.T) {
} }
} }
rCh := make(chan *pb.WatchResponse) rok, nr := WaitResponse(wStream, 1*time.Second)
go func() { if !rok {
resp, _ := wStream.Recv() t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
rCh <- resp
}()
select {
case nr := <-rCh:
t.Errorf("#%d: unexpected response is received %+v", i, nr)
case <-time.After(2 * time.Second):
}
wStream.CloseSend()
rv, ok := <-rCh
if rv != nil || !ok {
t.Errorf("#%d: rv, ok got = %v %v, want = nil true", i, rv, ok)
} }
// can't defer because tcp ports will be in use // can't defer because tcp ports will be in use
@ -473,20 +462,9 @@ func TestV3WatchCancel(t *testing.T) {
} }
// watch got canceled, so this should block // watch got canceled, so this should block
rCh := make(chan *pb.WatchResponse) rok, nr := WaitResponse(wStream, 1*time.Second)
go func() { if !rok {
resp, _ := wStream.Recv() t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
rCh <- resp
}()
select {
case nr := <-rCh:
t.Errorf("unexpected response is received %+v", nr)
case <-time.After(2 * time.Second):
}
wStream.CloseSend()
rv, ok := <-rCh
if rv != nil || !ok {
t.Errorf("rv, ok got = %v %v, want = nil true", rv, ok)
} }
clus.Terminate(t) clus.Terminate(t)