From ad943310bfd5a968604013df59d33d758d5f2daa Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Wed, 4 Aug 2021 09:57:49 -0400 Subject: [PATCH] Fix unit test. --- logging/telemetryhook_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/logging/telemetryhook_test.go b/logging/telemetryhook_test.go index c60275f95f..2009181433 100644 --- a/logging/telemetryhook_test.go +++ b/logging/telemetryhook_test.go @@ -217,5 +217,10 @@ func TestAsyncTelemetryHook_QueueDepth(t *testing.T) { close(filling) hook.Close() - require.Equal(t, maxDepth, len(testHook.entries())) + hookEntries := len(testHook.entries()) + require.GreaterOrEqual(t, hookEntries, maxDepth) + // the anonymous goroutine in createAsyncHookLevels might pull an entry off the pending list before + // writing it off to the underlying hook. when that happens, the total number of sent entries could + // be one higher then the maxDepth. + require.LessOrEqual(t, hookEntries, maxDepth+1) }