From 7cc00ec9810bf606c3aa0cd50103c646d7fcf891 Mon Sep 17 00:00:00 2001 From: Danielle Lancashire Date: Tue, 15 Mar 2022 18:56:19 +0000 Subject: [PATCH] tests/framework/integration: Fail nesting early Currently there are a handful of tests within etcd that silently fail because LeakDetection will skip the test before it manages to hit this check. Here we move the check to the beginning of the process to highlight these cases earlier, and to avoid them accidentally presenting as leaks. --- tests/framework/integration/testing.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/framework/integration/testing.go b/tests/framework/integration/testing.go index ca4a27f0d..a992c87f0 100644 --- a/tests/framework/integration/testing.go +++ b/tests/framework/integration/testing.go @@ -72,6 +72,10 @@ func BeforeTest(t testutil.TB, opts ...TestOption) { t.Helper() options := newTestOptions(opts...) + if insideTestContext { + t.Fatal("already in test context. BeforeTest was likely already called") + } + if options.skipInShort { testutil.SkipTestIfShortMode(t, "Cannot create clusters in --short tests") } @@ -93,10 +97,6 @@ func BeforeTest(t testutil.TB, opts ...TestOption) { os.Chdir(previousWD) }) - if insideTestContext { - t.Fatal("already in test context. BeforeTest was likely already called") - } - grpc_logger.Set(zapgrpc.NewLogger(zaptest.NewLogger(t).Named("grpc"))) insideTestContext = true