mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #109238 from jpbetz/reduce-time-cel-validation-tests
Flake fix: validate each expression once in primary CEL correctness suite
This commit is contained in:
commit
0184d77f50
@ -1778,38 +1778,6 @@ func TestValidationExpressions(t *testing.T) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// test with cost budget exceeded
|
||||
errs, _ = celValidator.Validate(ctx, field.NewPath("root"), &s, tt.obj, tt.oldObj, 0)
|
||||
var found bool
|
||||
for _, err := range errs {
|
||||
if err.Type == field.ErrorTypeInvalid && strings.Contains(err.Error(), "validation failed due to running out of cost budget, no further validation rules will be run") {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("expect cost limit exceed err but did not find")
|
||||
}
|
||||
if len(errs) > 1 {
|
||||
t.Errorf("expect to return cost budget exceed err once")
|
||||
}
|
||||
|
||||
// test with PerCallLimit exceeded
|
||||
found = false
|
||||
celValidator = NewValidator(&s, 0)
|
||||
if celValidator == nil {
|
||||
t.Fatal("expected non nil validator")
|
||||
}
|
||||
errs, _ = celValidator.Validate(ctx, field.NewPath("root"), &s, tt.obj, tt.oldObj, tt.costBudget)
|
||||
for _, err := range errs {
|
||||
if err.Type == field.ErrorTypeInvalid && strings.Contains(err.Error(), "no further validation rules will be run due to call cost exceeds limit for rule") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("expect PerCostLimit exceed err but did not find")
|
||||
}
|
||||
})
|
||||
}
|
||||
for rule, expectErrToContain := range tt.errors {
|
||||
@ -1828,21 +1796,6 @@ func TestValidationExpressions(t *testing.T) {
|
||||
t.Errorf("expected error to contain '%s', but got: %v", expectErrToContain, err)
|
||||
}
|
||||
}
|
||||
|
||||
// test with cost budget exceeded
|
||||
errs, _ = celValidator.Validate(ctx, field.NewPath("root"), &s, tt.obj, tt.oldObj, 0)
|
||||
var found bool
|
||||
for _, err := range errs {
|
||||
if err.Type == field.ErrorTypeInvalid && strings.Contains(err.Error(), "validation failed due to running out of cost budget, no further validation rules will be run") {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("expect cost limit exceed err but did not find")
|
||||
}
|
||||
if len(errs) > 1 {
|
||||
t.Errorf("expect to return cost budget exceed err once")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user