PDB MaxUnavailable: API changes
This commit is contained in:
@@ -25,6 +25,20 @@ import (
|
||||
)
|
||||
|
||||
func TestValidatePodDisruptionBudgetSpec(t *testing.T) {
|
||||
minAvailable := intstr.FromString("0%")
|
||||
maxUnavailable := intstr.FromString("10%")
|
||||
|
||||
spec := policy.PodDisruptionBudgetSpec{
|
||||
MinAvailable: &minAvailable,
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
}
|
||||
errs := ValidatePodDisruptionBudgetSpec(spec, field.NewPath("foo"))
|
||||
if len(errs) == 0 {
|
||||
t.Errorf("unexpected success for %v", spec)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateMinAvailablePodDisruptionBudgetSpec(t *testing.T) {
|
||||
successCases := []intstr.IntOrString{
|
||||
intstr.FromString("0%"),
|
||||
intstr.FromString("1%"),
|
||||
@@ -35,7 +49,7 @@ func TestValidatePodDisruptionBudgetSpec(t *testing.T) {
|
||||
}
|
||||
for _, c := range successCases {
|
||||
spec := policy.PodDisruptionBudgetSpec{
|
||||
MinAvailable: c,
|
||||
MinAvailable: &c,
|
||||
}
|
||||
errs := ValidatePodDisruptionBudgetSpec(spec, field.NewPath("foo"))
|
||||
if len(errs) != 0 {
|
||||
@@ -52,7 +66,7 @@ func TestValidatePodDisruptionBudgetSpec(t *testing.T) {
|
||||
}
|
||||
for _, c := range failureCases {
|
||||
spec := policy.PodDisruptionBudgetSpec{
|
||||
MinAvailable: c,
|
||||
MinAvailable: &c,
|
||||
}
|
||||
errs := ValidatePodDisruptionBudgetSpec(spec, field.NewPath("foo"))
|
||||
if len(errs) == 0 {
|
||||
@@ -61,6 +75,20 @@ func TestValidatePodDisruptionBudgetSpec(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateMinAvailablePodAndMaxUnavailableDisruptionBudgetSpec(t *testing.T) {
|
||||
c1 := intstr.FromString("10%")
|
||||
c2 := intstr.FromInt(1)
|
||||
|
||||
spec := policy.PodDisruptionBudgetSpec{
|
||||
MinAvailable: &c1,
|
||||
MaxUnavailable: &c2,
|
||||
}
|
||||
errs := ValidatePodDisruptionBudgetSpec(spec, field.NewPath("foo"))
|
||||
if len(errs) == 0 {
|
||||
t.Errorf("unexpected success for %v", spec)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePodDisruptionBudgetStatus(t *testing.T) {
|
||||
successCases := []policy.PodDisruptionBudgetStatus{
|
||||
{PodDisruptionsAllowed: 10},
|
||||
|
||||
Reference in New Issue
Block a user