mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +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:
|
case 1:
|
||||||
podList.ListMeta = metav1.ListMeta{ResourceVersion: "10"}
|
podList.ListMeta = metav1.ListMeta{ResourceVersion: "10"}
|
||||||
default:
|
default:
|
||||||
|
t.Errorf("unexpected list call: %d", listCalls)
|
||||||
err = fmt.Errorf("unexpected list call")
|
err = fmt.Errorf("unexpected list call")
|
||||||
}
|
}
|
||||||
listCalls++
|
listCalls++
|
||||||
@ -921,8 +922,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
|||||||
for i := 12; i < 18; i++ {
|
for i := 12; i < 18; i++ {
|
||||||
w.Add(makePod(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:
|
default:
|
||||||
|
t.Errorf("unexpected watch call: %d", watchCalls)
|
||||||
err = fmt.Errorf("unexpected watch call")
|
err = fmt.Errorf("unexpected watch call")
|
||||||
}
|
}
|
||||||
watchCalls++
|
watchCalls++
|
||||||
@ -944,7 +948,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
errCh := make(chan error, concurrency)
|
|
||||||
for i := 0; i < concurrency; i++ {
|
for i := 0; i < concurrency; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
@ -968,11 +971,11 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
rv, err := strconv.Atoi(object.(*example.Pod).ResourceVersion)
|
rv, err := strconv.Atoi(object.(*example.Pod).ResourceVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCh <- fmt.Errorf("incorrect resource version: %v", err)
|
t.Errorf("incorrect resource version: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if prevRV != -1 && prevRV+1 != rv {
|
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
|
return
|
||||||
}
|
}
|
||||||
prevRV = rv
|
prevRV = rv
|
||||||
@ -981,11 +984,6 @@ func TestCacherDontMissEventsOnReinitialization(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
close(errCh)
|
|
||||||
|
|
||||||
for err := range errCh {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacherNoLeakWithMultipleWatchers(t *testing.T) {
|
func TestCacherNoLeakWithMultipleWatchers(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user