Skip to content

Commit ff5dc78

Browse files
ingest storage: add cleanup to TestPartitionReader_ConsumeAtStartup (#9579)
* ingest storage: add cleanup to TestPartitionReader_ConsumeAtStartup related to XXX; this PR fixes the race on `testing.T.log()` mentioned in that issue. We don't wait for the fetchers to exit and as a result they use the logger after the parent test has exited. Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Expect errors when shutting down PartitionReadr Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> --------- Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
1 parent 539e690 commit ff5dc78

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/storage/ingest/reader_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,11 @@ func TestPartitionReader_ConsumeAtStartup(t *testing.T) {
13051305

13061306
readerCtx, cancelReaderCtx := context.WithCancel(ctx)
13071307
require.NoError(t, reader.StartAsync(readerCtx))
1308+
t.Cleanup(func() {
1309+
// Interrupting startup should fail the service.
1310+
// A context cancellation error shouldn't be swallowed and interpreted as "startup went ok"
1311+
assert.ErrorIs(t, services.StopAndAwaitTerminated(ctx, reader), context.Canceled)
1312+
})
13081313

13091314
// Wait until the Kafka cluster received at least 1 ListOffsets request.
13101315
test.Poll(t, 5*time.Second, true, func() interface{} {
@@ -1349,6 +1354,11 @@ func TestPartitionReader_ConsumeAtStartup(t *testing.T) {
13491354

13501355
readerCtx, cancelReaderCtx := context.WithCancel(ctx)
13511356
require.NoError(t, reader.StartAsync(readerCtx))
1357+
t.Cleanup(func() {
1358+
// Interrupting startup should fail the service.
1359+
// A context cancellation error shouldn't be swallowed and interpreted as "startup went ok"
1360+
assert.ErrorIs(t, services.StopAndAwaitTerminated(ctx, reader), context.Canceled)
1361+
})
13521362

13531363
// Wait until the Kafka cluster received at least 1 Fetch request.
13541364
test.Poll(t, 5*time.Second, true, func() interface{} {

0 commit comments

Comments
 (0)