Make watch cache behave like uncached watch

This commit is contained in:
Jordan Liggitt
2016-04-07 19:53:41 -04:00
parent acf9492cb1
commit ada60236f7
4 changed files with 23 additions and 18 deletions

View File

@@ -19,6 +19,7 @@ package storage_test
import (
"fmt"
"reflect"
goruntime "runtime"
"strconv"
"testing"
"time"
@@ -159,15 +160,19 @@ func TestList(t *testing.T) {
}
func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType, eventObject runtime.Object) {
_, _, line, _ := goruntime.Caller(1)
select {
case event := <-w.ResultChan():
if e, a := eventType, event.Type; e != a {
t.Logf("(called from line %d)", line)
t.Errorf("Expected: %s, got: %s", eventType, event.Type)
}
if e, a := eventObject, event.Object; !api.Semantic.DeepDerivative(e, a) {
t.Logf("(called from line %d)", line)
t.Errorf("Expected (%s): %#v, got: %#v", eventType, e, a)
}
case <-time.After(wait.ForeverTestTimeout):
t.Logf("(called from line %d)", line)
t.Errorf("Timed out waiting for an event")
}
}
@@ -236,7 +241,6 @@ func TestWatch(t *testing.T) {
}
defer initialWatcher.Stop()
verifyWatchEvent(t, initialWatcher, watch.Added, podFoo)
verifyWatchEvent(t, initialWatcher, watch.Modified, podFooPrime)
// Now test watch from "now".
@@ -335,7 +339,6 @@ func TestFiltering(t *testing.T) {
}
defer watcher.Stop()
verifyWatchEvent(t, watcher, watch.Added, podFoo)
verifyWatchEvent(t, watcher, watch.Deleted, podFooFiltered)
verifyWatchEvent(t, watcher, watch.Added, podFoo)
verifyWatchEvent(t, watcher, watch.Modified, podFooPrime)