func newFailDeleteStorage(t *testing.T, called *bool) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 3} storage := NewStorage(restOptions, nil, nil) storage.Pod.Store.Storage = FailDeletionStorage{storage.Pod.Store.Storage, called} return storage.Pod, server }
func newFailDeleteStorage(t *testing.T, called *bool) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") failDeleteStorage := FailDeletionStorage{etcdStorage, called} restOptions := generic.RESTOptions{failDeleteStorage, generic.UndecoratedStorage, 3} storage := NewStorage(restOptions, nil, nil) return storage.Pod, server }
func newStorage(t *testing.T) (*REST, *StatusREST, *InternalREST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, latest.Version.Group) imageStorage, statusStorage, internalStorage, err := NewREST(restoptions.NewSimpleGetter(etcdStorage), noDefaultRegistry, &fakeSubjectAccessReviewRegistry{}, &testutil.FakeImageStreamLimitVerifier{}) if err != nil { t.Fatal(err) } return imageStorage, statusStorage, internalStorage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, latest.Version.Group) storage, err := NewREST(restoptions.NewSimpleGetter(etcdStorage)) if err != nil { t.Fatal(err) } return storage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") storage, _, _, err := NewREST(restoptions.NewSimpleGetter(etcdStorage), testclient.NewSimpleFake()) if err != nil { t.Fatal(err) } return storage, server }
func newStorage(t *testing.T, allocator routetypes.RouteAllocator) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") storage, _, err := NewREST(restoptions.NewSimpleGetter(etcdStorage), allocator) if err != nil { t.Fatal(err) } return storage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, federation.GroupName) restOptions := generic.RESTOptions{ Storage: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1} storage, _ := NewREST(restOptions) return storage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1} storage, err := NewStorage(restOptions, kubeletclient.KubeletClientConfig{}, nil) if err != nil { t.Fatal(err) } return storage.Node, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "endpoints", } return NewREST(restOptions), server }
func newStorage(t *testing.T) (*ScaleREST, *etcdtesting.EtcdTestServer, storage.Interface, factory.DestroyFunc) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "controllers"} s, d := generic.NewRawStorage(etcdStorage) destroyFunc := func() { d() server.Terminate(t) } return NewStorage(restOptions).Scale, server, s, destroyFunc }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, extensions.GroupName) restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "thirdpartyresources", } return NewREST(restOptions), server }
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, autoscaling.GroupName) restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "horizontalpodautoscalers", } horizontalPodAutoscalerStorage, statusStorage := NewREST(restOptions) return horizontalPodAutoscalerStorage, statusStorage, server }
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 3, ResourcePrefix: "pods", } storage := NewStorage(restOptions, nil, nil, nil) return storage.Pod, storage.Binding, storage.Status, server }
func newStorage(t *testing.T) (*JobStorage, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, batch.GroupName) restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "jobs", } jobStorage := NewStorage(restOptions) return &jobStorage, server }
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, extensions.GroupName) restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "daemonsets", } daemonSetStorage, statusStorage := NewREST(restOptions) return daemonSetStorage, statusStorage, server }
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "persistentvolumes", } persistentVolumeStorage, statusStorage := NewREST(restOptions) return persistentVolumeStorage, statusStorage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, storageapi.GroupName) restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "storageclasses", } storageClassStorage := NewREST(restOptions) return storageClassStorage, server }
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) { storageConfig, server := registrytest.NewEtcdStorage(t, federation.GroupName) restOptions := generic.RESTOptions{ StorageConfig: storageConfig, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "clusters", } storage, _ := NewREST(restOptions) return storage, server }
func newStorage(t *testing.T) (ControllerStorage, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{ StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "replicationcontrollers", } storage := NewStorage(restOptions) return storage, server }
func setup(t *testing.T) (*etcd.Client, *etcdtesting.EtcdTestServer, *REST) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") imageStorage := imageetcd.NewREST(etcdStorage) imageStreamStorage, imageStreamStatus, internalStorage := imagestreametcd.NewREST(etcdStorage, testDefaultRegistry, &fakeSubjectAccessReviewRegistry{}) imageRegistry := image.NewRegistry(imageStorage) imageStreamRegistry := imagestream.NewRegistry(imageStreamStorage, imageStreamStatus, internalStorage) storage := NewREST(imageRegistry, imageStreamRegistry) return server.Client, server, storage }
func newStorage(t *testing.T) (*tools.FakeEtcdClient, ipallocator.Interface, allocator.Interface) { etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "") _, cidr, err := net.ParseCIDR("192.168.1.0/24") if err != nil { t.Fatal(err) } var backing allocator.Interface storage := ipallocator.NewAllocatorCIDRRange(cidr, func(max int, rangeSpec string) allocator.Interface { mem := allocator.NewAllocationMap(max, rangeSpec) backing = mem etcd := allocator_etcd.NewEtcd(mem, "/ranges/serviceips", "serviceipallocation", etcdStorage) return etcd }) return fakeClient, storage, backing }
func TestPodLogValidates(t *testing.T) { etcdStorage, _ := registrytest.NewEtcdStorage(t, "") storage := NewStorage(etcdStorage, false, nil) negativeOne := int64(-1) testCases := []*api.PodLogOptions{ {SinceSeconds: &negativeOne}, {TailLines: &negativeOne}, } for _, tc := range testCases { _, err := storage.Log.Get(api.NewDefaultContext(), "test", tc) if !errors.IsInvalid(err) { t.Fatalf("unexpected error: %v", err) } } }
func newStorage(t *testing.T) (*etcdtesting.EtcdTestServer, ipallocator.Interface, allocator.Interface, storage.Interface) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") _, cidr, err := net.ParseCIDR("192.168.1.0/24") if err != nil { t.Fatal(err) } var backing allocator.Interface storage := ipallocator.NewAllocatorCIDRRange(cidr, func(max int, rangeSpec string) allocator.Interface { mem := allocator.NewAllocationMap(max, rangeSpec) backing = mem etcd := allocatoretcd.NewEtcd(mem, "/ranges/serviceips", api.Resource("serviceipallocations"), etcdStorage) return etcd }) return server, storage, backing, generic.NewRawStorage(etcdStorage) }
func TestPodLogValidates(t *testing.T) { etcdStorage, _ := registrytest.NewEtcdStorage(t, "") store := ®istry.Store{ Storage: etcdStorage, } logRest := &LogREST{Store: store, KubeletConn: nil} negativeOne := int64(-1) testCases := []*api.PodLogOptions{ {SinceSeconds: &negativeOne}, {TailLines: &negativeOne}, } for _, tc := range testCases { _, err := logRest.Get(api.NewDefaultContext(), "test", tc) if !errors.IsInvalid(err) { t.Fatalf("unexpected error: %v", err) } } }
func TestNewMasterLeasesHasCorrectTTL(t *testing.T) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") defer server.Terminate(t) masterLeases := newMasterLeases(etcdStorage) if err := masterLeases.UpdateLease("1.2.3.4"); err != nil { t.Fatalf("error updating lease: %v", err) } etcdClient := server.Client keys := client.NewKeysAPI(etcdClient) resp, err := keys.Get(context.Background(), etcdtest.PathPrefix()+"/masterleases/1.2.3.4", nil) if err != nil { t.Fatalf("error getting key: %v", err) } ttl := resp.Node.TTLDuration() if ttl > 15*time.Second || ttl < 10*time.Second { t.Errorf("ttl %v should be ~ 15s", ttl) } }
func setup(t *testing.T) (etcd.KeysAPI, *etcdtesting.EtcdTestServer, *REST) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") etcdClient := etcd.NewKeysAPI(server.Client) imageStorage, err := imageetcd.NewREST(restoptions.NewSimpleGetter(etcdStorage)) if err != nil { t.Fatal(err) } imageStreamStorage, imageStreamStatus, internalStorage, err := imagestreametcd.NewREST(restoptions.NewSimpleGetter(etcdStorage), testDefaultRegistry, &fakeSubjectAccessReviewRegistry{}, &testutil.FakeImageStreamLimitVerifier{}) if err != nil { t.Fatal(err) } imageRegistry := image.NewRegistry(imageStorage) imageStreamRegistry := imagestream.NewRegistry(imageStreamStorage, imageStreamStatus, internalStorage) storage := NewREST(imageRegistry, imageStreamRegistry) return etcdClient, server, storage }
func TestNewMasterLeasesHasCorrectTTL(t *testing.T) { etcdStorage, server := registrytest.NewEtcdStorage(t, "") restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1} storageInterface, _ := restOptions.Decorator(restOptions.StorageConfig, 0, nil, "masterleases", nil, nil, nil) defer server.Terminate(t) masterLeases := newMasterLeases(storageInterface) if err := masterLeases.UpdateLease("1.2.3.4"); err != nil { t.Fatalf("error updating lease: %v", err) } etcdClient := server.Client keys := client.NewKeysAPI(etcdClient) resp, err := keys.Get(context.Background(), etcdtest.PathPrefix()+"/masterleases/1.2.3.4", nil) if err != nil { t.Fatalf("error getting key: %v", err) } ttl := resp.Node.TTLDuration() if ttl > 15*time.Second || ttl < 10*time.Second { t.Errorf("ttl %v should be ~ 15s", ttl) } }
func TestPodLogValidates(t *testing.T) { config, server := registrytest.NewEtcdStorage(t, "") defer server.Terminate(t) s, destroyFunc := generic.NewRawStorage(config) defer destroyFunc() store := &genericregistry.Store{ Storage: s, } logRest := &LogREST{Store: store, KubeletConn: nil} negativeOne := int64(-1) testCases := []*api.PodLogOptions{ {SinceSeconds: &negativeOne}, {TailLines: &negativeOne}, } for _, tc := range testCases { _, err := logRest.Get(genericapirequest.NewDefaultContext(), "test", tc) if !errors.IsInvalid(err) { t.Fatalf("unexpected error: %v", err) } } }
func newStorage(t *testing.T) (*DeploymentStorage, *etcdtesting.EtcdTestServer) { etcdStorage, server := registrytest.NewEtcdStorage(t, extensions.GroupName) restOptions := generic.RESTOptions{etcdStorage, generic.UndecoratedStorage} deploymentStorage := NewStorage(restOptions) return &deploymentStorage, server }
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient) { etcdStorage, fakeClient := registrytest.NewEtcdStorage(t, "experimental") ingressStorage := NewREST(etcdStorage) return ingressStorage, fakeClient }