Skip to content

Commit

Permalink
Recheck log message in TestBatchProcessor (#5386)
Browse files Browse the repository at this point in the history
Fix #5384

On single-threaded, or in general slow, systems where the log message
may not be emitted, use assert.Everything to allow multiple lookups for
the expected log message.

Co-authored-by: Sam Xie <sam@samxie.me>
  • Loading branch information
MrAlias and XSAM committed May 21, 2024
1 parent 5661ff0 commit 281aeb5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sdk/log/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
stdlog "log"
"slices"
"strconv"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -444,9 +445,10 @@ func TestBatchProcessor(t *testing.T) {
return n > 0
}, 2*time.Second, time.Microsecond, "blocked export not attempted")

got := buf.String()
want := `"level"=1 "msg"="dropped log records" "dropped"=1`
assert.Contains(t, got, want)
wantMsg := `"level"=1 "msg"="dropped log records" "dropped"=1`
assert.Eventually(t, func() bool {
return strings.Contains(buf.String(), wantMsg)
}, 2*time.Second, time.Microsecond)

close(e.ExportTrigger)
_ = b.Shutdown(ctx)
Expand Down

0 comments on commit 281aeb5

Please sign in to comment.