unified-storage: Skip query when ListModifiedSince cannot return anything. (#110338)
* Skip query when ListModifiedSince cannot return anything. * Only save listRV if it's different than sinceRV. This saves a disk access if not needed. * Add test for ListModifiedSince with same RV.
This commit is contained in:
@@ -3,6 +3,7 @@ package test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"iter"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -523,11 +524,22 @@ func runTestIntegrationBackendListModifiedSince(t *testing.T, backend resource.S
|
||||
latestRv, seq := backend.ListModifiedSince(ctx, key, rvDeleted)
|
||||
require.GreaterOrEqual(t, latestRv, rvDeleted)
|
||||
|
||||
counter := 0
|
||||
for range seq {
|
||||
counter++
|
||||
isEmpty(t, seq)
|
||||
})
|
||||
|
||||
t.Run("no events for subsequent listModifiedSince calls", func(t *testing.T) {
|
||||
key := resource.NamespacedResource{
|
||||
Namespace: ns,
|
||||
Group: "group",
|
||||
Resource: "resource",
|
||||
}
|
||||
require.Equal(t, 0, counter) // no events should be returned
|
||||
latestRv1, seq := backend.ListModifiedSince(ctx, key, rvDeleted)
|
||||
require.GreaterOrEqual(t, latestRv1, rvDeleted)
|
||||
isEmpty(t, seq)
|
||||
|
||||
latestRv2, seq := backend.ListModifiedSince(ctx, key, latestRv1)
|
||||
require.GreaterOrEqual(t, latestRv1, latestRv2)
|
||||
isEmpty(t, seq)
|
||||
})
|
||||
|
||||
t.Run("will only return modified events for the given key", func(t *testing.T) {
|
||||
@@ -582,6 +594,14 @@ func runTestIntegrationBackendListModifiedSince(t *testing.T, backend resource.S
|
||||
})
|
||||
}
|
||||
|
||||
func isEmpty(t *testing.T, seq iter.Seq2[*resource.ModifiedResource, error]) {
|
||||
counter := 0
|
||||
for range seq {
|
||||
counter++
|
||||
}
|
||||
require.Equal(t, 0, counter)
|
||||
}
|
||||
|
||||
func runTestIntegrationBackendListHistory(t *testing.T, backend resource.StorageBackend, nsPrefix string) {
|
||||
ctx := testutil.NewTestContext(t, time.Now().Add(30*time.Second))
|
||||
server := newServer(t, backend)
|
||||
|
||||
Reference in New Issue
Block a user