Skip to content

Commit 530278b

Browse files
authored
Merge pull request kubernetes#128639 from jpbetz/fix-cost-test
Fix flake in CEL cost stability tests
2 parents 272bb95 + 3603555 commit 530278b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/celcoststability_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,24 @@ func TestCelCostStability(t *testing.T) {
372372
"!('c' in self.val)": 4,
373373
"'d' in self.val": 3,
374374
// field selection also possible if map key is a valid CEL identifier
375-
"!has(self.val.a)": 3,
376-
"has(self.val.b)": 2,
377-
"!has(self.val.c)": 3,
378-
"has(self.val.d)": 2,
379-
"self.val.all(k, self.val[k] > 0)": 17,
375+
"!has(self.val.a)": 3,
376+
"has(self.val.b)": 2,
377+
"!has(self.val.c)": 3,
378+
"has(self.val.d)": 2,
379+
"self.val.all(k, self.val[k] > 0)": 17,
380+
// It is important that the condition does not match in this exists test
381+
// since the map iteration order is non-deterministic, and exists short circuits when it matches.
382+
"!self.val.exists(k, self.val[k] == 3)": 20,
380383
"self.val.exists_one(k, self.val[k] == 2)": 14,
381384
"!self.val.exists_one(k, self.val[k] > 0)": 17,
382385
"size(self.val) == 2": 4,
383386
"size(self.val.filter(k, self.val[k] > 1)) == 1": 26,
384387

385388
// two variable comprehensions
386-
"self.val.all(k, v, v > 0)": 13,
387-
"self.val.exists(k, v, v == 2)": 15,
389+
"self.val.all(k, v, v > 0)": 13,
390+
// It is important that the condition does not match in this exists test
391+
// since the map iteration order is non-deterministic, and exists short circuits when it matches.
392+
"!self.val.exists(k, v, v == 3)": 16,
388393
"self.val.existsOne(k, v, v == 2)": 10,
389394
"self.val.transformMap(k, v, v > 1, v + 1).size() == 1": 14,
390395
"self.val.transformMap(k, v, v + 1).size() == 2": 15,

0 commit comments

Comments
 (0)