Skip to content

Commit 8ab0b7d

Browse files
committed
Use number of revisions instead of batches to configure TestWatchBatchUnsynced
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent eb34c85 commit 8ab0b7d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

server/storage/mvcc/watchable_store_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,14 @@ func TestWatchRestoreSyncedWatcher(t *testing.T) {
398398
func TestWatchBatchUnsynced(t *testing.T) {
399399
tcs := []struct {
400400
name string
401-
batches int
401+
revisions int
402402
watchBatchMaxRevs int
403403
eventsPerRevision int
404404
expectRevisionBatches [][]int64
405405
}{
406406
{
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,
409409
watchBatchMaxRevs: 4,
410410
eventsPerRevision: 1,
411411
expectRevisionBatches: [][]int64{
@@ -415,8 +415,8 @@ func TestWatchBatchUnsynced(t *testing.T) {
415415
},
416416
},
417417
{
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,
420420
watchBatchMaxRevs: 4,
421421
eventsPerRevision: 3,
422422
expectRevisionBatches: [][]int64{
@@ -438,7 +438,7 @@ func TestWatchBatchUnsynced(t *testing.T) {
438438
watchBatchMaxRevs = tc.watchBatchMaxRevs
439439

440440
v := []byte("foo")
441-
for i := 0; i < watchBatchMaxRevs*tc.batches; i++ {
441+
for i := 0; i < tc.revisions; i++ {
442442
txn := s.Write(traceutil.TODO())
443443
for j := 0; j < tc.eventsPerRevision; j++ {
444444
txn.Put(v, v, lease.NoLease)
@@ -450,11 +450,15 @@ func TestWatchBatchUnsynced(t *testing.T) {
450450
defer w.Close()
451451

452452
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
455457
for _, e := range (<-w.Chan()).Events {
456-
revisionBatches[i] = append(revisionBatches[i], e.Kv.ModRevision)
458+
revisions = append(revisions, e.Kv.ModRevision)
459+
eventCount++
457460
}
461+
revisionBatches = append(revisionBatches, revisions)
458462
}
459463
assert.Equal(t, tc.expectRevisionBatches, revisionBatches)
460464

0 commit comments

Comments
 (0)