From 0dd02dc67c0e4d9937640ed455a0fe58743148eb Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Mon, 20 May 2024 10:27:47 -0700 Subject: [PATCH] Recheck log message in TestBatchProcessor 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. --- sdk/log/batch_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/log/batch_test.go b/sdk/log/batch_test.go index bb836809f7f..2255fad02af 100644 --- a/sdk/log/batch_test.go +++ b/sdk/log/batch_test.go @@ -9,6 +9,7 @@ import ( stdlog "log" "slices" "strconv" + "strings" "sync" "testing" "time" @@ -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)