From 6ba25ba93fc9c6f0b1eebed7f30c476f90eca1d6 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 27 Nov 2023 15:17:08 +0000 Subject: [PATCH] tsdb tests: avoid 'defer' till end of function 'defer' only runs at the end of the function, so explicitly close the querier after we finish with it. Also check it didn't error. Signed-off-by: Bryan Boreham --- tsdb/head_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 748922ac6b..33b54a756f 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -1594,7 +1594,6 @@ func TestDelete_e2e(t *testing.T) { for i := 0; i < numRanges; i++ { q, err := NewBlockQuerier(hb, 0, 100000) require.NoError(t, err) - defer q.Close() ss := q.Select(context.Background(), true, nil, del.ms...) // Build the mockSeriesSet. matchedSeries := make([]storage.Series, 0, len(matched)) @@ -1635,6 +1634,7 @@ func TestDelete_e2e(t *testing.T) { } require.NoError(t, ss.Err()) require.Empty(t, ss.Warnings()) + require.NoError(t, q.Close()) } } }