From f24d2e5665bc1b4fe380e06f1d1f15a57c184680 Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Wed, 12 May 2021 09:57:29 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20Refactor=20tests=20to=20plain=20?= =?UTF-8?q?go=20in=20exp/controllers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../machinepool_controller_phases_test.go | 178 ++++++++++-------- exp/controllers/suite_test.go | 50 +++-- 2 files changed, 122 insertions(+), 106 deletions(-) diff --git a/exp/controllers/machinepool_controller_phases_test.go b/exp/controllers/machinepool_controller_phases_test.go index 193a7d79a605..2f499a363f1f 100644 --- a/exp/controllers/machinepool_controller_phases_test.go +++ b/exp/controllers/machinepool_controller_phases_test.go @@ -20,7 +20,6 @@ import ( "testing" "time" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -40,7 +39,7 @@ func init() { externalReadyWait = 1 * time.Second } -var _ = Describe("Reconcile MachinePool Phases", func() { +func TestReconcileMachinePoolPhases(t *testing.T) { deletionTimestamp := metav1.Now() var defaultKubeconfigSecret *corev1.Secret @@ -108,11 +107,10 @@ var _ = Describe("Reconcile MachinePool Phases", func() { }, } - BeforeEach(func() { - defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) - }) + t.Run("Should set OwnerReference and cluster name label on external objects", func(t *testing.T) { + g := NewWithT(t) - It("Should set OwnerReference and cluster name label on external objects", func() { + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() @@ -122,23 +120,26 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) r.reconcilePhase(machinepool) - Expect(r.Client.Get(ctx, types.NamespacedName{Name: bootstrapConfig.GetName(), Namespace: bootstrapConfig.GetNamespace()}, bootstrapConfig)).To(Succeed()) + g.Expect(r.Client.Get(ctx, types.NamespacedName{Name: bootstrapConfig.GetName(), Namespace: bootstrapConfig.GetNamespace()}, bootstrapConfig)).To(Succeed()) - Expect(bootstrapConfig.GetOwnerReferences()).To(HaveLen(1)) - Expect(bootstrapConfig.GetLabels()[clusterv1.ClusterLabelName]).To(BeEquivalentTo("test-cluster")) + g.Expect(bootstrapConfig.GetOwnerReferences()).To(HaveLen(1)) + g.Expect(bootstrapConfig.GetLabels()[clusterv1.ClusterLabelName]).To(BeEquivalentTo("test-cluster")) - Expect(r.Client.Get(ctx, types.NamespacedName{Name: infraConfig.GetName(), Namespace: infraConfig.GetNamespace()}, infraConfig)).To(Succeed()) + g.Expect(r.Client.Get(ctx, types.NamespacedName{Name: infraConfig.GetName(), Namespace: infraConfig.GetNamespace()}, infraConfig)).To(Succeed()) - Expect(infraConfig.GetOwnerReferences()).To(HaveLen(1)) - Expect(infraConfig.GetLabels()[clusterv1.ClusterLabelName]).To(BeEquivalentTo("test-cluster")) + g.Expect(infraConfig.GetOwnerReferences()).To(HaveLen(1)) + g.Expect(infraConfig.GetLabels()[clusterv1.ClusterLabelName]).To(BeEquivalentTo("test-cluster")) }) - It("Should set `Pending` with a new MachinePool", func() { + t.Run("Should set `Pending` with a new MachinePool", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() @@ -148,61 +149,67 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhasePending)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhasePending)) }) - It("Should set `Provisioning` when bootstrap is ready", func() { + t.Run("Should set `Provisioning` when bootstrap is ready", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) r := &MachinePoolReconciler{ Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig).Build(), } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseProvisioning)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseProvisioning)) }) - It("Should set `Running` when bootstrap and infra is ready", func() { + t.Run("Should set `Running` when bootstrap and infra is ready", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set infra ready. err = unstructured.SetNestedField(infraConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, int64(1), "status", "replicas") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedStringSlice(infraConfig.Object, []string{"test://machinepool-test-node"}, "spec", "providerIDList") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, "us-east-2a", "spec", "failureDomain") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set NodeRef. machinepool.Status.NodeRefs = []corev1.ObjectReference{{Kind: "Node", Name: "machinepool-test-node"}} @@ -212,37 +219,40 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas machinepool.Status.ReadyReplicas = 1 r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) }) - It("Should set `Running` when bootstrap, infra, and ready replicas equals spec replicas", func() { + t.Run("Should set `Running` when bootstrap, infra, and ready replicas equals spec replicas", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set infra ready. err = unstructured.SetNestedStringSlice(infraConfig.Object, []string{"test://id-1"}, "spec", "providerIDList") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, int64(1), "status", "replicas") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, []interface{}{ map[string]interface{}{ @@ -254,7 +264,7 @@ var _ = Describe("Reconcile MachinePool Phases", func() { "address": "10.0.0.2", }, }, "addresses") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set NodeRef. machinepool.Status.NodeRefs = []corev1.ObjectReference{{Kind: "Node", Name: "machinepool-test-node"}} @@ -264,27 +274,30 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas machinepool.Status.ReadyReplicas = 1 r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) }) - It("Should set `Provisioned` when there is a NodeRef but infra is not ready ", func() { + t.Run("Should set `Provisioned` when there is a NodeRef but infra is not ready ", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set NodeRef. machinepool.Status.NodeRefs = []corev1.ObjectReference{{Kind: "Node", Name: "machinepool-test-node"}} @@ -294,34 +307,37 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseProvisioned)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseProvisioned)) }) - It("Should set `ScalingUp` when infra is scaling up", func() { + t.Run("Should set `ScalingUp` when infra is scaling up", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set infra ready. err = unstructured.SetNestedStringSlice(infraConfig.Object, []string{"test://id-1"}, "spec", "providerIDList") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, int64(1), "status", "replicas") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set NodeRef. machinepool.Status.NodeRefs = []corev1.ObjectReference{{Kind: "Node", Name: "machinepool-test-node"}} @@ -331,8 +347,8 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas machinepool.Status.ReadyReplicas = 1 @@ -341,30 +357,33 @@ var _ = Describe("Reconcile MachinePool Phases", func() { machinepool.Spec.Replicas = pointer.Int32Ptr(5) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseScalingUp)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseScalingUp)) }) - It("Should set `ScalingDown` when infra is scaling down", func() { + t.Run("Should set `ScalingDown` when infra is scaling down", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set infra ready. err = unstructured.SetNestedStringSlice(infraConfig.Object, []string{"test://id-1"}, "spec", "providerIDList") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, int64(4), "status", "replicas") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) machinepool.Spec.Replicas = pointer.Int32Ptr(4) @@ -381,8 +400,8 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas machinepool.Status.ReadyReplicas = 4 @@ -391,27 +410,30 @@ var _ = Describe("Reconcile MachinePool Phases", func() { machinepool.Spec.Replicas = pointer.Int32Ptr(1) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseScalingDown)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseScalingDown)) }) - It("Should set `Deleting` when MachinePool is being deleted", func() { + t.Run("Should set `Deleting` when MachinePool is being deleted", func(t *testing.T) { + g := NewWithT(t) + + defaultKubeconfigSecret = kubeconfig.GenerateSecret(defaultCluster, kubeconfig.FromEnvTestConfig(testEnv.Config, defaultCluster)) machinepool := defaultMachinePool.DeepCopy() bootstrapConfig := defaultBootstrap.DeepCopy() infraConfig := defaultInfra.DeepCopy() // Set bootstrap ready. err := unstructured.SetNestedField(bootstrapConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(bootstrapConfig.Object, "secret-data", "status", "dataSecretName") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set infra ready. err = unstructured.SetNestedStringSlice(infraConfig.Object, []string{"test://id-1"}, "spec", "providerIDList") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, true, "status", "ready") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) err = unstructured.SetNestedField(infraConfig.Object, []interface{}{ map[string]interface{}{ @@ -423,7 +445,7 @@ var _ = Describe("Reconcile MachinePool Phases", func() { "address": "10.0.0.2", }, }, "addresses") - Expect(err).NotTo(HaveOccurred()) + g.Expect(err).NotTo(HaveOccurred()) // Set NodeRef. machinepool.Status.NodeRefs = []corev1.ObjectReference{{Kind: "Node", Name: "machinepool-test-node"}} @@ -436,13 +458,13 @@ var _ = Describe("Reconcile MachinePool Phases", func() { } res, err := r.reconcile(ctx, defaultCluster, machinepool) - Expect(err).NotTo(HaveOccurred()) - Expect(res.Requeue).To(BeFalse()) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(res.Requeue).To(BeFalse()) r.reconcilePhase(machinepool) - Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseDeleting)) + g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseDeleting)) }) -}) +} func TestReconcileMachinePoolBootstrap(t *testing.T) { defaultMachinePool := expv1.MachinePool{ diff --git a/exp/controllers/suite_test.go b/exp/controllers/suite_test.go index 8368f02a0639..177cafe76d38 100644 --- a/exp/controllers/suite_test.go +++ b/exp/controllers/suite_test.go @@ -17,55 +17,49 @@ limitations under the License. package controllers import ( + "fmt" + "os" "testing" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "sigs.k8s.io/cluster-api/test/helpers" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" // +kubebuilder:scaffold:imports ) -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - var ( testEnv *helpers.TestEnvironment ctx = ctrl.SetupSignalHandler() ) -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecsWithDefaultAndCustomReporters(t, - "Controller Suite", - []Reporter{printer.NewlineReporter{}}) -} - -var _ = BeforeSuite(func() { - By("bootstrapping test environment") +func TestMain(m *testing.M) { + fmt.Println("Creating new test environment") testEnv = helpers.NewTestEnvironment() - Expect((&MachinePoolReconciler{ + machinePoolReconciler := MachinePoolReconciler{ Client: testEnv, recorder: testEnv.GetEventRecorderFor("machinepool-controller"), - }).SetupWithManager(ctx, testEnv.Manager, controller.Options{MaxConcurrentReconciles: 1})).To(Succeed()) + } + err := machinePoolReconciler.SetupWithManager(ctx, testEnv.Manager, controller.Options{MaxConcurrentReconciles: 1}) + if err != nil { + panic(fmt.Sprintf("Failed to set up machine pool reconciler: %v", err)) + } - By("starting the manager") go func() { - defer GinkgoRecover() - Expect(testEnv.StartManager(ctx)).To(Succeed()) + fmt.Println("Starting the manager") + if err := testEnv.StartManager(ctx); err != nil { + panic(fmt.Sprintf("Failed to start the envtest manager: %v", err)) + } }() <-testEnv.Manager.Elected() testEnv.WaitForWebhooks() -}, 60) -var _ = AfterSuite(func() { - if testEnv != nil { - By("tearing down the test environment") - Expect(testEnv.Stop()).To(Succeed()) + code := m.Run() + + fmt.Println("Tearing down test suite") + if err := testEnv.Stop(); err != nil { + panic(fmt.Sprintf("Failed to stop envtest: %v", err)) } -}) + + os.Exit(code) +}