From 8bda9f85d2f976c3a2eeb1eb9760ebbf4e1472ab Mon Sep 17 00:00:00 2001 From: jwcesign Date: Thu, 17 Nov 2022 10:20:31 +0800 Subject: [PATCH] e2e: wait till the informer's cache is synced in karmada-controller Signed-off-by: jwcesign --- test/e2e/clusterpropagationpolicy_test.go | 18 ++++++++++-------- test/e2e/propagationpolicy_test.go | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/test/e2e/clusterpropagationpolicy_test.go b/test/e2e/clusterpropagationpolicy_test.go index b2c922e13..1b6d21d7d 100644 --- a/test/e2e/clusterpropagationpolicy_test.go +++ b/test/e2e/clusterpropagationpolicy_test.go @@ -331,8 +331,6 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { var deploymentNamespace, deploymentName string var deployment *appsv1.Deployment var policyHigherPriorityLabelSelector, policyLowerPriorityMatchName, policyImplicitPriorityMatchName *policyv1alpha1.ClusterPropagationPolicy - var priorityLabelKey = "priority" - var priorityLabelValue = "priority" ginkgo.BeforeEach(func() { higherPriorityLabelSelector = deploymentNamePrefix + "higherprioritylabelselector" + rand.String(RandomStrLength) @@ -340,6 +338,8 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { implicitPriorityMatchName = deploymentNamePrefix + "implicitprioritymatchname" + rand.String(RandomStrLength) deploymentNamespace = testNamespace deploymentName = deploymentNamePrefix + rand.String(RandomStrLength) + var priorityLabelKey = "priority" + var priorityLabelValue = "priority" + rand.String(RandomStrLength) deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName) deployment.SetLabels(map[string]string{priorityLabelKey: priorityLabelValue}) @@ -383,8 +383,9 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { framework.CreateClusterPropagationPolicy(karmadaClient, policyLowerPriorityMatchName) framework.CreateClusterPropagationPolicy(karmadaClient, policyImplicitPriorityMatchName) - // Wait policy present in cache - time.Sleep(time.Second) + // Wait till the informer's cache is synced in karmada-controller. + // Note: We tested and find that it takes about 1s before cache synced. + time.Sleep(time.Second * 5) framework.CreateDeployment(kubeClient, deployment) ginkgo.DeferCleanup(func() { @@ -413,14 +414,14 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { var deploymentNamespace, deploymentName string var deployment *appsv1.Deployment var policyExplicitPriorityLabelSelector, policyExplicitPriorityMatchName *policyv1alpha1.ClusterPropagationPolicy - var priorityLabelKey = "priority" - var priorityLabelValue = "priority" ginkgo.BeforeEach(func() { explicitPriorityLabelSelector = deploymentNamePrefix + "explicitprioritylabelselector" + rand.String(RandomStrLength) explicitPriorityMatchName = deploymentNamePrefix + "explicitprioritymatchname" + rand.String(RandomStrLength) deploymentNamespace = testNamespace deploymentName = deploymentNamePrefix + rand.String(RandomStrLength) + var priorityLabelKey = "priority" + var priorityLabelValue = "priority" + rand.String(RandomStrLength) deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName) deployment.SetLabels(map[string]string{priorityLabelKey: priorityLabelValue}) @@ -452,8 +453,9 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { framework.CreateClusterPropagationPolicy(karmadaClient, policyExplicitPriorityLabelSelector) framework.CreateClusterPropagationPolicy(karmadaClient, policyExplicitPriorityMatchName) - // Wait policy present in cache - time.Sleep(time.Second) + // Wait till the informer's cache is synced in karmada-controller. + // Note: We tested and find that it takes about 1s before cache synced. + time.Sleep(time.Second * 5) framework.CreateDeployment(kubeClient, deployment) ginkgo.DeferCleanup(func() { diff --git a/test/e2e/propagationpolicy_test.go b/test/e2e/propagationpolicy_test.go index c7630fc46..9847dcbe1 100644 --- a/test/e2e/propagationpolicy_test.go +++ b/test/e2e/propagationpolicy_test.go @@ -700,8 +700,6 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { var deploymentNamespace, deploymentName string var deployment *appsv1.Deployment var policyHigherPriorityLabelSelector, policyLowerPriorityMatchMatchName, policyImplicitPriorityMatchMatchName *policyv1alpha1.PropagationPolicy - var priorityLabelKey = "priority" - var priorityLabelValue = "priority" ginkgo.BeforeEach(func() { policyNamespace = testNamespace @@ -710,6 +708,8 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { implicitPriorityMatchName = deploymentNamePrefix + "implicitprioritymatchname" + rand.String(RandomStrLength) deploymentNamespace = testNamespace deploymentName = deploymentNamePrefix + rand.String(RandomStrLength) + var priorityLabelKey = "priority" + var priorityLabelValue = "priority" + rand.String(RandomStrLength) deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName) deployment.SetLabels(map[string]string{priorityLabelKey: priorityLabelValue}) @@ -753,8 +753,9 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { framework.CreatePropagationPolicy(karmadaClient, policyLowerPriorityMatchMatchName) framework.CreatePropagationPolicy(karmadaClient, policyImplicitPriorityMatchMatchName) - // Wait policy present in cache - time.Sleep(time.Second) + // Wait till the informer's cache is synced in karmada-controller. + // Note: We tested and find that it takes about 1s before cache synced. + time.Sleep(time.Second * 5) framework.CreateDeployment(kubeClient, deployment) ginkgo.DeferCleanup(func() { @@ -784,8 +785,6 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { var deploymentNamespace, deploymentName string var deployment *appsv1.Deployment var policyExplicitPriorityLabelSelector, policyExplicitPriorityMatchName *policyv1alpha1.PropagationPolicy - var priorityLabelKey = "priority" - var priorityLabelValue = "priority" ginkgo.BeforeEach(func() { policyNamespace = testNamespace @@ -793,6 +792,8 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { explicitPriorityMatchName = deploymentNamePrefix + "explicitprioritymatchname" + rand.String(RandomStrLength) deploymentNamespace = testNamespace deploymentName = deploymentNamePrefix + rand.String(RandomStrLength) + var priorityLabelKey = "priority" + var priorityLabelValue = "priority" + rand.String(RandomStrLength) deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName) deployment.SetLabels(map[string]string{priorityLabelKey: priorityLabelValue}) @@ -824,8 +825,9 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { framework.CreatePropagationPolicy(karmadaClient, policyExplicitPriorityLabelSelector) framework.CreatePropagationPolicy(karmadaClient, policyExplicitPriorityMatchName) - // Wait policy present in cache - time.Sleep(time.Second) + // Wait till the informer's cache is synced in karmada-controller. + // Note: We tested and find that it takes about 1s before cache synced. + time.Sleep(time.Second * 5) framework.CreateDeployment(kubeClient, deployment) ginkgo.DeferCleanup(func() {