From f5c3ea1bf28de89b195b7e935ac3f5dfcca15358 Mon Sep 17 00:00:00 2001 From: Shihao Xia Date: Mon, 20 Dec 2021 07:07:53 -0500 Subject: [PATCH] fix missing db.Close() in web_test.go in order to avoid goroutine leak (#10035) Signed-off-by: Shihao Xia --- web/web_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/web_test.go b/web/web_test.go index f5711235f..f8bac60e7 100644 --- a/web/web_test.go +++ b/web/web_test.go @@ -116,7 +116,9 @@ func TestReadyAndHealthy(t *testing.T) { db, err := tsdb.Open(dbDir, nil, nil, nil, nil) require.NoError(t, err) - + t.Cleanup(func() { + require.NoError(t, db.Close()) + }) port := fmt.Sprintf(":%d", testutil.RandomUnprivilegedPort(t)) opts := &Options{ @@ -237,6 +239,9 @@ func TestRoutePrefix(t *testing.T) { db, err := tsdb.Open(dbDir, nil, nil, nil, nil) require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, db.Close()) + }) port := fmt.Sprintf(":%d", testutil.RandomUnprivilegedPort(t)) @@ -404,7 +409,9 @@ func TestShutdownWithStaleConnection(t *testing.T) { db, err := tsdb.Open(dbDir, nil, nil, nil, nil) require.NoError(t, err) - + t.Cleanup(func() { + require.NoError(t, db.Close()) + }) timeout := 10 * time.Second port := fmt.Sprintf(":%d", testutil.RandomUnprivilegedPort(t))