privval: synchronize leak check with shutdown (#7629)

The interaction between defers and t.Cleanup can be delicate.
For this case, which regularly flakes in CI, be explicit:
Defer the closes and waits before making any attempt to leaktest.
This commit is contained in:
M. J. Fromberger
2022-01-18 16:36:09 -08:00
committed by GitHub
parent a7eb95065d
commit 5eae2e62c0

View File

@@ -73,14 +73,15 @@ func TestSignerClose(t *testing.T) {
for _, tc := range getSignerTestCases(bctx, t, logger) {
t.Run(tc.name, func(t *testing.T) {
t.Cleanup(leaktest.Check(t))
defer tc.closer()
defer leaktest.Check(t)
defer func() {
tc.closer()
tc.signerClient.endpoint.Wait()
tc.signerServer.Wait()
}()
assert.NoError(t, tc.signerClient.Close())
assert.NoError(t, tc.signerServer.Stop())
t.Cleanup(tc.signerClient.endpoint.Wait)
t.Cleanup(tc.signerServer.Wait)
})
}
}