diff --git a/test/e2e/resource_test.go b/test/e2e/resource_test.go index 1839164fd..971d24341 100644 --- a/test/e2e/resource_test.go +++ b/test/e2e/resource_test.go @@ -571,9 +571,13 @@ var _ = ginkgo.Describe("[resource-status collection] resource status collection pdbNamespace = testNamespace pdbName = policyName deploymentName := policyName + // use a special label value to prevent PDB from selecting pods of other parallel e2e cases. + matchLabels := map[string]string{"app": "nginx-" + rand.String(RandomStrLength)} deployment = testhelper.NewDeployment(pdbNamespace, deploymentName) - pdb = testhelper.NewPodDisruptionBudget(pdbNamespace, pdbName, intstr.FromString("50%")) + deployment.Spec.Selector.MatchLabels = matchLabels + deployment.Spec.Template.Labels = matchLabels + pdb = testhelper.NewPodDisruptionBudget(pdbNamespace, pdbName, intstr.FromString("50%"), matchLabels) policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{ { APIVersion: pdb.APIVersion, diff --git a/test/helper/resource.go b/test/helper/resource.go index 09d795425..5f001efa7 100644 --- a/test/helper/resource.go +++ b/test/helper/resource.go @@ -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", @@ -951,7 +949,7 @@ func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrS Spec: policyv1.PodDisruptionBudgetSpec{ MaxUnavailable: &maxUnAvailable, Selector: &metav1.LabelSelector{ - MatchLabels: podLabels, + MatchLabels: matchLabels, }, }, }