@@ -398,14 +398,14 @@ func TestWatchRestoreSyncedWatcher(t *testing.T) {
398
398
func TestWatchBatchUnsynced (t * testing.T ) {
399
399
tcs := []struct {
400
400
name string
401
- batches int
401
+ revisions int
402
402
watchBatchMaxRevs int
403
403
eventsPerRevision int
404
404
expectRevisionBatches [][]int64
405
405
}{
406
406
{
407
- name : "3 batches , 4 revs per batch, 1 events per revision" ,
408
- batches : 3 ,
407
+ name : "3 revisions , 4 revs per batch, 1 events per revision" ,
408
+ revisions : 12 ,
409
409
watchBatchMaxRevs : 4 ,
410
410
eventsPerRevision : 1 ,
411
411
expectRevisionBatches : [][]int64 {
@@ -415,8 +415,8 @@ func TestWatchBatchUnsynced(t *testing.T) {
415
415
},
416
416
},
417
417
{
418
- name : "3 batches , 4 revs per batch, 3 events per revision" ,
419
- batches : 3 ,
418
+ name : "3 revisions , 4 revs per batch, 3 events per revision" ,
419
+ revisions : 12 ,
420
420
watchBatchMaxRevs : 4 ,
421
421
eventsPerRevision : 3 ,
422
422
expectRevisionBatches : [][]int64 {
@@ -438,7 +438,7 @@ func TestWatchBatchUnsynced(t *testing.T) {
438
438
watchBatchMaxRevs = tc .watchBatchMaxRevs
439
439
440
440
v := []byte ("foo" )
441
- for i := 0 ; i < watchBatchMaxRevs * tc .batches ; i ++ {
441
+ for i := 0 ; i < tc .revisions ; i ++ {
442
442
txn := s .Write (traceutil .TODO ())
443
443
for j := 0 ; j < tc .eventsPerRevision ; j ++ {
444
444
txn .Put (v , v , lease .NoLease )
@@ -450,11 +450,15 @@ func TestWatchBatchUnsynced(t *testing.T) {
450
450
defer w .Close ()
451
451
452
452
w .Watch (0 , v , nil , 1 )
453
- revisionBatches := make ([][]int64 , tc .batches )
454
- for i := 0 ; i < tc .batches ; i ++ {
453
+ var revisionBatches [][]int64
454
+ eventCount := 0
455
+ for eventCount < tc .revisions * tc .eventsPerRevision {
456
+ var revisions []int64
455
457
for _ , e := range (<- w .Chan ()).Events {
456
- revisionBatches [i ] = append (revisionBatches [i ], e .Kv .ModRevision )
458
+ revisions = append (revisions , e .Kv .ModRevision )
459
+ eventCount ++
457
460
}
461
+ revisionBatches = append (revisionBatches , revisions )
458
462
}
459
463
assert .Equal (t , tc .expectRevisionBatches , revisionBatches )
460
464
0 commit comments