mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #128530 from wojtek-t/automated-cherry-pick-of-#128468-upstream-release-1.31
Automated cherry pick of #128468: Fix TestCacherDontMissEventsOnReinitialization test
This commit is contained in:
commit
f6f4d800c8
@ -899,6 +899,7 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
||||
case 1:
|
||||
podList.ListMeta = metav1.ListMeta{ResourceVersion: "10"}
|
||||
default:
|
||||
t.Errorf("unexpected list call: %d", listCalls)
|
||||
err = fmt.Errorf("unexpected list call")
|
||||
}
|
||||
listCalls++
|
||||
@ -921,8 +922,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
||||
for i := 12; i < 18; i++ {
|
||||
w.Add(makePod(i))
|
||||
}
|
||||
w.Stop()
|
||||
// Keep the watch open to avoid another reinitialization,
|
||||
// but register it for cleanup.
|
||||
t.Cleanup(func() { w.Stop() })
|
||||
default:
|
||||
t.Errorf("unexpected watch call: %d", watchCalls)
|
||||
err = fmt.Errorf("unexpected watch call")
|
||||
}
|
||||
watchCalls++
|
||||
@ -944,7 +948,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
errCh := make(chan error, concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -968,11 +971,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
||||
}
|
||||
rv, err := strconv.Atoi(object.(*example.Pod).ResourceVersion)
|
||||
if err != nil {
|
||||
errCh <- fmt.Errorf("incorrect resource version: %v", err)
|
||||
t.Errorf("incorrect resource version: %v", err)
|
||||
return
|
||||
}
|
||||
if prevRV != -1 && prevRV+1 != rv {
|
||||
errCh <- fmt.Errorf("unexpected event received, prevRV=%d, rv=%d", prevRV, rv)
|
||||
t.Errorf("unexpected event received, prevRV=%d, rv=%d", prevRV, rv)
|
||||
return
|
||||
}
|
||||
prevRV = rv
|
||||
@ -981,11 +984,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
close(errCh)
|
||||
|
||||
for err := range errCh {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCacherNoLeakWithMultipleWatchers(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user