From 0f4a815fdd89368d1deb822bf9d6ad71951e3ccf Mon Sep 17 00:00:00 2001 From: Yang Le Date: Thu, 21 May 2020 11:43:45 +0800 Subject: [PATCH] Enable status condition checking --- test/integration/util/assertion.go | 2 +- test/integration/work_test.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/integration/util/assertion.go b/test/integration/util/assertion.go index a851c7491..39d18d838 100644 --- a/test/integration/util/assertion.go +++ b/test/integration/util/assertion.go @@ -29,7 +29,7 @@ func AssertWorkCondition(namespace, name string, workClient workclientset.Interf } // check work status condition - return HaveCondition(work.Status.Conditions, string(workapiv1.WorkApplied), metav1.ConditionTrue) + return HaveCondition(work.Status.Conditions, expectedType, expectedWorkStatus) }, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue()) } diff --git a/test/integration/work_test.go b/test/integration/work_test.go index fded151f5..521a1572f 100644 --- a/test/integration/work_test.go +++ b/test/integration/work_test.go @@ -72,16 +72,19 @@ var _ = ginkgo.Describe("ManifestWork", func() { ginkgo.It("should create work and then apply it successfully", func() { util.AssertManifestsApplied(manifests, spokeKubeClient, eventuallyTimeout, eventuallyInterval) - /* comment this block until PR work/8 (https://github.com/open-cluster-management/work/pull/8) is merged util.AssertWorkCondition(work.Namespace, work.Name, hubWorkClient, string(workapiv1.WorkApplied), metav1.ConditionTrue, []metav1.ConditionStatus{metav1.ConditionTrue}, eventuallyTimeout, eventuallyInterval) - */ }) ginkgo.It("should update work and then apply it successfully", func() { + util.AssertWorkCondition(work.Namespace, work.Name, hubWorkClient, string(workapiv1.WorkApplied), metav1.ConditionTrue, + []metav1.ConditionStatus{metav1.ConditionTrue}, eventuallyTimeout, eventuallyInterval) + newManifests := []workapiv1.Manifest{ util.ToManifest(util.NewConfigmap(o.SpokeClusterName, "cm2", map[string]string{"x": "y"})), } + work, err = hubWorkClient.WorkV1().ManifestWorks(o.SpokeClusterName).Get(context.Background(), work.Name, metav1.GetOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) work.Spec.Workload.Manifests = newManifests work, err = hubWorkClient.WorkV1().ManifestWorks(o.SpokeClusterName).Update(context.Background(), work, metav1.UpdateOptions{}) @@ -113,20 +116,23 @@ var _ = ginkgo.Describe("ManifestWork", func() { ginkgo.It("should create work and then apply it successfully", func() { util.AssertManifestsApplied(manifests[1:], spokeKubeClient, eventuallyTimeout, eventuallyInterval) - /* comment this block until PR work/8 (https://github.com/open-cluster-management/work/pull/8) is merged - util.AssertWorkCondition(work.Namespace, work.Name, hubWorkClient, string(workapiv1.WorkApplied), metav1.ConditionTrue, + util.AssertWorkCondition(work.Namespace, work.Name, hubWorkClient, string(workapiv1.WorkApplied), metav1.ConditionFalse, []metav1.ConditionStatus{metav1.ConditionFalse, metav1.ConditionTrue, metav1.ConditionTrue}, eventuallyTimeout, eventuallyInterval) - */ }) ginkgo.It("should update work and then apply it successfully", func() { + util.AssertWorkCondition(work.Namespace, work.Name, hubWorkClient, string(workapiv1.WorkApplied), metav1.ConditionFalse, + []metav1.ConditionStatus{metav1.ConditionFalse, metav1.ConditionTrue, metav1.ConditionTrue}, eventuallyTimeout, eventuallyInterval) + newManifests := []workapiv1.Manifest{ util.ToManifest(util.NewConfigmap(o.SpokeClusterName, "cm1", map[string]string{"a": "b"})), util.ToManifest(util.NewConfigmap(o.SpokeClusterName, "cm2", map[string]string{"x": "y"})), util.ToManifest(util.NewConfigmap(o.SpokeClusterName, "cm3", map[string]string{"e": "f"})), } - work.Spec.Workload.Manifests = newManifests + work, err = hubWorkClient.WorkV1().ManifestWorks(o.SpokeClusterName).Get(context.Background(), work.Name, metav1.GetOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + work.Spec.Workload.Manifests = newManifests work, err = hubWorkClient.WorkV1().ManifestWorks(o.SpokeClusterName).Update(context.Background(), work, metav1.UpdateOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred())