Skip to content

Commit

Permalink
Merge pull request #2819 from jwcesign/failing-test-fix
Browse files Browse the repository at this point in the history
e2e: wait till the informer's cache is synced in karmada-controller
  • Loading branch information
karmada-bot committed Nov 17, 2022
2 parents a5b41fa + 8bda9f8 commit 594ad9f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions test/e2e/clusterpropagationpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ 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)
lowerPriorityMatchName = deploymentNamePrefix + "lowerprioritymatchname" + rand.String(RandomStrLength)
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})
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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() {
Expand Down
18 changes: 10 additions & 8 deletions test/e2e/propagationpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -784,15 +785,15 @@ 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
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})
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 594ad9f

Please sign in to comment.