From 0e9a3ceb3b9d7af3ceeb99269d6b612d80eba7b0 Mon Sep 17 00:00:00 2001 From: wyike <77846369+wangyikewxgm@users.noreply.github.com> Date: Fri, 26 Mar 2021 15:46:01 +0800 Subject: [PATCH] fix unstable appcontext test (#1312) --- test/e2e-test/appcontext_test.go | 48 ++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/test/e2e-test/appcontext_test.go b/test/e2e-test/appcontext_test.go index 82aebd12f..2a2f04f06 100644 --- a/test/e2e-test/appcontext_test.go +++ b/test/e2e-test/appcontext_test.go @@ -221,9 +221,19 @@ var _ = Describe("Test applicationContext reconcile", func() { }, time.Second*60, time.Millisecond*300).Should(BeNil()) By("Test revision have both workload and trait , switch AppContext to revision2") - Expect(k8sClient.Get(ctx, key, appContext)).Should(BeNil()) - appContext.Spec.ApplicationRevisionName = arName2 - Expect(k8sClient.Update(ctx, appContext)).Should(Succeed()) + Eventually(func() error { + updateContext := new(v1alpha2.ApplicationContext) + err := k8sClient.Get(ctx, key, updateContext) + if err != nil { + return err + } + updateContext.Spec.ApplicationRevisionName = arName2 + err = k8sClient.Update(ctx, updateContext) + if err != nil { + return err + } + return nil + }, time.Second*60, time.Microsecond*300).Should(BeNil()) Eventually(func() error { appCtx := new(v1alpha2.ApplicationContext) err := k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: appContextName}, appCtx) @@ -276,9 +286,19 @@ var _ = Describe("Test applicationContext reconcile", func() { Expect(k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: arName1}, ar1)).Should(BeNil()) ar1.Spec.ApplicationConfiguration = util.Object2RawExtension(ac1) Expect(k8sClient.Update(ctx, ar1)).Should(Succeed()) - Expect(k8sClient.Get(ctx, key, appContext)).Should(BeNil()) - appContext.Spec.ApplicationRevisionName = arName1 - Expect(k8sClient.Update(ctx, appContext)).Should(Succeed()) + Eventually(func() error { + updateContext := new(v1alpha2.ApplicationContext) + err := k8sClient.Get(ctx, key, updateContext) + if err != nil { + return err + } + updateContext.Spec.ApplicationRevisionName = arName1 + err = k8sClient.Update(ctx, updateContext) + if err != nil { + return err + } + return nil + }, time.Second*60, time.Microsecond*300).Should(BeNil()) Eventually(func() error { mt := new(v1alpha2.ManualScalerTrait) err := k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: traitName1}, mt) @@ -297,9 +317,19 @@ var _ = Describe("Test applicationContext reconcile", func() { ac2.Spec.Components[0].Traits = []v1alpha2.ComponentTrait{} ar1.Spec.ApplicationConfiguration = util.Object2RawExtension(ac2) Expect(k8sClient.Update(ctx, ar2)).Should(BeNil()) - Expect(k8sClient.Get(ctx, key, appContext)).Should(BeNil()) - appContext.Spec.ApplicationRevisionName = arName2 - Expect(k8sClient.Update(ctx, appContext)).Should(Succeed()) + Eventually(func() error { + updateContext := new(v1alpha2.ApplicationContext) + err := k8sClient.Get(ctx, key, updateContext) + if err != nil { + return err + } + updateContext.Spec.ApplicationRevisionName = arName2 + err = k8sClient.Update(ctx, updateContext) + if err != nil { + return err + } + return nil + }, time.Second*60, time.Microsecond*300).Should(BeNil()) Eventually(func() error { mt := new(v1alpha2.ManualScalerTrait) return k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: traitName2}, mt)