Skip to content

Commit

Permalink
fix: Adjust timing so test doesn't fail intermittently
Browse files Browse the repository at this point in the history
This is for TestBatchInTimeAndCountMode_TimeElapsed test

closes #548

Signed-off-by: lenny <[email protected]>
  • Loading branch information
lenny committed Oct 16, 2020
1 parent c65eb72 commit 1dbe117
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/transforms/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@ func TestBatchInTimeAndCountMode_TimeElapsed(t *testing.T) {

go func() {
go func() {
time.Sleep(time.Second * 2)
time.Sleep(time.Second * 1)
wgFirst.Done()
}()

// Key to this test is this call occurs first and will be blocked until
// batch time interval has elapsed. In the mean time the other go func have to execute
// before the batch time interval has elapsed, so the sleep above has to be less than the
// batch time interval.
continuePipeline1, result := bs.Batch(context, []byte(dataToBatch[0]))
assert.True(t, continuePipeline1)
assert.Equal(t, 3, len(result.([][]byte)))
assert.Len(t, bs.batchData.all(), 0, "Should have 0 records")
if continuePipeline1 {
assert.Equal(t, 3, len(result.([][]byte)))
assert.Len(t, bs.batchData.all(), 0, "Should have 0 records")
}
wgAll.Done()
}()
go func() {
Expand Down

0 comments on commit 1dbe117

Please sign in to comment.