@@ -899,6 +899,7 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
899
899
case 1 :
900
900
podList .ListMeta = metav1.ListMeta {ResourceVersion : "10" }
901
901
default :
902
+ t .Errorf ("unexpected list call: %d" , listCalls )
902
903
err = fmt .Errorf ("unexpected list call" )
903
904
}
904
905
listCalls ++
@@ -921,8 +922,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
921
922
for i := 12 ; i < 18 ; i ++ {
922
923
w .Add (makePod (i ))
923
924
}
924
- w .Stop ()
925
+ // Keep the watch open to avoid another reinitialization,
926
+ // but register it for cleanup.
927
+ t .Cleanup (func () { w .Stop () })
925
928
default :
929
+ t .Errorf ("unexpected watch call: %d" , watchCalls )
926
930
err = fmt .Errorf ("unexpected watch call" )
927
931
}
928
932
watchCalls ++
@@ -944,7 +948,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
944
948
ctx , cancel := context .WithTimeout (context .Background (), 3 * time .Second )
945
949
defer cancel ()
946
950
947
- errCh := make (chan error , concurrency )
948
951
for i := 0 ; i < concurrency ; i ++ {
949
952
go func () {
950
953
defer wg .Done ()
@@ -968,11 +971,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
968
971
}
969
972
rv , err := strconv .Atoi (object .(* example.Pod ).ResourceVersion )
970
973
if err != nil {
971
- errCh <- fmt .Errorf ("incorrect resource version: %v" , err )
974
+ t .Errorf ("incorrect resource version: %v" , err )
972
975
return
973
976
}
974
977
if prevRV != - 1 && prevRV + 1 != rv {
975
- errCh <- fmt .Errorf ("unexpected event received, prevRV=%d, rv=%d" , prevRV , rv )
978
+ t .Errorf ("unexpected event received, prevRV=%d, rv=%d" , prevRV , rv )
976
979
return
977
980
}
978
981
prevRV = rv
@@ -981,11 +984,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
981
984
}()
982
985
}
983
986
wg .Wait ()
984
- close (errCh )
985
-
986
- for err := range errCh {
987
- t .Error (err )
988
- }
989
987
}
990
988
991
989
func TestCacherNoLeakWithMultipleWatchers (t * testing.T ) {
0 commit comments