mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Fix flake in CEL cost stability tests
A new test was added that uses exists(), which short circuits when a condition is met. The test input is a map with random ordering, so the test can fail when the element that causes the iteration to short circuit is traversed first.
This commit is contained in:
parent
4c487b00af
commit
3603555831
@ -377,6 +377,9 @@ func TestCelCostStability(t *testing.T) {
|
|||||||
"!has(self.val.c)": 3,
|
"!has(self.val.c)": 3,
|
||||||
"has(self.val.d)": 2,
|
"has(self.val.d)": 2,
|
||||||
"self.val.all(k, self.val[k] > 0)": 17,
|
"self.val.all(k, self.val[k] > 0)": 17,
|
||||||
|
// It is important that the condition does not match in this exists test
|
||||||
|
// since the map iteration order is non-deterministic, and exists short circuits when it matches.
|
||||||
|
"!self.val.exists(k, self.val[k] == 3)": 20,
|
||||||
"self.val.exists_one(k, self.val[k] == 2)": 14,
|
"self.val.exists_one(k, self.val[k] == 2)": 14,
|
||||||
"!self.val.exists_one(k, self.val[k] > 0)": 17,
|
"!self.val.exists_one(k, self.val[k] > 0)": 17,
|
||||||
"size(self.val) == 2": 4,
|
"size(self.val) == 2": 4,
|
||||||
@ -384,7 +387,9 @@ func TestCelCostStability(t *testing.T) {
|
|||||||
|
|
||||||
// two variable comprehensions
|
// two variable comprehensions
|
||||||
"self.val.all(k, v, v > 0)": 13,
|
"self.val.all(k, v, v > 0)": 13,
|
||||||
"self.val.exists(k, v, v == 2)": 15,
|
// It is important that the condition does not match in this exists test
|
||||||
|
// since the map iteration order is non-deterministic, and exists short circuits when it matches.
|
||||||
|
"!self.val.exists(k, v, v == 3)": 16,
|
||||||
"self.val.existsOne(k, v, v == 2)": 10,
|
"self.val.existsOne(k, v, v == 2)": 10,
|
||||||
"self.val.transformMap(k, v, v > 1, v + 1).size() == 1": 14,
|
"self.val.transformMap(k, v, v > 1, v + 1).size() == 1": 14,
|
||||||
"self.val.transformMap(k, v, v + 1).size() == 2": 15,
|
"self.val.transformMap(k, v, v + 1).size() == 2": 15,
|
||||||
|
Loading…
Reference in New Issue
Block a user