fix pdb collection testing occasional failure
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
parent
cd99897506
commit
e7e06ceed8
|
@ -571,9 +571,13 @@ var _ = ginkgo.Describe("[resource-status collection] resource status collection
|
||||||
pdbNamespace = testNamespace
|
pdbNamespace = testNamespace
|
||||||
pdbName = policyName
|
pdbName = policyName
|
||||||
deploymentName := 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)
|
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{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: pdb.APIVersion,
|
APIVersion: pdb.APIVersion,
|
||||||
|
|
|
@ -936,9 +936,7 @@ func NewIngress(namespace, name string) *networkingv1.Ingress {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPodDisruptionBudget will build a new PodDisruptionBudget object.
|
// NewPodDisruptionBudget will build a new PodDisruptionBudget object.
|
||||||
func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrString) *policyv1.PodDisruptionBudget {
|
func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrString, matchLabels map[string]string) *policyv1.PodDisruptionBudget {
|
||||||
podLabels := map[string]string{"app": "nginx"}
|
|
||||||
|
|
||||||
return &policyv1.PodDisruptionBudget{
|
return &policyv1.PodDisruptionBudget{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "policy/v1",
|
APIVersion: "policy/v1",
|
||||||
|
@ -951,7 +949,7 @@ func NewPodDisruptionBudget(namespace, name string, maxUnAvailable intstr.IntOrS
|
||||||
Spec: policyv1.PodDisruptionBudgetSpec{
|
Spec: policyv1.PodDisruptionBudgetSpec{
|
||||||
MaxUnavailable: &maxUnAvailable,
|
MaxUnavailable: &maxUnAvailable,
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: podLabels,
|
MatchLabels: matchLabels,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue