Skip to content

Commit

Permalink
integration: fix "TestV3WatchMultipleStreams"
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Jun 2, 2018
1 parent 0940d6d commit 530fc6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions integration/v3_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ func testV3WatchMultipleStreams(t *testing.T, startRev int64) {
Kv: &mvccpb.KeyValue{Key: []byte("foo"), Value: []byte("bar"), CreateRevision: 2, ModRevision: 2, Version: 1},
},
}

var idMu sync.Mutex
ids := make(map[int64]struct{})
for i := range streams {
go func(i int) {
defer wg.Done()
Expand All @@ -929,9 +932,12 @@ func testV3WatchMultipleStreams(t *testing.T, startRev int64) {
if err != nil {
t.Fatalf("wStream.Recv error: %v", err)
}
if wresp.WatchId != 0 {
t.Errorf("watchId got = %d, want = 0", wresp.WatchId)
idMu.Lock()
if _, ok := ids[wresp.WatchId]; ok {
t.Fatalf("duplicate watch ID found %d", wresp.WatchId)
}
ids[wresp.WatchId] = struct{}{}
idMu.Unlock()
if !reflect.DeepEqual(wresp.Events, wevents) {
t.Errorf("wresp.Events got = %+v, want = %+v", wresp.Events, wevents)
}
Expand Down

0 comments on commit 530fc6e

Please sign in to comment.