From f4560390875996446739c6aebc82d37b39b454a4 Mon Sep 17 00:00:00 2001 From: Will Sewell Date: Fri, 29 Mar 2024 16:25:34 +0000 Subject: [PATCH] Don't block on goroutines returning in processor_test.go Blocking on all goroutines fully returning is not necssary to appearse goleak. See: https://github.com/jaegertracing/jaeger/pull/5310/files/dfe7adc7fd34389e2e507d9512eb64b5e19048f7#r1544603132 Signed-off-by: Will Sewell --- .../strategystore/adaptive/processor_test.go | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/plugin/sampling/strategystore/adaptive/processor_test.go b/plugin/sampling/strategystore/adaptive/processor_test.go index 4615b65fa49..03ae6b7b7bb 100644 --- a/plugin/sampling/strategystore/adaptive/processor_test.go +++ b/plugin/sampling/strategystore/adaptive/processor_test.go @@ -393,15 +393,8 @@ func TestRunCalculationLoop_GetThroughputError(t *testing.T) { p, err := newProcessor(cfg, "host", mockStorage, mockEP, metrics.NullFactory, logger) require.NoError(t, err) p.shutdown = make(chan struct{}) - done := make(chan struct{}) - go func() { - p.runCalculationLoop() - close(done) - }() - defer func() { - close(p.shutdown) - <-done - }() + defer close(p.shutdown) + go p.runCalculationLoop() for i := 0; i < 1000; i++ { // match logs specific to getThroughputErrMsg. We expect to see more than 2, once during @@ -439,17 +432,10 @@ func TestRunUpdateProbabilitiesLoop(t *testing.T) { followerRefreshInterval: time.Millisecond, electionParticipant: mockEP, } + defer close(p.shutdown) require.Nil(t, p.probabilities) require.Nil(t, p.strategyResponses) - done := make(chan struct{}) - go func() { - p.runUpdateProbabilitiesLoop() - close(done) - }() - defer func() { - close(p.shutdown) - <-done - }() + go p.runUpdateProbabilitiesLoop() for i := 0; i < 1000; i++ { p.RLock()