@@ -905,6 +905,7 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
905
905
case 1 :
906
906
podList .ListMeta = metav1.ListMeta {ResourceVersion : "10" }
907
907
default :
908
+ t .Errorf ("unexpected list call: %d" , listCalls )
908
909
err = fmt .Errorf ("unexpected list call" )
909
910
}
910
911
listCalls ++
@@ -927,8 +928,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
927
928
for i := 12 ; i < 18 ; i ++ {
928
929
w .Add (makePod (i ))
929
930
}
930
- w .Stop ()
931
+ // Keep the watch open to avoid another reinitialization,
932
+ // but register it for cleanup.
933
+ t .Cleanup (func () { w .Stop () })
931
934
default :
935
+ t .Errorf ("unexpected watch call: %d" , watchCalls )
932
936
err = fmt .Errorf ("unexpected watch call" )
933
937
}
934
938
watchCalls ++
@@ -950,7 +954,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
950
954
ctx , cancel := context .WithTimeout (context .Background (), 3 * time .Second )
951
955
defer cancel ()
952
956
953
- errCh := make (chan error , concurrency )
954
957
for i := 0 ; i < concurrency ; i ++ {
955
958
go func () {
956
959
defer wg .Done ()
@@ -974,11 +977,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
974
977
}
975
978
rv , err := strconv .Atoi (object .(* example.Pod ).ResourceVersion )
976
979
if err != nil {
977
- errCh <- fmt .Errorf ("incorrect resource version: %v" , err )
980
+ t .Errorf ("incorrect resource version: %v" , err )
978
981
return
979
982
}
980
983
if prevRV != - 1 && prevRV + 1 != rv {
981
- errCh <- fmt .Errorf ("unexpected event received, prevRV=%d, rv=%d" , prevRV , rv )
984
+ t .Errorf ("unexpected event received, prevRV=%d, rv=%d" , prevRV , rv )
982
985
return
983
986
}
984
987
prevRV = rv
@@ -987,11 +990,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
987
990
}()
988
991
}
989
992
wg .Wait ()
990
- close (errCh )
991
-
992
- for err := range errCh {
993
- t .Error (err )
994
- }
995
993
}
996
994
997
995
func TestCacherNoLeakWithMultipleWatchers (t * testing.T ) {
0 commit comments