Merge pull request #123927 from p0lyn0mial/upstream-cacher-decrease-watcher-draining-no-bookmark-after

apiserver/storage/cacher: decrease running time of TestCacheWatcherDrainingNoBookmarkAfterResourceVersionReceived
This commit is contained in:
Kubernetes Prow Robot 2024-04-22 01:24:10 -07:00 committed by GitHub
commit 4d9b50bcb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -499,10 +499,22 @@ func TestCacheWatcherDrainingNoBookmarkAfterResourceVersionReceived(t *testing.T
w = newCacheWatcher(0, filter, forget, storage.APIObjectVersioner{}, time.Now(), true, schema.GroupResource{Resource: "pods"}, "")
w.setBookmarkAfterResourceVersion(10)
go w.processInterval(context.Background(), intervalFromEvents(initEvents), 0)
if w.add(&watchCacheEvent{Object: &v1.Pod{}}, time.NewTimer(1*time.Second)) {
// get an event so that
// we know the w.processInterval
// has been scheduled, and
// it will be blocked on
// sending the other event
// to the result chan
<-w.ResultChan()
// now, once we know, the processInterval
// is waiting add another event that will time out
// and start the cleanup process
if w.add(&watchCacheEvent{Object: &v1.Pod{}}, time.NewTimer(10*time.Millisecond)) {
t.Fatal("expected the add method to fail")
}
if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) {
if err := wait.PollUntilContextTimeout(context.Background(), 100*time.Millisecond, 5*time.Second, true, func(_ context.Context) (bool, error) {
lock.RLock()
defer lock.RUnlock()
return count == 2, nil