MCPcopy
hub / github.com/kubernetes/client-go / TestReflectorResync

Function TestReflectorResync

tools/cache/reflector_test.go:357–389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

355}
356
357func TestReflectorResync(t *testing.T) {
358 iteration := 0
359 stopCh := make(chan struct{})
360 rerr := errors.New("expected resync reached")
361 s := &FakeCustomStore{
362 ResyncFunc: func() error {
363 iteration++
364 if iteration == 2 {
365 return rerr
366 }
367 return nil
368 },
369 }
370
371 lw := &testLW{
372 WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
373 fw := watch.NewFake()
374 return fw, nil
375 },
376 ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
377 return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "0"}}, nil
378 },
379 }
380 resyncPeriod := 1 * time.Millisecond
381 r := NewReflector(lw, &v1.Pod{}, s, resyncPeriod)
382 if err := r.ListAndWatch(stopCh); err != nil {
383 // error from Resync is not propaged up to here.
384 t.Errorf("expected error %v", err)
385 }
386 if iteration != 2 {
387 t.Errorf("exactly 2 iterations were expected, got: %v", iteration)
388 }
389}
390
391func TestReflectorWatchListPageSize(t *testing.T) {
392 stopCh := make(chan struct{})

Callers

nothing calls this directly

Calls 3

ListAndWatchMethod · 0.95
NewReflectorFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected