func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Deployment.Etcd) test.TestUpdate( // valid validNewDeployment(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Deployment) object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"} return object }, // invalid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Deployment) object.UID = "newUID" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Deployment) object.Name = "" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Deployment) object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Deployment) object.Spec.Selector = map[string]string{} return object }, ) }
func TestWatch(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestWatch( validController, // matching labels []labels.Set{ {"a": "b"}, }, // not matching labels []labels.Set{ {"a": "c"}, {"foo": "bar"}, }, // matching fields []fields.Set{ {"status.replicas": "0"}, {"metadata.name": "foo"}, {"status.replicas": "0", "metadata.name": "foo"}, }, // not matchin fields []fields.Set{ {"status.replicas": "10"}, {"metadata.name": "bar"}, {"name": "foo"}, {"status.replicas": "10", "metadata.name": "foo"}, {"status.replicas": "0", "metadata.name": "bar"}, }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validIngress(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Ingress) object.Spec.Rules = toIngressRules(map[string]IngressRuleValues{ "bar.foo.com": {"/bar": defaultBackendName}, }) return object }, // invalid updateFunc: ObjeceMeta is not to be tampered with. func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Ingress) object.UID = "newUID" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Ingress) object.Name = "" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Ingress) object.Spec.Rules = toIngressRules(map[string]IngressRuleValues{ "foo.bar.com": {"/invalid[": "svc"}}) return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).AllowCreateOnUpdate() test.TestUpdate( // valid validNewLimitRange(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.LimitRange) object.Spec.Limits = []api.LimitRangeItem{ { Type: api.LimitTypePod, Max: api.ResourceList{ api.ResourceCPU: resource.MustParse("1000"), api.ResourceMemory: resource.MustParse("100000"), }, Min: api.ResourceList{ api.ResourceCPU: resource.MustParse("10"), api.ResourceMemory: resource.MustParse("1000"), }, }, } return object }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) validService := validService() validService.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid validService, // invalid &api.Service{ Spec: api.ServiceSpec{}, }, // invalid &api.Service{ Spec: api.ServiceSpec{ Selector: map[string]string{"bar": "baz"}, ClusterIP: "invalid", SessionAffinity: "None", Type: api.ServiceTypeClusterIP, Ports: []api.ServicePort{{ Port: 6502, Protocol: api.ProtocolTCP, TargetPort: util.NewIntOrStringFromInt(6502), }}, }, }, ) }
func TestWatch(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestWatch( validDaemonSet, // matching labels []labels.Set{ {"a": "b"}, }, // not matching labels []labels.Set{ {"a": "c"}, {"foo": "bar"}, }, // matching fields []fields.Set{ {"metadata.name": "foo"}, }, // notmatching fields []fields.Set{ {"metadata.name": "bar"}, {"name": "foo"}, }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewController(), // valid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Spec.Replicas = object.Spec.Replicas + 1 return object }, // invalid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.UID = "newUID" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Name = "" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Spec.Selector = map[string]string{} return object }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) two := 2 test.TestUpdate( // valid validNewJob(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Job) object.Spec.Parallelism = &two return object }, // invalid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Job) object.Spec.Selector = &extensions.PodSelector{} return object }, func(obj runtime.Object) runtime.Object { object := obj.(*extensions.Job) object.Spec.Completions = &two return object }, ) }
func TestDelete(t *testing.T) { storage, _, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ReturnDeletedObject() test.TestDelete(validNewPod()) scheduledPod := validNewPod() scheduledPod.Spec.NodeName = "some-node" test.TestDeleteGraceful(scheduledPod, 30) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) rsrc := validNewThirdPartyResource("foo") rsrc.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid rsrc, // invalid &extensions.ThirdPartyResource{}, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) event := validNewEvent(test.TestNamespace()) event.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid event, // invalid &api.Event{}, ) }
func TestCreate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) autoscaler := validNewHorizontalPodAutoscaler("foo") autoscaler.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid autoscaler, // invalid &extensions.HorizontalPodAutoscaler{}, ) }
func TestCreate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) pv := validNewPersistentVolumeClaim("foo", api.NamespaceDefault) pv.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid pv, // invalid &api.PersistentVolumeClaim{ ObjectMeta: api.ObjectMeta{Name: "*BadName!"}, }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) endpoints := validNewEndpoints() endpoints.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid endpoints, // invalid &api.Endpoints{ ObjectMeta: api.ObjectMeta{Name: "_-a123-a_"}, }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewHorizontalPodAutoscaler("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.HorizontalPodAutoscaler) object.Spec.MaxReplicas = object.Spec.MaxReplicas + 1 return object }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).GeneratesName() validLimitRange := validNewLimitRange() validLimitRange.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid validLimitRange, // invalid &api.LimitRange{ ObjectMeta: api.ObjectMeta{Name: "_-a123-a_"}, }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ClusterScope() node := validNewNode() node.ObjectMeta = api.ObjectMeta{GenerateName: "foo"} test.TestCreate( // valid node, // invalid &api.Node{ ObjectMeta: api.ObjectMeta{Name: "_-a123-a_"}, }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ClusterScope() test.TestUpdate( // valid validNewNode(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Node) object.Spec.Unschedulable = !object.Spec.Unschedulable return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewServiceAccount("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ServiceAccount) // TODO: Update this serviceAccount return object }, ) }
func TestCreate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) resourcequota := validNewResourceQuota() resourcequota.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid resourcequota, // invalid &api.ResourceQuota{ ObjectMeta: api.ObjectMeta{Name: "_-a123-a_"}, }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewSecret("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Secret) object.Data["othertest"] = []byte("otherdata") return object }, ) }
func TestCreate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ClusterScope() pv := validNewPersistentVolume("foo") pv.ObjectMeta = api.ObjectMeta{GenerateName: "foo"} test.TestCreate( // valid pv, // invalid &api.PersistentVolume{ ObjectMeta: api.ObjectMeta{Name: "*BadName!"}, }, ) }
func TestUpdate(t *testing.T) { storage, _, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewPod(), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Pod) object.Labels = map[string]string{"a": "b"} return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( // valid validNewThirdPartyResource("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*extensions.ThirdPartyResource) object.Description = "new description" return object }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ClusterScope() namespace := validNewNamespace() namespace.ObjectMeta = api.ObjectMeta{GenerateName: "foo"} test.TestCreate( // valid namespace, // invalid &api.Namespace{ ObjectMeta: api.ObjectMeta{Name: "bad value"}, }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) test.TestUpdate( //valid validNewPodTemplate("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.PodTemplate) object.Template.Spec.NodeSelector = map[string]string{"a": "b"} return object }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) pod := validNewPodTemplate("foo") pod.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid pod, // invalid &api.PodTemplate{ Template: api.PodTemplateSpec{}, }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd) serviceAccount := validNewServiceAccount("foo") serviceAccount.ObjectMeta = api.ObjectMeta{GenerateName: "foo-"} test.TestCreate( // valid serviceAccount, // invalid &api.ServiceAccount{}, &api.ServiceAccount{ ObjectMeta: api.ObjectMeta{Name: "name with spaces"}, }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Etcd).ClusterScope() test.TestUpdate( // valid validNewPersistentVolume("foo"), // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.PersistentVolume) object.Spec.Capacity = api.ResourceList{ api.ResourceName(api.ResourceStorage): resource.MustParse("20G"), } return object }, ) }
func TestCreate(t *testing.T) { storage, fakeClient := newStorage(t) test := registrytest.New(t, fakeClient, storage.Deployment.Etcd) deployment := validNewDeployment() deployment.ObjectMeta = api.ObjectMeta{} test.TestCreate( // valid deployment, // invalid (invalid selector) &extensions.Deployment{ Spec: extensions.DeploymentSpec{ Selector: map[string]string{}, Template: validDeployment.Spec.Template, }, }, ) }