Skip to content

Commit

Permalink
cache: fix flaky resync test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed May 22, 2016
1 parent 0257f54 commit f31ec95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/client/cache/reflector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cache

import (
"errors"
"fmt"
"math/rand"
"strconv"
Expand Down Expand Up @@ -354,11 +355,12 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
func TestReflectorResync(t *testing.T) {
iteration := 0
stopCh := make(chan struct{})
rerr := errors.New("expected resync reached")
s := &FakeCustomStore{
ResyncFunc: func() error {
iteration++
if iteration == 2 {
close(stopCh)
return rerr
}
return nil
},
Expand All @@ -375,7 +377,10 @@ func TestReflectorResync(t *testing.T) {
}
resyncPeriod := 1 * time.Millisecond
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 {
t.Errorf("exactly 2 iterations were expected, got: %v", iteration)
}
Expand Down

0 comments on commit f31ec95

Please sign in to comment.