diff --git a/controllers/shipwrightbuild_controller_test.go b/controllers/shipwrightbuild_controller_test.go index dddbe6dc..07c3842c 100644 --- a/controllers/shipwrightbuild_controller_test.go +++ b/controllers/shipwrightbuild_controller_test.go @@ -155,20 +155,24 @@ func testShipwrightBuildReconcilerReconcile(t *testing.T, targetNamespace string // rolling out all manifests on the desired namespace, making sure the deployment for Shipwright // Build Controller is created accordingly t.Run("rollout-manifests", func(t *testing.T) { - t.Skip("TEMP: Skipping due to fake clients not talking to each other") ctx := context.TODO() res, err := r.Reconcile(ctx, req) g.Expect(err).To(o.BeNil()) - g.Expect(res.Requeue).To(o.BeFalse()) + // TODO: Code technically uses two different clientsets that don't talk to each other. + // This makes testing brittle and unable to capture the behavior on a real cluster. + // Requeue can return "true" because the tests think the CRD for ClusterBuildStrategies + // do not exist yet. + g.Expect(res.Requeue).To(o.BeTrue(), "checking requeue for Reconcile") err = c.Get(ctx, deploymentName, &appsv1.Deployment{}) g.Expect(err).To(o.BeNil()) err = c.Get(ctx, namespacedName, b) g.Expect(err).To(o.BeNil()) - g.Expect(b.Status.IsReady()).To(o.BeTrue()) + // Likewise, the ShipwrightBuild object will not report itself ready because it is waiting + // for the ClusterBuildStrategy CRD to be created first. + g.Expect(b.Status.IsReady()).To(o.BeFalse(), "checking ShipwrightBuild readiness") }) t.Run("rollout-manifests-with-images-env-vars", func(t *testing.T) { - t.Skip("TEMP: Skipping due to fake clients not talking to each other") ctx := context.TODO() for _, v := range images { t.Setenv(v.key, v.value) @@ -176,14 +180,20 @@ func testShipwrightBuildReconcilerReconcile(t *testing.T, targetNamespace string deployment := &appsv1.Deployment{} res, err := r.Reconcile(ctx, req) g.Expect(err).To(o.BeNil()) - g.Expect(res.Requeue).To(o.BeFalse()) + // TODO: Code technically uses two different clientsets that don't talk to each other. + // This makes testing brittle and unable to capture the behavior on a real cluster. + // Requeue can return "true" because the tests think the CRD for ClusterBuildStrategies + // do not exist yet. + g.Expect(res.Requeue).To(o.BeTrue()) err = c.Get(ctx, deploymentName, deployment) g.Expect(err).To(o.BeNil()) containers := deployment.Spec.Template.Spec.Containers g.Expect(containers[0].Image).To(o.Equal("ghcr.io/shipwright-io/build/shipwright-build-controller:nightly-2023-05-05-1683263383")) err = c.Get(ctx, namespacedName, b) g.Expect(err).To(o.BeNil()) - g.Expect(b.Status.IsReady()).To(o.BeTrue()) + // Likewise, the ShipwrightBuild object will not report itself ready because it is waiting + // for the ClusterBuildStrategy CRD to be created first. + g.Expect(b.Status.IsReady()).To(o.BeFalse()) }) // rolling back all changes, making sure the main deployment is also not found afterwards @@ -195,6 +205,8 @@ func testShipwrightBuildReconcilerReconcile(t *testing.T, targetNamespace string // setting a deletion timestemp on the build object, it triggers the rollback logic so the // reconciliation should remove the objects previously deployed + + // TODO: Refactor to use owner references so the rollback is handled by Kubernetes itself. b.SetDeletionTimestamp(&metav1.Time{Time: time.Now()}) err = r.Update(ctx, b, &client.UpdateOptions{}) g.Expect(err).To(o.BeNil()) @@ -223,9 +235,6 @@ func TestShipwrightBuildReconciler_Reconcile(t *testing.T) { for _, tt := range tests { t.Run(tt.testName, func(t *testing.T) { - if tt.testName == "target namespace is informed" { - t.Skip("TEMP: skip due to fake clients not talking to each other") - } testShipwrightBuildReconcilerReconcile(t, tt.targetNamespace) }) }