Skip to content

Commit

Permalink
fix pdb collection testing occasional failure
Browse files Browse the repository at this point in the history
Signed-off-by: chaosi-zju <[email protected]>
  • Loading branch information
chaosi-zju committed Aug 15, 2024
1 parent cd99897 commit cbe10b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/e2e/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,11 @@ var _ = ginkgo.Describe("[resource-status collection] resource status collection
pdbNamespace = testNamespace
pdbName = policyName
deploymentName := policyName
matchLabels := map[string]string{"app": "nginx-" + rand.String(RandomStrLength)}

deployment = testhelper.NewDeployment(pdbNamespace, deploymentName)
pdb = testhelper.NewPodDisruptionBudget(pdbNamespace, pdbName, intstr.FromString("50%"))
deployment.SetLabels(matchLabels)
pdb = testhelper.NewPodDisruptionBudget(pdbNamespace, pdbName, intstr.FromString("50%"), matchLabels)
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
{
APIVersion: pdb.APIVersion,
Expand Down
6 changes: 2 additions & 4 deletions test/helper/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,7 @@ func NewIngress(namespace, name string) *networkingv1.Ingress {
}

// NewPodDisruptionBudget will build a new PodDisruptionBudget object.
func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrString) *policyv1.PodDisruptionBudget {
podLabels := map[string]string{"app": "nginx"}

func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrString, matchLabels map[string]string) *policyv1.PodDisruptionBudget {
return &policyv1.PodDisruptionBudget{
TypeMeta: metav1.TypeMeta{
APIVersion: "policy/v1",
Expand All @@ -951,7 +949,7 @@ func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrS
Spec: policyv1.PodDisruptionBudgetSpec{
MaxUnavailable: &maxUnAvailable,
Selector: &metav1.LabelSelector{
MatchLabels: podLabels,
MatchLabels: matchLabels,
},
},
}
Expand Down

0 comments on commit cbe10b9

Please sign in to comment.