diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a939b0f53..043a01f1f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -816,339 +816,339 @@ }, { "ImportPath": "k8s.io/api/admission/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/admissionregistration/v1alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/admissionregistration/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/apps/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/apps/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/apps/v1beta2", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/authentication/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/authentication/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/authorization/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/authorization/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/autoscaling/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/autoscaling/v2beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/batch/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/batch/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/batch/v2alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/certificates/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/core/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/events/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/extensions/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/networking/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/policy/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/rbac/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/rbac/v1alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/rbac/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/scheduling/v1alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/settings/v1alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/storage/v1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/storage/v1alpha1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/api/storage/v1beta1", - "Rev": "860727955743743199a0f053f2292f41d7196604" + "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/equality", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/errors", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/meta", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/resource", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/testing", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/validation", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/validation/path", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apimachinery", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/conversion", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/fields", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/labels", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/selection", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/types", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/cache", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/clock", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/diff", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/errors", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/framer", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/json", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/net", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/rand", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/sets", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/uuid", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/validation", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/wait", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/version", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/pkg/watch", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", - "Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" + "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a" }, { "ImportPath": "k8s.io/client-go/discovery", diff --git a/pkg/storage/BUILD b/pkg/storage/BUILD index 387ccf7f4..712544e2d 100644 --- a/pkg/storage/BUILD +++ b/pkg/storage/BUILD @@ -28,7 +28,6 @@ go_test( "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/client-go/tools/cache:go_default_library", diff --git a/pkg/storage/watch_cache.go b/pkg/storage/watch_cache.go index a21a5f830..373e74eed 100644 --- a/pkg/storage/watch_cache.go +++ b/pkg/storage/watch_cache.go @@ -377,7 +377,17 @@ func (w *watchCache) Replace(objs []interface{}, resourceVersion string) error { if err != nil { return fmt.Errorf("couldn't compute key: %v", err) } - toReplace = append(toReplace, &storeElement{Key: key, Object: object}) + objLabels, objFields, objUninitialized, err := w.getAttrsFunc(object) + if err != nil { + return err + } + toReplace = append(toReplace, &storeElement{ + Key: key, + Object: object, + Labels: objLabels, + Fields: objFields, + Uninitialized: objUninitialized, + }) } w.Lock() diff --git a/pkg/storage/watch_cache_test.go b/pkg/storage/watch_cache_test.go index b695f3a81..f7b353e63 100644 --- a/pkg/storage/watch_cache_test.go +++ b/pkg/storage/watch_cache_test.go @@ -17,6 +17,7 @@ limitations under the License. package storage import ( + "fmt" "strconv" "testing" "time" @@ -29,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/clock" - "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/cache" @@ -41,7 +41,23 @@ func makeTestPod(name string, resourceVersion uint64) *v1.Pod { Namespace: "ns", Name: name, ResourceVersion: strconv.FormatUint(resourceVersion, 10), + Labels: map[string]string{ + "k8s-app": "my-app", + }, }, + Spec: v1.PodSpec{ + NodeName: "some-node", + }, + } +} + +func makeTestStoreElement(pod *v1.Pod) *storeElement { + return &storeElement{ + Key: "prefix/ns/" + pod.Name, + Object: pod, + Labels: labels.Set(pod.Labels), + Fields: fields.Set{"spec.nodeName": pod.Spec.NodeName}, + Uninitialized: false, } } @@ -51,7 +67,11 @@ func newTestWatchCache(capacity int) *watchCache { return NamespaceKeyFunc("prefix", obj) } getAttrsFunc := func(obj runtime.Object) (labels.Set, fields.Set, bool, error) { - return nil, nil, false, nil + pod, ok := obj.(*v1.Pod) + if !ok { + return nil, nil, false, fmt.Errorf("not a pod!") + } + return labels.Set(pod.Labels), fields.Set{"spec.nodeName": pod.Spec.NodeName}, false, nil } wc := newWatchCache(capacity, keyFunc, getAttrsFunc) wc.clock = clock.NewFakeClock(time.Now()) @@ -69,8 +89,9 @@ func TestWatchCacheBasic(t *testing.T) { if item, ok, _ := store.Get(pod1); !ok { t.Errorf("didn't find pod") } else { - if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod1}, item) { - t.Errorf("expected %v, got %v", pod1, item) + expected := makeTestStoreElement(makeTestPod("pod", 1)) + if !apiequality.Semantic.DeepEqual(expected, item) { + t.Errorf("expected %v, got %v", expected, item) } } pod2 := makeTestPod("pod", 2) @@ -80,8 +101,9 @@ func TestWatchCacheBasic(t *testing.T) { if item, ok, _ := store.Get(pod2); !ok { t.Errorf("didn't find pod") } else { - if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod2}, item) { - t.Errorf("expected %v, got %v", pod1, item) + expected := makeTestStoreElement(makeTestPod("pod", 2)) + if !apiequality.Semantic.DeepEqual(expected, item) { + t.Errorf("expected %v, got %v", expected, item) } } pod3 := makeTestPod("pod", 3) @@ -97,15 +119,18 @@ func TestWatchCacheBasic(t *testing.T) { store.Add(makeTestPod("pod2", 5)) store.Add(makeTestPod("pod3", 6)) { - podNames := sets.String{} + expected := map[string]storeElement{ + "prefix/ns/pod1": *makeTestStoreElement(makeTestPod("pod1", 4)), + "prefix/ns/pod2": *makeTestStoreElement(makeTestPod("pod2", 5)), + "prefix/ns/pod3": *makeTestStoreElement(makeTestPod("pod3", 6)), + } + items := make(map[string]storeElement, 0) for _, item := range store.List() { - podNames.Insert(item.(*storeElement).Object.(*v1.Pod).ObjectMeta.Name) + elem := item.(*storeElement) + items[elem.Key] = *elem } - if !podNames.HasAll("pod1", "pod2", "pod3") { - t.Errorf("missing pods, found %v", podNames) - } - if len(podNames) != 3 { - t.Errorf("found missing/extra items") + if !apiequality.Semantic.DeepEqual(expected, items) { + t.Errorf("expected %v, got %v", expected, items) } } @@ -115,15 +140,17 @@ func TestWatchCacheBasic(t *testing.T) { makeTestPod("pod5", 8), }, "8") { - podNames := sets.String{} + expected := map[string]storeElement{ + "prefix/ns/pod4": *makeTestStoreElement(makeTestPod("pod4", 7)), + "prefix/ns/pod5": *makeTestStoreElement(makeTestPod("pod5", 8)), + } + items := make(map[string]storeElement) for _, item := range store.List() { - podNames.Insert(item.(*storeElement).Object.(*v1.Pod).ObjectMeta.Name) + elem := item.(*storeElement) + items[elem.Key] = *elem } - if !podNames.HasAll("pod4", "pod5") { - t.Errorf("missing pods, found %v", podNames) - } - if len(podNames) != 2 { - t.Errorf("found missing/extra items") + if !apiequality.Semantic.DeepEqual(expected, items) { + t.Errorf("expected %v, got %v", expected, items) } } } @@ -288,8 +315,9 @@ func TestWaitUntilFreshAndGet(t *testing.T) { if !exists { t.Fatalf("no results returned: %#v", obj) } - if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/bar", Object: makeTestPod("bar", 5)}, obj) { - t.Errorf("unexpected element returned: %#v", obj) + expected := makeTestStoreElement(makeTestPod("bar", 5)) + if !apiequality.Semantic.DeepEqual(expected, obj) { + t.Errorf("expected %v, got %v", expected, obj) } }