diff --git a/pkg/controllers/workapplier/controller_integration_migrated_2_test.go b/pkg/controllers/workapplier/controller_integration_migrated_2_test.go deleted file mode 100644 index a5567cdc5..000000000 --- a/pkg/controllers/workapplier/controller_integration_migrated_2_test.go +++ /dev/null @@ -1,221 +0,0 @@ -/* -Copyright (c) Microsoft Corporation. -Licensed under the MIT license. -*/ - -package workapplier - -import ( - "context" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - utilrand "k8s.io/apimachinery/pkg/util/rand" - - fleetv1beta1 "go.goms.io/fleet/apis/placement/v1beta1" - testv1alpha1 "go.goms.io/fleet/test/apis/v1alpha1" -) - -var _ = Describe("Work Status Reconciler", func() { - var resourceNamespace string - var work *fleetv1beta1.Work - var cm, cm2 *corev1.ConfigMap - var rns corev1.Namespace - - BeforeEach(func() { - resourceNamespace = utilrand.String(5) - rns = corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceNamespace, - }, - } - Expect(k8sClient.Create(context.Background(), &rns)).Should(Succeed(), "Failed to create the resource namespace") - - // Create the Work object with some type of Manifest resource. - cm = &corev1.ConfigMap{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "ConfigMap", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "configmap-" + utilrand.String(5), - Namespace: resourceNamespace, - }, - Data: map[string]string{ - "test": "test", - }, - } - cm2 = &corev1.ConfigMap{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "ConfigMap", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "configmap2-" + utilrand.String(5), - Namespace: resourceNamespace, - }, - Data: map[string]string{ - "test": "test", - }, - } - - By("Create work that contains two configMaps") - work = &fleetv1beta1.Work{ - ObjectMeta: metav1.ObjectMeta{ - Name: "work-" + utilrand.String(5), - Namespace: testWorkNamespace, - }, - Spec: fleetv1beta1.WorkSpec{ - Workload: fleetv1beta1.WorkloadTemplate{ - Manifests: []fleetv1beta1.Manifest{ - { - RawExtension: runtime.RawExtension{Object: cm}, - }, - { - RawExtension: runtime.RawExtension{Object: cm2}, - }, - }, - }, - }, - } - }) - - AfterEach(func() { - // TODO: Ensure that all resources are being deleted. - Expect(k8sClient.Delete(context.Background(), work)).Should(Succeed()) - Expect(k8sClient.Delete(context.Background(), &rns)).Should(Succeed()) - }) - - It("Should delete the manifest from the member cluster after it is removed from work", func() { - By("Apply the work") - Expect(k8sClient.Create(context.Background(), work)).ToNot(HaveOccurred()) - - By("Make sure that the work is applied") - currentWork := waitForWorkToApply(work.Name, testWorkNamespace) - var appliedWork fleetv1beta1.AppliedWork - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) - - By("Remove configMap 2 from the work") - currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ - { - RawExtension: runtime.RawExtension{Object: cm}, - }, - } - Expect(k8sClient.Update(context.Background(), currentWork)).Should(Succeed()) - - By("Verify that the resource is removed from the cluster") - Eventually(func() bool { - var configMap corev1.ConfigMap - return apierrors.IsNotFound(k8sClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap)) - }, timeout, interval).Should(BeTrue()) - - By("Verify that the appliedWork status is correct") - Eventually(func() bool { - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - return len(appliedWork.Status.AppliedResources) == 1 - }, timeout, interval).Should(BeTrue()) - Expect(appliedWork.Status.AppliedResources[0].Name).Should(Equal(cm.GetName())) - Expect(appliedWork.Status.AppliedResources[0].Namespace).Should(Equal(cm.GetNamespace())) - Expect(appliedWork.Status.AppliedResources[0].Version).Should(Equal(cm.GetObjectKind().GroupVersionKind().Version)) - Expect(appliedWork.Status.AppliedResources[0].Group).Should(Equal(cm.GetObjectKind().GroupVersionKind().Group)) - Expect(appliedWork.Status.AppliedResources[0].Kind).Should(Equal(cm.GetObjectKind().GroupVersionKind().Kind)) - }) - - It("Should delete the manifest from the member cluster even if there is apply failure", func() { - By("Apply the work") - Expect(k8sClient.Create(context.Background(), work)).ToNot(HaveOccurred()) - - By("Make sure that the work is applied") - currentWork := waitForWorkToApply(work.Name, testWorkNamespace) - var appliedWork fleetv1beta1.AppliedWork - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) - - By("replace configMap with a bad object from the work") - testResource := &testv1alpha1.TestResource{ - TypeMeta: metav1.TypeMeta{ - APIVersion: testv1alpha1.GroupVersion.String(), - Kind: "TestResource", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "testresource-" + utilrand.String(5), - // to ensure the resource is not applied. - Namespace: "random-test-namespace", - }, - } - currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ - { - RawExtension: runtime.RawExtension{Object: testResource}, - }, - } - Expect(k8sClient.Update(context.Background(), currentWork)).Should(Succeed()) - - By("Verify that the configMaps are removed from the cluster even if the new resource didn't apply") - Eventually(func() bool { - var configMap corev1.ConfigMap - return apierrors.IsNotFound(k8sClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap)) - }, timeout, interval).Should(BeTrue()) - - Eventually(func() bool { - var configMap corev1.ConfigMap - return apierrors.IsNotFound(k8sClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap)) - }, timeout, interval).Should(BeTrue()) - - By("Verify that the appliedWork status is correct") - Eventually(func() bool { - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - return len(appliedWork.Status.AppliedResources) == 0 - }, timeout, interval).Should(BeTrue()) - }) - - It("Test the order of the manifest in the work alone does not trigger any operation in the member cluster", func() { - By("Apply the work") - Expect(k8sClient.Create(context.Background(), work)).ToNot(HaveOccurred()) - - By("Make sure that the work is applied") - currentWork := waitForWorkToApply(work.Name, testWorkNamespace) - var appliedWork fleetv1beta1.AppliedWork - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) - - By("Make sure that the manifests exist on the member cluster") - Eventually(func() bool { - var configMap corev1.ConfigMap - return k8sClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap) == nil && - k8sClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap) == nil - }, timeout, interval).Should(BeTrue()) - - By("Change the order of the two configs in the work") - currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ - { - RawExtension: runtime.RawExtension{Object: cm2}, - }, - { - RawExtension: runtime.RawExtension{Object: cm}, - }, - } - Expect(k8sClient.Update(context.Background(), currentWork)).Should(Succeed()) - - By("Verify that nothing is removed from the cluster") - Consistently(func() bool { - var configMap corev1.ConfigMap - return k8sClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap) == nil && - k8sClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap) == nil - }, timeout, time.Millisecond*25).Should(BeTrue()) - - By("Verify that the appliedWork status is correct") - Eventually(func() bool { - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) - return len(appliedWork.Status.AppliedResources) == 2 - }, timeout, interval).Should(BeTrue()) - Expect(appliedWork.Status.AppliedResources[0].Name).Should(Equal(cm2.GetName())) - Expect(appliedWork.Status.AppliedResources[1].Name).Should(Equal(cm.GetName())) - }) -}) diff --git a/pkg/controllers/workapplier/controller_integration_migrated_helper_test.go b/pkg/controllers/workapplier/controller_integration_migrated_helper_test.go index 45fa25802..077f846a5 100644 --- a/pkg/controllers/workapplier/controller_integration_migrated_helper_test.go +++ b/pkg/controllers/workapplier/controller_integration_migrated_helper_test.go @@ -25,12 +25,12 @@ import ( ) // createWorkWithManifest creates a work given a manifest -func createWorkWithManifest(workNamespace string, manifest runtime.Object) *fleetv1beta1.Work { +func createWorkWithManifest(manifest runtime.Object) *fleetv1beta1.Work { manifestCopy := manifest.DeepCopyObject() newWork := fleetv1beta1.Work{ ObjectMeta: metav1.ObjectMeta{ Name: "work-" + utilrand.String(5), - Namespace: workNamespace, + Namespace: memberReservedNSName, }, Spec: fleetv1beta1.WorkSpec{ Workload: fleetv1beta1.WorkloadTemplate{ @@ -48,7 +48,7 @@ func createWorkWithManifest(workNamespace string, manifest runtime.Object) *flee // verifyAppliedConfigMap verifies that the applied CM is the same as the CM we want to apply func verifyAppliedConfigMap(cm *corev1.ConfigMap) *corev1.ConfigMap { var appliedCM corev1.ConfigMap - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &appliedCM)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &appliedCM)).Should(Succeed()) By("Check the config map label") Expect(cmp.Diff(appliedCM.Labels, cm.Labels)).Should(BeEmpty()) @@ -67,10 +67,10 @@ func verifyAppliedConfigMap(cm *corev1.ConfigMap) *corev1.ConfigMap { } // waitForWorkToApply waits for a work to be applied -func waitForWorkToApply(workName, workNS string) *fleetv1beta1.Work { +func waitForWorkToApply(workName string) *fleetv1beta1.Work { var resultWork fleetv1beta1.Work Eventually(func() bool { - err := k8sClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: workNS}, &resultWork) + err := hubClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: memberReservedNSName}, &resultWork) if err != nil { return false } @@ -86,15 +86,15 @@ func waitForWorkToApply(workName, workNS string) *fleetv1beta1.Work { } } return true - }, timeout, interval).Should(BeTrue()) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) return &resultWork } // waitForWorkToAvailable waits for a work to have an available condition to be true -func waitForWorkToBeAvailable(workName, workNS string) *fleetv1beta1.Work { +func waitForWorkToBeAvailable(workName string) *fleetv1beta1.Work { var resultWork fleetv1beta1.Work Eventually(func() bool { - err := k8sClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: workNS}, &resultWork) + err := hubClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: memberReservedNSName}, &resultWork) if err != nil { return false } @@ -110,7 +110,7 @@ func waitForWorkToBeAvailable(workName, workNS string) *fleetv1beta1.Work { } } return true - }, timeout, interval).Should(BeTrue()) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) return &resultWork } @@ -118,11 +118,11 @@ func waitForWorkToBeAvailable(workName, workNS string) *fleetv1beta1.Work { func waitForWorkToBeHandled(workName, workNS string) *fleetv1beta1.Work { var resultWork fleetv1beta1.Work Eventually(func() bool { - err := k8sClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: workNS}, &resultWork) + err := hubClient.Get(context.Background(), types.NamespacedName{Name: workName, Namespace: workNS}, &resultWork) if err != nil { return false } return controllerutil.ContainsFinalizer(&resultWork, fleetv1beta1.WorkFinalizer) - }, timeout, interval).Should(BeTrue()) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) return &resultWork } diff --git a/pkg/controllers/workapplier/controller_integration_migrated_1_test.go b/pkg/controllers/workapplier/controller_integration_migrated_test.go similarity index 57% rename from pkg/controllers/workapplier/controller_integration_migrated_1_test.go rename to pkg/controllers/workapplier/controller_integration_migrated_test.go index a744c97d2..2c4644e8c 100644 --- a/pkg/controllers/workapplier/controller_integration_migrated_1_test.go +++ b/pkg/controllers/workapplier/controller_integration_migrated_test.go @@ -9,14 +9,15 @@ import ( "context" "encoding/json" "fmt" - "time" "github.com/google/go-cmp/cmp" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" utilrand "k8s.io/apimachinery/pkg/util/rand" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -26,9 +27,6 @@ import ( "go.goms.io/fleet/test/utils/controller" ) -const timeout = time.Second * 10 -const interval = time.Millisecond * 250 - var _ = Describe("Work Controller", func() { var cm *corev1.ConfigMap var work *fleetv1beta1.Work @@ -53,11 +51,11 @@ var _ = Describe("Work Controller", func() { } By("create the work") - work = createWorkWithManifest(testWorkNamespace, cm) - err := k8sClient.Create(context.Background(), work) + work = createWorkWithManifest(cm) + err := hubClient.Create(context.Background(), work) Expect(err).ToNot(HaveOccurred()) - resultWork := waitForWorkToBeAvailable(work.GetName(), work.GetNamespace()) + resultWork := waitForWorkToBeAvailable(work.GetName()) Expect(len(resultWork.Status.ManifestConditions)).Should(Equal(1)) expectedResourceID := fleetv1beta1.WorkResourceIdentifier{ Ordinal: 0, @@ -98,11 +96,11 @@ var _ = Describe("Work Controller", func() { By("Check applied config map") var configMap corev1.ConfigMap - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: cmName, Namespace: cmNamespace}, &configMap)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: cmName, Namespace: cmNamespace}, &configMap)).Should(Succeed()) Expect(cmp.Diff(configMap.Labels, cm.Labels)).Should(BeEmpty()) Expect(cmp.Diff(configMap.Data, cm.Data)).Should(BeEmpty()) - Expect(k8sClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") + Expect(hubClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") }) It("Should pick up the built-in manifest change correctly", func() { @@ -131,11 +129,11 @@ var _ = Describe("Work Controller", func() { } By("create the work") - work = createWorkWithManifest(testWorkNamespace, cm) - Expect(k8sClient.Create(context.Background(), work)).ToNot(HaveOccurred()) + work = createWorkWithManifest(cm) + Expect(hubClient.Create(context.Background(), work)).ToNot(HaveOccurred()) By("wait for the work to be available") - waitForWorkToBeAvailable(work.GetName(), work.GetNamespace()) + waitForWorkToBeAvailable(work.GetName()) By("Check applied config map") verifyAppliedConfigMap(cm) @@ -155,19 +153,19 @@ var _ = Describe("Work Controller", func() { delete(cm.Annotations, "annotationKey1") By("update the work") - resultWork := waitForWorkToApply(work.GetName(), work.GetNamespace()) + resultWork := waitForWorkToApply(work.GetName()) rawCM, err := json.Marshal(cm) Expect(err).Should(Succeed()) resultWork.Spec.Workload.Manifests[0].Raw = rawCM - Expect(k8sClient.Update(ctx, resultWork)).Should(Succeed()) + Expect(hubClient.Update(ctx, resultWork)).Should(Succeed()) By("wait for the change of the work to be applied") - waitForWorkToApply(work.GetName(), work.GetNamespace()) + waitForWorkToApply(work.GetName()) By("verify that applied configMap took all the changes") verifyAppliedConfigMap(cm) - Expect(k8sClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") + Expect(hubClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") }) It("Should merge the third party change correctly", func() { @@ -193,12 +191,12 @@ var _ = Describe("Work Controller", func() { } By("create the work") - work = createWorkWithManifest(testWorkNamespace, cm) - err := k8sClient.Create(context.Background(), work) + work = createWorkWithManifest(cm) + err := hubClient.Create(context.Background(), work) Expect(err).ToNot(HaveOccurred()) By("wait for the work to be applied") - waitForWorkToApply(work.GetName(), work.GetNamespace()) + waitForWorkToApply(work.GetName()) By("Check applied configMap") appliedCM := verifyAppliedConfigMap(cm) @@ -213,11 +211,11 @@ var _ = Describe("Work Controller", func() { // remove label key2 and key3 delete(cm.Labels, "labelKey2") delete(cm.Labels, "labelKey3") - Expect(k8sClient.Update(context.Background(), appliedCM)).Should(Succeed()) + Expect(memberClient.Update(context.Background(), appliedCM)).Should(Succeed()) By("Get the last applied config map and verify it's updated") var modifiedCM corev1.ConfigMap - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &modifiedCM)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &modifiedCM)).Should(Succeed()) Expect(cmp.Diff(appliedCM.Labels, modifiedCM.Labels)).Should(BeEmpty()) Expect(cmp.Diff(appliedCM.Data, modifiedCM.Data)).Should(BeEmpty()) @@ -230,17 +228,17 @@ var _ = Describe("Work Controller", func() { cm.Labels["labelKey3"] = "added-back-by-manifest" By("update the work") - resultWork := waitForWorkToApply(work.GetName(), work.GetNamespace()) + resultWork := waitForWorkToApply(work.GetName()) rawCM, err := json.Marshal(cm) Expect(err).Should(Succeed()) resultWork.Spec.Workload.Manifests[0].Raw = rawCM - Expect(k8sClient.Update(context.Background(), resultWork)).Should(Succeed()) + Expect(hubClient.Update(context.Background(), resultWork)).Should(Succeed()) By("wait for the change of the work to be applied") - waitForWorkToApply(work.GetName(), work.GetNamespace()) + waitForWorkToApply(work.GetName()) By("Get the last applied config map") - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: cmName, Namespace: cmNamespace}, appliedCM)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: cmName, Namespace: cmNamespace}, appliedCM)).Should(Succeed()) By("Check the config map data") // data1's value picks up our change @@ -263,7 +261,7 @@ var _ = Describe("Work Controller", func() { } Expect(cmp.Diff(appliedCM.Labels, expectedLabel)).Should(BeEmpty()) - Expect(k8sClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") + Expect(hubClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") }) It("Should pick up the crd change correctly", func() { @@ -298,16 +296,16 @@ var _ = Describe("Work Controller", func() { } By("create the work") - work = createWorkWithManifest(testWorkNamespace, testResource) - err := k8sClient.Create(context.Background(), work) + work = createWorkWithManifest(testResource) + err := hubClient.Create(context.Background(), work) Expect(err).ToNot(HaveOccurred()) By("wait for the work to be applied") - waitForWorkToBeAvailable(work.GetName(), work.GetNamespace()) + waitForWorkToBeAvailable(work.GetName()) By("Check applied TestResource") var appliedTestResource testv1alpha1.TestResource - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &appliedTestResource)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &appliedTestResource)).Should(Succeed()) By("verify the TestResource spec") Expect(cmp.Diff(appliedTestResource.Spec, testResource.Spec)).Should(BeEmpty()) @@ -328,11 +326,11 @@ var _ = Describe("Work Controller", func() { appliedTestResource.Spec.Items = []string{"a", "b"} appliedTestResource.Spec.Foo = "foo1" appliedTestResource.Spec.Bar = "bar1" - Expect(k8sClient.Update(context.Background(), &appliedTestResource)).Should(Succeed()) + Expect(memberClient.Update(context.Background(), &appliedTestResource)).Should(Succeed()) By("Verify applied TestResource modified") var modifiedTestResource testv1alpha1.TestResource - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &modifiedTestResource)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &modifiedTestResource)).Should(Succeed()) Expect(cmp.Diff(appliedTestResource.Spec, modifiedTestResource.Spec)).Should(BeEmpty()) By("Modify the TestResource") @@ -346,15 +344,15 @@ var _ = Describe("Work Controller", func() { testResource.Spec.Foo = "foo2" testResource.Spec.Bar = "bar2" By("update the work") - resultWork := waitForWorkToApply(work.GetName(), work.GetNamespace()) + resultWork := waitForWorkToApply(work.GetName()) rawTR, err := json.Marshal(testResource) Expect(err).Should(Succeed()) resultWork.Spec.Workload.Manifests[0].Raw = rawTR - Expect(k8sClient.Update(context.Background(), resultWork)).Should(Succeed()) - waitForWorkToApply(work.GetName(), work.GetNamespace()) + Expect(hubClient.Update(context.Background(), resultWork)).Should(Succeed()) + waitForWorkToApply(work.GetName()) By("Get the last applied TestResource") - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &appliedTestResource)).Should(Succeed()) + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: testResourceName, Namespace: testResourceNamespace}, &appliedTestResource)).Should(Succeed()) By("Check the TestResource spec, its an override for arrays") expectedItems := []string{"a", "b"} @@ -363,7 +361,7 @@ var _ = Describe("Work Controller", func() { Expect(cmp.Diff(appliedTestResource.Spec.Foo, "foo2")).Should(BeEmpty()) Expect(cmp.Diff(appliedTestResource.Spec.Bar, "bar2")).Should(BeEmpty()) - Expect(k8sClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") + Expect(hubClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") }) It("Check that the apply still works if the last applied annotation does not exist", func() { @@ -390,23 +388,23 @@ var _ = Describe("Work Controller", func() { } By("create the work") - work = createWorkWithManifest(testWorkNamespace, cm) - err := k8sClient.Create(ctx, work) + work = createWorkWithManifest(cm) + err := hubClient.Create(ctx, work) Expect(err).Should(Succeed()) By("wait for the work to be applied") - waitForWorkToApply(work.GetName(), work.GetNamespace()) + waitForWorkToApply(work.GetName()) By("Check applied configMap") appliedCM := verifyAppliedConfigMap(cm) By("Delete the last applied annotation from the current resource") delete(appliedCM.Annotations, fleetv1beta1.LastAppliedConfigAnnotation) - Expect(k8sClient.Update(ctx, appliedCM)).Should(Succeed()) + Expect(memberClient.Update(ctx, appliedCM)).Should(Succeed()) By("Get the last applied config map and verify it does not have the last applied annotation") var modifiedCM corev1.ConfigMap - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &modifiedCM)).Should(Succeed()) + Expect(memberClient.Get(ctx, types.NamespacedName{Name: cm.GetName(), Namespace: cm.GetNamespace()}, &modifiedCM)).Should(Succeed()) Expect(modifiedCM.Annotations[fleetv1beta1.LastAppliedConfigAnnotation]).Should(BeEmpty()) By("Modify the manifest") @@ -418,20 +416,20 @@ var _ = Describe("Work Controller", func() { cm.Labels["labelKey3"] = "added-back-by-manifest" By("update the work") - resultWork := waitForWorkToApply(work.GetName(), work.GetNamespace()) + resultWork := waitForWorkToApply(work.GetName()) rawCM, err := json.Marshal(cm) Expect(err).Should(Succeed()) resultWork.Spec.Workload.Manifests[0].Raw = rawCM - Expect(k8sClient.Update(ctx, resultWork)).Should(Succeed()) + Expect(hubClient.Update(ctx, resultWork)).Should(Succeed()) By("wait for the change of the work to be applied") - waitForWorkToApply(work.GetName(), work.GetNamespace()) + waitForWorkToApply(work.GetName()) By("Check applied configMap is modified even without the last applied annotation") - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cmName, Namespace: cmNamespace}, appliedCM)).Should(Succeed()) + Expect(memberClient.Get(ctx, types.NamespacedName{Name: cmName, Namespace: cmNamespace}, appliedCM)).Should(Succeed()) verifyAppliedConfigMap(cm) - Expect(k8sClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") + Expect(hubClient.Delete(ctx, work)).Should(Succeed(), "Failed to deleted the work") }) It("Check that failed to apply manifest has the proper identification", func() { @@ -451,14 +449,14 @@ var _ = Describe("Work Controller", func() { Foo: "foo", }, } - work = createWorkWithManifest(testWorkNamespace, testResource) - err := k8sClient.Create(context.Background(), work) + work = createWorkWithManifest(testResource) + err := hubClient.Create(context.Background(), work) Expect(err).ToNot(HaveOccurred()) By("wait for the work to be applied, apply condition set to failed") var resultWork fleetv1beta1.Work Eventually(func() bool { - err := k8sClient.Get(context.Background(), types.NamespacedName{Name: work.Name, Namespace: work.GetNamespace()}, &resultWork) + err := hubClient.Get(context.Background(), types.NamespacedName{Name: work.Name, Namespace: work.GetNamespace()}, &resultWork) if err != nil { return false } @@ -470,7 +468,7 @@ var _ = Describe("Work Controller", func() { return false } return true - }, timeout, interval).Should(BeTrue()) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) expectedResourceID := fleetv1beta1.WorkResourceIdentifier{ Ordinal: 0, Group: testv1alpha1.GroupVersion.Group, @@ -491,7 +489,7 @@ var _ = Describe("Work Controller", func() { AfterEach(func() { for _, staleWork := range works { - err := k8sClient.Delete(context.Background(), staleWork) + err := hubClient.Delete(context.Background(), staleWork) Expect(err).ToNot(HaveOccurred()) } }) @@ -523,9 +521,9 @@ var _ = Describe("Work Controller", func() { Data: data, } // make sure we can call join as many as possible - Expect(workController.Join(ctx)).Should(Succeed()) - work = createWorkWithManifest(testWorkNamespace, cm) - err := k8sClient.Create(ctx, work) + Expect(workApplier.Join(ctx)).Should(Succeed()) + work = createWorkWithManifest(cm) + err := hubClient.Create(ctx, work) Expect(err).ToNot(HaveOccurred()) By(fmt.Sprintf("created the work = %s", work.GetName())) works = append(works, work) @@ -538,8 +536,8 @@ var _ = Describe("Work Controller", func() { By("mark the work controller as leave") Eventually(func() error { - return workController.Leave(ctx) - }, timeout, interval).Should(Succeed()) + return workApplier.Leave(ctx) + }, eventuallyDuration, eventuallyInterval).Should(Succeed()) By("make sure the manifests have no finalizer and its status match the member cluster") newData := map[string]string{ @@ -551,13 +549,13 @@ var _ = Describe("Work Controller", func() { } for i := 0; i < numWork; i++ { var resultWork fleetv1beta1.Work - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: works[i].GetName(), Namespace: testWorkNamespace}, &resultWork)).Should(Succeed()) + Expect(hubClient.Get(ctx, types.NamespacedName{Name: works[i].GetName(), Namespace: memberReservedNSName}, &resultWork)).Should(Succeed()) Expect(controllerutil.ContainsFinalizer(&resultWork, fleetv1beta1.WorkFinalizer)).Should(BeFalse()) // make sure that leave can be called as many times as possible // The work may be updated and may hit 409 error. Eventually(func() error { - return workController.Leave(ctx) - }, timeout, interval).Should(Succeed(), "Failed to set the work controller to leave") + return workApplier.Leave(ctx) + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to set the work controller to leave") By(fmt.Sprintf("change the work = %s", work.GetName())) cm = &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ @@ -573,7 +571,7 @@ var _ = Describe("Work Controller", func() { rawCM, err := json.Marshal(cm) Expect(err).Should(Succeed()) resultWork.Spec.Workload.Manifests[0].Raw = rawCM - Expect(k8sClient.Update(ctx, &resultWork)).Should(Succeed()) + Expect(hubClient.Update(ctx, &resultWork)).Should(Succeed()) } By("make sure the update in the work is not picked up") @@ -581,7 +579,7 @@ var _ = Describe("Work Controller", func() { for i := 0; i < numWork; i++ { By(fmt.Sprintf("updated the work = %s", works[i].GetName())) var resultWork fleetv1beta1.Work - err := k8sClient.Get(context.Background(), types.NamespacedName{Name: works[i].GetName(), Namespace: testWorkNamespace}, &resultWork) + err := hubClient.Get(context.Background(), types.NamespacedName{Name: works[i].GetName(), Namespace: memberReservedNSName}, &resultWork) Expect(err).Should(Succeed()) Expect(controllerutil.ContainsFinalizer(&resultWork, fleetv1beta1.WorkFinalizer)).Should(BeFalse()) applyCond := meta.FindStatusCondition(resultWork.Status.Conditions, fleetv1beta1.WorkConditionTypeApplied) @@ -589,24 +587,222 @@ var _ = Describe("Work Controller", func() { return false } By("check if the config map is not changed") - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cmNames[i], Namespace: cmNamespace}, &configMap)).Should(Succeed()) + Expect(memberClient.Get(ctx, types.NamespacedName{Name: cmNames[i], Namespace: cmNamespace}, &configMap)).Should(Succeed()) Expect(cmp.Diff(configMap.Data, data)).Should(BeEmpty()) } return true - }, timeout, interval).Should(BeTrue()) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) By("enable the work controller again") - Expect(workController.Join(ctx)).Should(Succeed()) + Expect(workApplier.Join(ctx)).Should(Succeed()) By("make sure the work change get picked up") for i := 0; i < numWork; i++ { - resultWork := waitForWorkToApply(works[i].GetName(), works[i].GetNamespace()) + resultWork := waitForWorkToApply(works[i].GetName()) Expect(len(resultWork.Status.ManifestConditions)).Should(Equal(1)) Expect(meta.IsStatusConditionTrue(resultWork.Status.ManifestConditions[0].Conditions, fleetv1beta1.WorkConditionTypeApplied)).Should(BeTrue()) By("the work is applied, check if the applied config map is updated") - Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cmNames[i], Namespace: cmNamespace}, &configMap)).Should(Succeed()) + Expect(memberClient.Get(ctx, types.NamespacedName{Name: cmNames[i], Namespace: cmNamespace}, &configMap)).Should(Succeed()) Expect(cmp.Diff(configMap.Data, newData)).Should(BeEmpty()) } }) }) }) + +var _ = Describe("Work Status Reconciler", func() { + var resourceNamespace string + var work *fleetv1beta1.Work + var cm, cm2 *corev1.ConfigMap + var rns corev1.Namespace + + BeforeEach(func() { + resourceNamespace = utilrand.String(5) + rns = corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: resourceNamespace, + }, + } + Expect(memberClient.Create(context.Background(), &rns)).Should(Succeed(), "Failed to create the resource namespace") + + // Create the Work object with some type of Manifest resource. + cm = &corev1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ConfigMap", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "configmap-" + utilrand.String(5), + Namespace: resourceNamespace, + }, + Data: map[string]string{ + "test": "test", + }, + } + cm2 = &corev1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ConfigMap", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "configmap2-" + utilrand.String(5), + Namespace: resourceNamespace, + }, + Data: map[string]string{ + "test": "test", + }, + } + + By("Create work that contains two configMaps") + work = &fleetv1beta1.Work{ + ObjectMeta: metav1.ObjectMeta{ + Name: "work-" + utilrand.String(5), + Namespace: memberReservedNSName, + }, + Spec: fleetv1beta1.WorkSpec{ + Workload: fleetv1beta1.WorkloadTemplate{ + Manifests: []fleetv1beta1.Manifest{ + { + RawExtension: runtime.RawExtension{Object: cm}, + }, + { + RawExtension: runtime.RawExtension{Object: cm2}, + }, + }, + }, + }, + } + }) + + AfterEach(func() { + // TODO: Ensure that all resources are being deleted. + Expect(hubClient.Delete(context.Background(), work)).Should(Succeed()) + Expect(memberClient.Delete(context.Background(), &rns)).Should(Succeed()) + }) + + It("Should delete the manifest from the member cluster after it is removed from work", func() { + By("Apply the work") + Expect(hubClient.Create(context.Background(), work)).ToNot(HaveOccurred()) + + By("Make sure that the work is applied") + currentWork := waitForWorkToApply(work.Name) + var appliedWork fleetv1beta1.AppliedWork + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) + + By("Remove configMap 2 from the work") + currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ + { + RawExtension: runtime.RawExtension{Object: cm}, + }, + } + Expect(hubClient.Update(context.Background(), currentWork)).Should(Succeed()) + + By("Verify that the resource is removed from the cluster") + Eventually(func() bool { + var configMap corev1.ConfigMap + return apierrors.IsNotFound(memberClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap)) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + + By("Verify that the appliedWork status is correct") + Eventually(func() bool { + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + return len(appliedWork.Status.AppliedResources) == 1 + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + Expect(appliedWork.Status.AppliedResources[0].Name).Should(Equal(cm.GetName())) + Expect(appliedWork.Status.AppliedResources[0].Namespace).Should(Equal(cm.GetNamespace())) + Expect(appliedWork.Status.AppliedResources[0].Version).Should(Equal(cm.GetObjectKind().GroupVersionKind().Version)) + Expect(appliedWork.Status.AppliedResources[0].Group).Should(Equal(cm.GetObjectKind().GroupVersionKind().Group)) + Expect(appliedWork.Status.AppliedResources[0].Kind).Should(Equal(cm.GetObjectKind().GroupVersionKind().Kind)) + }) + + It("Should delete the manifest from the member cluster even if there is apply failure", func() { + By("Apply the work") + Expect(hubClient.Create(context.Background(), work)).ToNot(HaveOccurred()) + + By("Make sure that the work is applied") + currentWork := waitForWorkToApply(work.Name) + var appliedWork fleetv1beta1.AppliedWork + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) + + By("replace configMap with a bad object from the work") + testResource := &testv1alpha1.TestResource{ + TypeMeta: metav1.TypeMeta{ + APIVersion: testv1alpha1.GroupVersion.String(), + Kind: "TestResource", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "testresource-" + utilrand.String(5), + // to ensure the resource is not applied. + Namespace: "random-test-namespace", + }, + } + currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ + { + RawExtension: runtime.RawExtension{Object: testResource}, + }, + } + Expect(hubClient.Update(context.Background(), currentWork)).Should(Succeed()) + + By("Verify that the configMaps are removed from the cluster even if the new resource didn't apply") + Eventually(func() bool { + var configMap corev1.ConfigMap + return apierrors.IsNotFound(memberClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap)) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + + Eventually(func() bool { + var configMap corev1.ConfigMap + return apierrors.IsNotFound(memberClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap)) + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + + By("Verify that the appliedWork status is correct") + Eventually(func() bool { + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + return len(appliedWork.Status.AppliedResources) == 0 + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + }) + + It("Test the order of the manifest in the work alone does not trigger any operation in the member cluster", func() { + By("Apply the work") + Expect(hubClient.Create(context.Background(), work)).ToNot(HaveOccurred()) + + By("Make sure that the work is applied") + currentWork := waitForWorkToApply(work.Name) + var appliedWork fleetv1beta1.AppliedWork + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + Expect(len(appliedWork.Status.AppliedResources)).Should(Equal(2)) + + By("Make sure that the manifests exist on the member cluster") + Eventually(func() bool { + var configMap corev1.ConfigMap + return memberClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap) == nil && + memberClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap) == nil + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + + By("Change the order of the two configs in the work") + currentWork.Spec.Workload.Manifests = []fleetv1beta1.Manifest{ + { + RawExtension: runtime.RawExtension{Object: cm2}, + }, + { + RawExtension: runtime.RawExtension{Object: cm}, + }, + } + Expect(hubClient.Update(context.Background(), currentWork)).Should(Succeed()) + + By("Verify that nothing is removed from the cluster") + Consistently(func() bool { + var configMap corev1.ConfigMap + return memberClient.Get(context.Background(), types.NamespacedName{Name: cm2.Name, Namespace: resourceNamespace}, &configMap) == nil && + memberClient.Get(context.Background(), types.NamespacedName{Name: cm.Name, Namespace: resourceNamespace}, &configMap) == nil + }, consistentlyDuration, consistentlyInterval).Should(BeTrue()) + + By("Verify that the appliedWork status is correct") + Eventually(func() bool { + Expect(memberClient.Get(context.Background(), types.NamespacedName{Name: work.Name}, &appliedWork)).Should(Succeed()) + return len(appliedWork.Status.AppliedResources) == 2 + }, eventuallyDuration, eventuallyInterval).Should(BeTrue()) + Expect(appliedWork.Status.AppliedResources[0].Name).Should(Equal(cm2.GetName())) + Expect(appliedWork.Status.AppliedResources[1].Name).Should(Equal(cm.GetName())) + }) +}) diff --git a/pkg/controllers/workapplier/controller_integration_test.go b/pkg/controllers/workapplier/controller_integration_test.go index 83454486e..0fa36a4da 100644 --- a/pkg/controllers/workapplier/controller_integration_test.go +++ b/pkg/controllers/workapplier/controller_integration_test.go @@ -34,9 +34,9 @@ const ( const ( eventuallyDuration = time.Second * 30 - eventuallyInternal = time.Second * 1 + eventuallyInterval = time.Second * 1 consistentlyDuration = time.Second * 5 - consistentlyInternal = time.Millisecond * 500 + consistentlyInterval = time.Millisecond * 500 ) var ( @@ -408,7 +408,7 @@ func cleanupWorkObject(workName string) { } return nil } - Eventually(workRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the Work object") + Eventually(workRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the Work object") } func appliedWorkRemovedActual(workName string) func() error { @@ -499,12 +499,12 @@ var _ = Describe("applying manifests", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -512,13 +512,13 @@ var _ = Describe("applying manifests", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") // Ensure that the Deployment object has been applied as expected. regularDeploymentObjectAppliedActual := regularDeploymentObjectAppliedActual(nsName, deployName, appliedWorkOwnerRef) - Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the deployment object") + Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the deployment object") Expect(memberClient.Get(ctx, client.ObjectKey{Namespace: nsName, Name: deployName}, regularDeploy)).To(Succeed(), "Failed to retrieve the Deployment object") }) @@ -594,7 +594,7 @@ var _ = Describe("applying manifests", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -626,7 +626,7 @@ var _ = Describe("applying manifests", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -635,10 +635,10 @@ var _ = Describe("applying manifests", func() { // Ensure that all applied manifests have been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") regularDeployRemovedActual := regularDeployRemovedActual(nsName, deployName) - Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the deployment object") + Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -674,12 +674,12 @@ var _ = Describe("applying manifests", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -687,13 +687,13 @@ var _ = Describe("applying manifests", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") // Ensure that the Deployment object has been applied as expected. regularDeploymentObjectAppliedActual := regularDeploymentObjectAppliedActual(nsName, deployName, appliedWorkOwnerRef) - Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the deployment object") + Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the deployment object") Expect(memberClient.Get(ctx, client.ObjectKey{Namespace: nsName, Name: deployName}, regularDeploy)).To(Succeed(), "Failed to retrieve the Deployment object") }) @@ -769,7 +769,7 @@ var _ = Describe("applying manifests", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -801,7 +801,7 @@ var _ = Describe("applying manifests", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can delete some manifests", func() { @@ -817,7 +817,7 @@ var _ = Describe("applying manifests", func() { It("should garbage collect removed manifests", func() { deployRemovedActual := regularDeployRemovedActual(nsName, deployName) - Eventually(deployRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the deployment object") + Eventually(deployRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the deployment object") }) It("should update the Work object status", func() { @@ -862,7 +862,7 @@ var _ = Describe("applying manifests", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -882,7 +882,7 @@ var _ = Describe("applying manifests", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -891,7 +891,7 @@ var _ = Describe("applying manifests", func() { // Ensure that all applied manifests have been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -939,12 +939,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -952,13 +952,13 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") // Ensure that the Deployment object has been applied as expected. regularDeploymentObjectAppliedActual := regularDeploymentObjectAppliedActual(nsName, deployName, appliedWorkOwnerRef) - Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the deployment object") + Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the deployment object") Expect(memberClient.Get(ctx, client.ObjectKey{Namespace: nsName, Name: deployName}, regularDeploy)).To(Succeed(), "Failed to retrieve the Deployment object") }) @@ -1032,7 +1032,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -1064,7 +1064,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -1073,10 +1073,10 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that all applied manifests have been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") regularDeployRemovedActual := regularDeployRemovedActual(nsName, deployName) - Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the deployment object") + Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -1132,12 +1132,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -1176,7 +1176,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to take over the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to take over the NS object") }) It("should not take over some objects", func() { @@ -1234,7 +1234,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("deployment diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to leave the Deployment object alone") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to leave the Deployment object alone") }) It("should update the Work object status", func() { @@ -1312,7 +1312,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -1332,7 +1332,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -1341,11 +1341,11 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // Ensure that the Deployment object has been left alone. regularDeployNotRemovedActual := regularDeployNotRemovedActual(nsName, deployName) - Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to remove the deployment object") + Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -1400,12 +1400,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") }) It("should not take over any object", func() { @@ -1438,7 +1438,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to take over the NS object") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to take over the NS object") // Verify that the Deployment object has not been taken over. wantDeploy := deploy.DeepCopy() @@ -1494,7 +1494,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("deployment diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal, "Failed to leave the Deployment object alone") + }, consistentlyDuration, consistentlyInterval, "Failed to leave the Deployment object alone") }) It("should update the Work object status", func() { @@ -1607,13 +1607,13 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { // No object can be applied, hence no resource are bookkept in the AppliedWork object status. appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, nil) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -1622,11 +1622,11 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // Ensure that the Deployment object has been left alone. regularDeployNotRemovedActual := regularDeployNotRemovedActual(nsName, deployName) - Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to remove the deployment object") + Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -1666,12 +1666,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -1679,13 +1679,13 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") // Ensure that the Deployment object has been applied as expected. regularDeploymentObjectAppliedActual := regularDeploymentObjectAppliedActual(nsName, deployName, appliedWorkOwnerRef) - Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the deployment object") + Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the deployment object") Expect(memberClient.Get(ctx, client.ObjectKey{Namespace: nsName, Name: deployName}, regularDeploy)).To(Succeed(), "Failed to retrieve the Deployment object") }) @@ -1761,7 +1761,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -1793,7 +1793,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -1813,7 +1813,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the Deployment object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the Deployment object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the Deployment object") Eventually(func() error { // Retrieve the NS object. @@ -1833,7 +1833,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) It("should continue to apply some manifest (while preserving drifts in unmanaged fields)", func() { @@ -1870,7 +1870,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to take over the NS object") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to take over the NS object") }) It("should stop applying some objects", func() { @@ -1931,7 +1931,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("deployment diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to leave the Deployment object alone") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to leave the Deployment object alone") }) It("should update the Work object status", func() { @@ -2010,7 +2010,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2030,7 +2030,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -2039,11 +2039,11 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // Ensure that the Deployment object has been left alone. regularDeployNotRemovedActual := regularDeployNotRemovedActual(nsName, deployName) - Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to remove the deployment object") + Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -2077,12 +2077,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -2090,7 +2090,7 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") }) @@ -2137,7 +2137,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2157,7 +2157,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -2179,7 +2179,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) It("should stop applying some objects", func() { @@ -2215,7 +2215,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to leave the NS object alone") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to leave the NS object alone") }) It("should update the Work object status", func() { @@ -2268,13 +2268,13 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { // No object can be applied, hence no resource are bookkept in the AppliedWork object status. appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, nil) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -2283,7 +2283,7 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -2319,12 +2319,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -2332,7 +2332,7 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") }) @@ -2379,7 +2379,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2399,7 +2399,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -2421,7 +2421,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) It("should continue to apply some manifest (while overwriting drifts in managed fields)", func() { @@ -2459,8 +2459,8 @@ var _ = Describe("drift detection and takeover", func() { } return nil } - Eventually(nsOverwrittenActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the NS object") - Consistently(nsOverwrittenActual, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to apply the NS object") + Eventually(nsOverwrittenActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the NS object") + Consistently(nsOverwrittenActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to apply the NS object") }) It("should update the Work object status", func() { @@ -2505,7 +2505,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2525,7 +2525,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -2534,7 +2534,7 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -2569,12 +2569,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -2582,7 +2582,7 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") }) @@ -2629,7 +2629,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2649,7 +2649,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -2671,7 +2671,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) It("should stop applying some objects", func() { @@ -2707,7 +2707,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to leave the NS object alone") + }, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to leave the NS object alone") }) It("should update the Work object status", func() { @@ -2761,13 +2761,13 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { // No object can be applied, hence no resource are bookkept in the AppliedWork object status. appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, nil) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can update the Work object", func() { @@ -2819,7 +2819,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply new manifests") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply new manifests") }) It("should update the Work object status", func() { @@ -2864,7 +2864,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -2884,7 +2884,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -2893,7 +2893,7 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -2928,12 +2928,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -2941,7 +2941,7 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests", func() { // Ensure that the NS object has been applied as expected. regularNSObjectAppliedActual := regularNSObjectAppliedActual(nsName, appliedWorkOwnerRef) - Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the namespace object") + Eventually(regularNSObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the namespace object") Expect(memberClient.Get(ctx, client.ObjectKey{Name: nsName}, regularNS)).To(Succeed(), "Failed to retrieve the NS object") }) @@ -2988,7 +2988,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -3008,7 +3008,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -3030,7 +3030,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) var firstDriftedMustBeforeTimestamp metav1.Time @@ -3086,7 +3086,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") // Track the timestamp that was just after the drift was first detected. firstDriftedMustBeforeTimestamp = metav1.Now() @@ -3111,7 +3111,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("failed to update the NS object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the NS object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the NS object") }) It("should update the Work object status (must track timestamps correctly)", func() { @@ -3165,7 +3165,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &driftObservedMustBeforeTimestamp, &firstDriftedMustBeforeTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) }) @@ -3205,12 +3205,12 @@ var _ = Describe("drift detection and takeover", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -3218,7 +3218,7 @@ var _ = Describe("drift detection and takeover", func() { It("should apply the manifests that haven not been created yet", func() { // Ensure that the Deployment object has been applied as expected. regularDeploymentObjectAppliedActual := regularDeploymentObjectAppliedActual(nsName, deployName, appliedWorkOwnerRef) - Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to apply the deployment object") + Eventually(regularDeploymentObjectAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to apply the deployment object") Expect(memberClient.Get(ctx, client.ObjectKey{Namespace: nsName, Name: deployName}, regularDeploy)).To(Succeed(), "Failed to retrieve the Deployment object") }) @@ -3245,7 +3245,7 @@ var _ = Describe("drift detection and takeover", func() { return fmt.Errorf("namespace diff (-got +want):\n%s", diff) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to leave the NS object alone") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to leave the NS object alone") }) It("can mark the deployment as available", func() { @@ -3313,7 +3313,7 @@ var _ = Describe("drift detection and takeover", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -3334,7 +3334,7 @@ var _ = Describe("drift detection and takeover", func() { } appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -3343,10 +3343,10 @@ var _ = Describe("drift detection and takeover", func() { // Ensure that all applied manifests have been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") regularDeployRemovedActual := regularDeployRemovedActual(nsName, deployName) - Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the deployment object") + Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -3379,12 +3379,12 @@ var _ = Describe("report diff", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -3392,7 +3392,7 @@ var _ = Describe("report diff", func() { It("should not apply the manifests", func() { // Ensure that the NS object has not been applied. regularNSObjectNotAppliedActual := regularNSObjectNotAppliedActual(nsName) - Eventually(regularNSObjectNotAppliedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to avoid applying the namespace object") + Eventually(regularNSObjectNotAppliedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to avoid applying the namespace object") }) It("should update the Work object status", func() { @@ -3434,13 +3434,13 @@ var _ = Describe("report diff", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { // Prepare the status information. appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, nil) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -3449,7 +3449,7 @@ var _ = Describe("report diff", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -3495,12 +3495,12 @@ var _ = Describe("report diff", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") appliedWorkOwnerRef = prepareAppliedWorkOwnerRef(workName) }) @@ -3566,8 +3566,8 @@ var _ = Describe("report diff", func() { return nil } - Eventually(deployOwnedButNotApplied, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to own the Deployment object without applying the manifest") - Consistently(deployOwnedButNotApplied, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to own the Deployment object without applying the manifest") + Eventually(deployOwnedButNotApplied, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to own the Deployment object without applying the manifest") + Consistently(deployOwnedButNotApplied, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to own the Deployment object without applying the manifest") // Verify that Fleet has assumed ownership of the NS object. wantNS := ns.DeepCopy() @@ -3595,8 +3595,8 @@ var _ = Describe("report diff", func() { } return nil } - Eventually(nsOwnedButNotApplied, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to own the NS object without applying the manifest") - Consistently(nsOwnedButNotApplied, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to own the NS object without applying the manifest") + Eventually(nsOwnedButNotApplied, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to own the NS object without applying the manifest") + Consistently(nsOwnedButNotApplied, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to own the NS object without applying the manifest") }) It("should update the Work object status", func() { @@ -3663,7 +3663,7 @@ var _ = Describe("report diff", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -3671,7 +3671,7 @@ var _ = Describe("report diff", func() { var appliedResourceMeta []fleetv1beta1.AppliedResourceMeta appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) It("can make changes to the objects", func() { @@ -3691,7 +3691,7 @@ var _ = Describe("report diff", func() { return fmt.Errorf("failed to update the Deployment object: %w", err) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update the Deployment object") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the Deployment object") }) It("can mark the deployment as available", func() { @@ -3753,7 +3753,7 @@ var _ = Describe("report diff", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, &noLaterThanTimestamp, &noLaterThanTimestamp) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -3761,7 +3761,7 @@ var _ = Describe("report diff", func() { var appliedResourceMeta []fleetv1beta1.AppliedResourceMeta appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -3770,11 +3770,11 @@ var _ = Describe("report diff", func() { // Ensure that the AppliedWork object has been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") // Ensure that the Deployment object has been left alone. regularDeployNotRemovedActual := regularDeployNotRemovedActual(nsName, deployName) - Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInternal).Should(Succeed(), "Failed to remove the deployment object") + Consistently(regularDeployNotRemovedActual, consistentlyDuration, consistentlyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. @@ -3820,12 +3820,12 @@ var _ = Describe("report diff", func() { It("should add cleanup finalizer to the Work object", func() { finalizerAddedActual := workFinalizerAddedActual(workName) - Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") + Eventually(finalizerAddedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to add cleanup finalizer to the Work object") }) It("should prepare an AppliedWork object", func() { appliedWorkCreatedActual := appliedWorkCreatedActual(workName) - Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to prepare an AppliedWork object") + Eventually(appliedWorkCreatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to prepare an AppliedWork object") }) It("should not apply any manifest", func() { @@ -3851,7 +3851,7 @@ var _ = Describe("report diff", func() { } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to leave the NS object alone") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to leave the NS object alone") // Verify that the Deployment manifest has not been applied. Eventually(func() error { @@ -3902,7 +3902,7 @@ var _ = Describe("report diff", func() { return fmt.Errorf("deployment diff (-got +want):\n%s", diff) } return nil - }, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to leave the Deployment object alone") + }, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to leave the Deployment object alone") }) It("should update the Work object status", func() { @@ -3965,7 +3965,7 @@ var _ = Describe("report diff", func() { } workStatusUpdatedActual := workStatusUpdated(workName, workConds, manifestConds, nil, nil) - Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update work status") + Eventually(workStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update work status") }) It("should update the AppliedWork object status", func() { @@ -3973,7 +3973,7 @@ var _ = Describe("report diff", func() { var appliedResourceMeta []fleetv1beta1.AppliedResourceMeta appliedWorkStatusUpdatedActual := appliedWorkStatusUpdated(workName, appliedResourceMeta) - Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to update appliedWork status") + Eventually(appliedWorkStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update appliedWork status") }) AfterAll(func() { @@ -3982,10 +3982,10 @@ var _ = Describe("report diff", func() { // Ensure that all applied manifests have been removed. appliedWorkRemovedActual := appliedWorkRemovedActual(workName) - Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the AppliedWork object") + Eventually(appliedWorkRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the AppliedWork object") regularDeployRemovedActual := regularDeployRemovedActual(nsName, deployName) - Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInternal).Should(Succeed(), "Failed to remove the deployment object") + Eventually(regularDeployRemovedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to remove the deployment object") // The environment prepared by the envtest package does not support namespace // deletion; consequently this test suite would not attempt so verify its deletion. diff --git a/pkg/controllers/workapplier/suite_test.go b/pkg/controllers/workapplier/suite_test.go index fc4542dd8..ab93847d4 100644 --- a/pkg/controllers/workapplier/suite_test.go +++ b/pkg/controllers/workapplier/suite_test.go @@ -8,7 +8,6 @@ package workapplier import ( "context" "flag" - "os" "path/filepath" "testing" "time" @@ -49,15 +48,6 @@ var ( ctx context.Context cancel context.CancelFunc - - // Temporary variables for migrated integration tests. - tmpEnv *envtest.Environment - tmpCfg *rest.Config - k8sClient client.Client - tmpMgr manager.Manager - workController *Reconciler - - testWorkNamespace = "test-work-namespace" ) const ( @@ -172,71 +162,6 @@ var _ = BeforeSuite(func() { Expect(workApplier.Join(ctx)).To(Succeed()) Expect(hubMgr.Start(ctx)).To(Succeed()) }() - - // Temporary setup for migrated integration tests. - tmpEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{ - filepath.Join("../../../", "config", "crd", "bases"), - filepath.Join("../../../", "test", "manifests"), - }, - } - - tmpCfg, err = tmpEnv.Start() - Expect(err).ToNot(HaveOccurred()) - Expect(tmpCfg).ToNot(BeNil()) - - k8sClient, err = client.New(tmpCfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).ToNot(HaveOccurred()) - - workNamespace := corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: testWorkNamespace, - }, - } - err = k8sClient.Create(context.Background(), &workNamespace) - Expect(err).ToNot(HaveOccurred()) - - tmpMgr, err = ctrl.NewManager(tmpCfg, ctrl.Options{ - Scheme: scheme.Scheme, - Metrics: server.Options{ - BindAddress: "0", - }, - Cache: cache.Options{ - DefaultNamespaces: map[string]cache.Config{ - testWorkNamespace: {}, - }, - }, - Logger: textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(4))), - }) - Expect(err).ToNot(HaveOccurred()) - - tmpSpokeDynamicClient, err := dynamic.NewForConfig(tmpCfg) - Expect(err).ToNot(HaveOccurred()) - - tmpSpokeClient, err := client.New(tmpCfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).ToNot(HaveOccurred()) - - workController = NewReconciler( - tmpMgr.GetClient(), - testWorkNamespace, - tmpSpokeDynamicClient, - tmpSpokeClient, - tmpSpokeClient.RESTMapper(), - tmpMgr.GetEventRecorderFor("work-applier"), - maxConcurrentReconciles, - workerCount, - time.Second*5, - time.Second*5, - ) - Expect(workController.SetupWithManager(tmpMgr)).To(Succeed()) - Expect(workController.Join(ctx)).To(Succeed()) - - go func() { - if err = tmpMgr.Start(ctx); err != nil { - os.Exit(1) - } - Expect(err).ToNot(HaveOccurred()) - }() }) var _ = AfterSuite(func() { @@ -246,7 +171,4 @@ var _ = AfterSuite(func() { By("Tearing down the test environment") Expect(hubEnv.Stop()).To(Succeed()) Expect(memberEnv.Stop()).To(Succeed()) - - // Temporary setup for migrated integration tests. - Expect(tmpEnv.Stop()).To(Succeed()) })