diff --git a/pkg/storage/cacher_test.go b/pkg/storage/cacher_test.go index 00195ccb5be..30d52dc1c99 100644 --- a/pkg/storage/cacher_test.go +++ b/pkg/storage/cacher_test.go @@ -37,6 +37,7 @@ import ( etcdstorage "k8s.io/kubernetes/pkg/storage/etcd" "k8s.io/kubernetes/pkg/storage/etcd/etcdtest" etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" + "k8s.io/kubernetes/pkg/storage/etcd3" "k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/watch" @@ -45,15 +46,15 @@ import ( ) func newEtcdTestStorage(t *testing.T, codec runtime.Codec, prefix string) (*etcdtesting.EtcdTestServer, storage.Interface) { - server := etcdtesting.NewEtcdTestClientServer(t) - storage := etcdstorage.NewEtcdStorage(server.Client, codec, prefix, false, etcdtest.DeserializationCacheSize) + server, _ := etcdtesting.NewUnsecuredEtcd3TestClientServer(t) + storage := etcd3.New(server.V3Client, codec, prefix) return server, storage } -func newTestCacher(s storage.Interface) *storage.Cacher { +func newTestCacher(s storage.Interface, cap int) *storage.Cacher { prefix := "pods" config := storage.CacherConfig{ - CacheCapacity: 10, + CacheCapacity: cap, Storage: s, Versioner: etcdstorage.APIObjectVersioner{}, Type: &api.Pod{}, @@ -96,7 +97,7 @@ func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod { func TestList(t *testing.T) { server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix()) defer server.Terminate(t) - cacher := newTestCacher(etcdStorage) + cacher := newTestCacher(etcdStorage, 10) defer cacher.Stop() podFoo := makeTestPod("foo") @@ -210,7 +211,7 @@ func TestWatch(t *testing.T) { // Inject one list error to make sure we test the relist case. etcdStorage = &injectListError{errors: 1, Interface: etcdStorage} defer server.Terminate(t) - cacher := newTestCacher(etcdStorage) + cacher := newTestCacher(etcdStorage, 3) // small capacity to trigger "too old version" error defer cacher.Stop() podFoo := makeTestPod("foo") @@ -285,7 +286,7 @@ func TestWatch(t *testing.T) { func TestWatcherTimeout(t *testing.T) { server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix()) defer server.Terminate(t) - cacher := newTestCacher(etcdStorage) + cacher := newTestCacher(etcdStorage, 10) defer cacher.Stop() // initialVersion is used to initate the watcher at the beginning of the world, @@ -320,7 +321,7 @@ func TestWatcherTimeout(t *testing.T) { func TestFiltering(t *testing.T) { server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix()) defer server.Terminate(t) - cacher := newTestCacher(etcdStorage) + cacher := newTestCacher(etcdStorage, 10) defer cacher.Stop() // Ensure that the cacher is initialized, before creating any pods, @@ -382,7 +383,7 @@ func TestFiltering(t *testing.T) { func TestStartingResourceVersion(t *testing.T) { server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix()) defer server.Terminate(t) - cacher := newTestCacher(etcdStorage) + cacher := newTestCacher(etcdStorage, 10) defer cacher.Stop() // add 1 object diff --git a/pkg/storage/etcd/testing/utils.go b/pkg/storage/etcd/testing/utils.go index aa6daa51487..679a624bb2a 100644 --- a/pkg/storage/etcd/testing/utils.go +++ b/pkg/storage/etcd/testing/utils.go @@ -63,7 +63,7 @@ type EtcdTestServer struct { // The following are lumped etcd3 test server params v3Cluster *integration.ClusterV3 - v3Client *clientv3.Client + V3Client *clientv3.Client } // newLocalListener opens a port localhost using any port @@ -314,11 +314,11 @@ func NewUnsecuredEtcd3TestClientServer(t *testing.T) (*EtcdTestServer, *storageb server := &EtcdTestServer{ v3Cluster: integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}), } - server.v3Client = server.v3Cluster.RandClient() + server.V3Client = server.v3Cluster.RandClient() config := &storagebackend.Config{ Type: "etcd3", Prefix: etcdtest.PathPrefix(), - ServerList: server.v3Client.Endpoints(), + ServerList: server.V3Client.Endpoints(), DeserializationCacheSize: etcdtest.DeserializationCacheSize, } return server, config