Skip to content

Commit 58d9b5c

Browse files
committed
Test bypass for negative RV
1 parent 611abd3 commit 58d9b5c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,23 @@ func TestGetListCacheBypass(t *testing.T) {
250250
if err != nil {
251251
t.Fatalf("Unexpected error: %v", err)
252252
}
253+
continueOnNegativeRV, err := storage.EncodeContinue(keyPrefix+"foo", keyPrefix, -1)
254+
if err != nil {
255+
t.Fatalf("Unexpected error: %v", err)
256+
}
253257
testCases := map[opts]bool{}
254258
testCases[opts{}] = true
255259
testCases[opts{Limit: 100}] = true
256260
testCases[opts{Continue: continueOnRev1}] = true
257261
testCases[opts{Limit: 100, Continue: continueOnRev1}] = true
262+
testCases[opts{Continue: continueOnNegativeRV}] = true
263+
testCases[opts{Limit: 100, Continue: continueOnNegativeRV}] = true
258264
testCases[opts{ResourceVersion: "0"}] = false
259265
testCases[opts{ResourceVersion: "0", Limit: 100}] = false
260266
testCases[opts{ResourceVersion: "0", Continue: continueOnRev1}] = true
261267
testCases[opts{ResourceVersion: "0", Limit: 100, Continue: continueOnRev1}] = true
268+
testCases[opts{ResourceVersion: "0", Continue: continueOnNegativeRV}] = true
269+
testCases[opts{ResourceVersion: "0", Limit: 100, Continue: continueOnNegativeRV}] = true
262270
testCases[opts{ResourceVersion: "0", ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan}] = false
263271
testCases[opts{ResourceVersion: "0", ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan, Limit: 100}] = false
264272
testCases[opts{ResourceVersion: "1"}] = false
@@ -276,10 +284,12 @@ func TestGetListCacheBypass(t *testing.T) {
276284
// Continue is ignored on non recursive LIST
277285
testCases[opts{ResourceVersion: "1", Continue: continueOnRev1}] = true
278286
testCases[opts{ResourceVersion: "1", Continue: continueOnRev1, Limit: 100}] = true
287+
testCases[opts{ResourceVersion: "1", Continue: continueOnNegativeRV}] = true
288+
testCases[opts{ResourceVersion: "1", Continue: continueOnNegativeRV, Limit: 100}] = true
279289

280290
for _, rv := range []string{"", "0", "1"} {
281291
for _, match := range []metav1.ResourceVersionMatch{"", metav1.ResourceVersionMatchExact, metav1.ResourceVersionMatchNotOlderThan} {
282-
for _, continueKey := range []string{"", continueOnRev1} {
292+
for _, continueKey := range []string{"", continueOnRev1, continueOnNegativeRV} {
283293
for _, limit := range []int64{0, 100} {
284294
for _, recursive := range []bool{true, false} {
285295
opt := opts{

0 commit comments

Comments
 (0)