diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index e25e4ef..9abde0b 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -19,8 +19,10 @@ limitations under the License. package controller import ( + "context" "path/filepath" "testing" + "time" "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo/v2" @@ -48,6 +50,8 @@ var k8sClient client.Client var testEnv *envtest.Environment var mockCtrl *gomock.Controller var mockConfigurationSettings *mocks.MockConfigurationSettingsRetriever +var ctx context.Context +var cancel context.CancelFunc func TestAPIs(t *testing.T) { RegisterFailHandler(Fail) @@ -58,6 +62,8 @@ func TestAPIs(t *testing.T) { var _ = BeforeSuite(func() { logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + ctx, cancel = context.WithCancel(context.TODO()) + By("bootstrapping test environment") testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, @@ -103,8 +109,12 @@ var _ = BeforeSuite(func() { var _ = AfterSuite(func() { By("tearing down the test environment") + cancel() mockCtrl.Finish() err := testEnv.Stop() - + if err != nil { + time.Sleep(1 * time.Minute) + } + err = testEnv.Stop() Expect(err).NotTo(HaveOccurred()) })