mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #26013 from xiang90/fix_test
cache: fix flaky resync test
This commit is contained in:
commit
d92c151fec
9
pkg/client/cache/reflector_test.go
vendored
9
pkg/client/cache/reflector_test.go
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -356,11 +357,12 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
|
|||||||
func TestReflectorResync(t *testing.T) {
|
func TestReflectorResync(t *testing.T) {
|
||||||
iteration := 0
|
iteration := 0
|
||||||
stopCh := make(chan struct{})
|
stopCh := make(chan struct{})
|
||||||
|
rerr := errors.New("expected resync reached")
|
||||||
s := &FakeCustomStore{
|
s := &FakeCustomStore{
|
||||||
ResyncFunc: func() error {
|
ResyncFunc: func() error {
|
||||||
iteration++
|
iteration++
|
||||||
if iteration == 2 {
|
if iteration == 2 {
|
||||||
close(stopCh)
|
return rerr
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -377,7 +379,10 @@ func TestReflectorResync(t *testing.T) {
|
|||||||
}
|
}
|
||||||
resyncPeriod := 1 * time.Millisecond
|
resyncPeriod := 1 * time.Millisecond
|
||||||
r := NewReflector(lw, &api.Pod{}, s, resyncPeriod)
|
r := NewReflector(lw, &api.Pod{}, s, resyncPeriod)
|
||||||
r.ListAndWatch(stopCh)
|
err := r.ListAndWatch(stopCh)
|
||||||
|
if err != rerr {
|
||||||
|
t.Errorf("expected exiting from err %v, got: %v", rerr, err)
|
||||||
|
}
|
||||||
if iteration != 2 {
|
if iteration != 2 {
|
||||||
t.Errorf("exactly 2 iterations were expected, got: %v", iteration)
|
t.Errorf("exactly 2 iterations were expected, got: %v", iteration)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user