pkg/storage/testing/watcher_tests: RunWatchSemantics checks if the storage has been primed with init data

Kubernetes-commit: e7e2123feb2f1957be490a21aa606cb2dc718432
This commit is contained in:
Lukasz Szaszkiewicz 2024-09-20 09:37:53 +02:00 committed by Kubernetes Publisher
parent eb3a20ad8b
commit cdd40a3d24
1 changed files with 15 additions and 0 deletions

View File

@ -1460,6 +1460,21 @@ func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interfac
createdPods = append(createdPods, out)
}
if len(createdPods) > 0 {
// this list call ensures that the cache has seen the created pods.
// this makes the watch request below deterministic.
listObject := &example.PodList{}
opts := storage.ListOptions{
Predicate: storage.Everything,
Recursive: true,
ResourceVersion: createdPods[len(createdPods)-1].ResourceVersion,
ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan,
}
err := store.GetList(ctx, fmt.Sprintf("/pods/%s", ns), opts, listObject)
require.NoError(t, err)
require.Len(t, listObject.Items, len(createdPods))
}
if scenario.useCurrentRV {
currentStorageRV, err := storage.GetCurrentResourceVersionFromStorage(ctx, store, func() runtime.Object { return &example.PodList{} }, "/pods", "")
require.NoError(t, err)