@@ -45,6 +45,10 @@ import (
45
45
utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
46
46
)
47
47
48
+ var (
49
+ objectType = reflect .TypeOf (& v1.Pod {})
50
+ )
51
+
48
52
// verifies the cacheWatcher.process goroutine is properly cleaned up even if
49
53
// the writes to cacheWatcher.result channel is blocked.
50
54
func TestCacheWatcherCleanupNotBlockedByResult (t * testing.T ) {
@@ -67,7 +71,7 @@ func TestCacheWatcherCleanupNotBlockedByResult(t *testing.T) {
67
71
}
68
72
// set the size of the buffer of w.result to 0, so that the writes to
69
73
// w.result is blocked.
70
- w = newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false )
74
+ w = newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false , objectType )
71
75
go w .process (context .Background (), initEvents , 0 )
72
76
w .Stop ()
73
77
if err := wait .PollImmediate (1 * time .Second , 5 * time .Second , func () (bool , error ) {
@@ -187,7 +191,7 @@ TestCase:
187
191
testCase .events [j ].ResourceVersion = uint64 (j ) + 1
188
192
}
189
193
190
- w := newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false )
194
+ w := newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false , objectType )
191
195
go w .process (context .Background (), testCase .events , 0 )
192
196
193
197
ch := w .ResultChan ()
@@ -466,7 +470,7 @@ func TestCacheWatcherStoppedInAnotherGoroutine(t *testing.T) {
466
470
// timeout to zero and run the Stop goroutine concurrently.
467
471
// May sure that the watch will not be blocked on Stop.
468
472
for i := 0 ; i < maxRetriesToProduceTheRaceCondition ; i ++ {
469
- w = newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false )
473
+ w = newCacheWatcher (0 , filter , forget , testVersioner {}, time .Now (), false , objectType )
470
474
go w .Stop ()
471
475
select {
472
476
case <- done :
@@ -478,7 +482,7 @@ func TestCacheWatcherStoppedInAnotherGoroutine(t *testing.T) {
478
482
deadline := time .Now ().Add (time .Hour )
479
483
// After that, verifies the cacheWatcher.process goroutine works correctly.
480
484
for i := 0 ; i < maxRetriesToProduceTheRaceCondition ; i ++ {
481
- w = newCacheWatcher (2 , filter , emptyFunc , testVersioner {}, deadline , false )
485
+ w = newCacheWatcher (2 , filter , emptyFunc , testVersioner {}, deadline , false , objectType )
482
486
w .input <- & watchCacheEvent {Object : & v1.Pod {}, ResourceVersion : uint64 (i + 1 )}
483
487
ctx , _ := context .WithDeadline (context .Background (), deadline )
484
488
go w .process (ctx , nil , 0 )
@@ -498,7 +502,7 @@ func TestTimeBucketWatchersBasic(t *testing.T) {
498
502
forget := func () {}
499
503
500
504
newWatcher := func (deadline time.Time ) * cacheWatcher {
501
- return newCacheWatcher (0 , filter , forget , testVersioner {}, deadline , true )
505
+ return newCacheWatcher (0 , filter , forget , testVersioner {}, deadline , true , objectType )
502
506
}
503
507
504
508
clock := clock .NewFakeClock (time .Now ())
0 commit comments