Skip to content

Commit bffc7a1

Browse files
maelvlswallrj
andcommitted
tests: fix left over kube-apiserver and etcd processes
Sometimes (for example when the CRD file isn't found), the test would stop immediately after envtest.Start, meaning that the t.Cleanup block wouldn't run and the two new processes would be left over after the test process would end. The credit for identifying this bug and fixing goes to Richard Wall in [1]. [1]: #560 (comment) Co-authored-by: Richard Wall <[email protected]>
1 parent ac192bb commit bffc7a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/client/client_venconn_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,14 @@ func startEnvtest(t testing.TB) (_ *envtest.Environment, _ *rest.Config, kclient
346346
ErrorIfCRDPathMissing: true,
347347
CRDDirectoryPaths: []string{"../../deploy/charts/venafi-kubernetes-agent/crd_bases/jetstack.io_venaficonnections.yaml"},
348348
}
349-
restconf, err := envtest.Start()
350-
require.NoError(t, err)
351349

350+
restconf, err := envtest.Start()
352351
t.Cleanup(func() {
353352
t.Log("Waiting for envtest to exit")
354-
err = envtest.Stop()
355-
require.NoError(t, err)
353+
e := envtest.Stop()
354+
require.NoError(t, e)
356355
})
356+
require.NoError(t, err)
357357

358358
sch := runtime.NewScheme()
359359
_ = v1alpha1.AddToScheme(sch)

0 commit comments

Comments
 (0)