Skip to content

Commit e7e2123

Browse files
committed
pkg/storage/testing/watcher_tests: RunWatchSemantics checks if the storage has been primed with init data
1 parent de735be commit e7e2123

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

staging/src/k8s.io/apiserver/pkg/storage/testing/watcher_tests.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,21 @@ func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interfac
14601460
createdPods = append(createdPods, out)
14611461
}
14621462

1463+
if len(createdPods) > 0 {
1464+
// this list call ensures that the cache has seen the created pods.
1465+
// this makes the watch request below deterministic.
1466+
listObject := &example.PodList{}
1467+
opts := storage.ListOptions{
1468+
Predicate: storage.Everything,
1469+
Recursive: true,
1470+
ResourceVersion: createdPods[len(createdPods)-1].ResourceVersion,
1471+
ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan,
1472+
}
1473+
err := store.GetList(ctx, fmt.Sprintf("/pods/%s", ns), opts, listObject)
1474+
require.NoError(t, err)
1475+
require.Len(t, listObject.Items, len(createdPods))
1476+
}
1477+
14631478
if scenario.useCurrentRV {
14641479
currentStorageRV, err := storage.GetCurrentResourceVersionFromStorage(ctx, store, func() runtime.Object { return &example.PodList{} }, "/pods", "")
14651480
require.NoError(t, err)

0 commit comments

Comments
 (0)