Skip to content

Commit b44eee3

Browse files
kruskallorestisfl
andauthored
test(TestPeriodIsAddedToEvent): wait for worker to shutdown (#47660)
* test(TestPeriodIsAddedToEvent): wait for worker to shutdown metricbeat wrapper is leaking a goroutine causing the test to fail because it's logging a message after the test is over. wait for worker to shutdown before returning * Apply suggestion from @orestisfl Co-authored-by: Orestis Floros <orestisflo@gmail.com> --------- Co-authored-by: Orestis Floros <orestisflo@gmail.com>
1 parent a6c922e commit b44eee3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

metricbeat/mb/module/wrapper_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,20 @@ func TestPeriodIsAddedToEvent(t *testing.T) {
193193
require.NoError(t, err)
194194

195195
done := make(chan struct{})
196-
defer close(done)
197196

198197
output := m.Start(done)
199198

200199
event := <-output
201200

202201
hasPeriod, _ := event.Fields.HasKey("metricset.period")
203202
assert.Equal(t, c.hasPeriod, hasPeriod, "has metricset.period in event %+v", event)
203+
204+
// stop worker
205+
close(done)
206+
207+
// wait for shutdown
208+
event, ok := <-output
209+
assert.Falsef(t, ok, "received unexpected event: %+v", event)
204210
})
205211
}
206212
}

0 commit comments

Comments
 (0)