Merge pull request #80792 from tedyu/cacher-no-leak-test
Refine watcher count calculation Kubernetes-commit: 27c4ba579441e78bd40c84b62adb6deb79aa61cf
This commit is contained in:
commit
1a26677aca
|
@ -163,7 +163,6 @@ func (i *indexedWatchers) terminateAll(objectType reflect.Type, done func(*cache
|
|||
// As we don't need a high precision here, we keep all watchers timeout within a
|
||||
// second in a bucket, and pop up them once at the timeout. To be more specific,
|
||||
// if you set fire time at X, you can get the bookmark within (X-1,X+1) period.
|
||||
// This is NOT thread-safe.
|
||||
type watcherBookmarkTimeBuckets struct {
|
||||
lock sync.Mutex
|
||||
watchersBuckets map[int64][]*cacheWatcher
|
||||
|
|
|
@ -647,7 +647,12 @@ func TestCacherNoLeakWithMultipleWatchers(t *testing.T) {
|
|||
cacher.bookmarkWatchers.lock.Lock()
|
||||
defer cacher.bookmarkWatchers.lock.Unlock()
|
||||
if len(cacher.bookmarkWatchers.watchersBuckets) != 0 {
|
||||
t.Errorf("unexpected bookmark watchers %v", len(cacher.bookmarkWatchers.watchersBuckets))
|
||||
numWatchers := 0
|
||||
for bucketID, v := range cacher.bookmarkWatchers.watchersBuckets {
|
||||
numWatchers += len(v)
|
||||
t.Errorf("there are %v watchers at bucket Id %v with start Id %v", len(v), bucketID, cacher.bookmarkWatchers.startBucketID)
|
||||
}
|
||||
t.Errorf("unexpected bookmark watchers %v", numWatchers)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue