From 0d81f5901bf23e07e298fd01df86685f8eba4283 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 15:09:12 -0700 Subject: [PATCH 1/7] add v1 items to runtime/unstructured_test.go --- pkg/runtime/unstructured_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/runtime/unstructured_test.go b/pkg/runtime/unstructured_test.go index 71e8147d715..16eba5dab09 100644 --- a/pkg/runtime/unstructured_test.go +++ b/pkg/runtime/unstructured_test.go @@ -29,6 +29,8 @@ func TestDecodeUnstructured(t *testing.T) { &api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}}, &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)}, &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)}, + &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`)}, + &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: "v1"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`)}, &runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}}, }, } From b61658d064e42c5e160b55e26bea82ee52af4e03 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 16:05:40 -0700 Subject: [PATCH 2/7] add v1 item in pkg/runtime/helper_test.go --- pkg/runtime/helper_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/runtime/helper_test.go b/pkg/runtime/helper_test.go index f32e85f10da..97d4da51bcb 100644 --- a/pkg/runtime/helper_test.go +++ b/pkg/runtime/helper_test.go @@ -138,6 +138,7 @@ func TestDecodeList(t *testing.T) { Items: []runtime.Object{ &api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}}, &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1beta3"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`)}, + &runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: "v1"}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`)}, &runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}}, }, } From 97b29c7fe6bafa7dc640f70e14a6dbf7b8c77f46 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 16:07:00 -0700 Subject: [PATCH 3/7] in pkg/kubelet/config/commont_test.go, remove check for v1beta1, add test cases for all registered version --- pkg/kubelet/config/common_test.go | 78 +++++++++++++++---------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/pkg/kubelet/config/common_test.go b/pkg/kubelet/config/common_test.go index d311c6b3af5..cb19deeed7a 100644 --- a/pkg/kubelet/config/common_test.go +++ b/pkg/kubelet/config/common_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" "github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext" @@ -56,11 +57,6 @@ func TestDecodeSinglePod(t *testing.T) { t.Errorf("unexpected error: %v", err) } parsed, podOut, err := tryDecodeSinglePod(json, noDefault) - if testapi.Version() == "v1beta1" { - // v1beta1 conversion leaves empty lists that should be nil - podOut.Spec.Containers[0].Resources.Limits = nil - podOut.Spec.Containers[0].Resources.Requests = nil - } if !parsed { t.Errorf("expected to have parsed file: (%s)", string(json)) } @@ -71,24 +67,26 @@ func TestDecodeSinglePod(t *testing.T) { t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(json)) } - externalPod, err := testapi.Converter().ConvertToVersion(pod, "v1beta3") - if err != nil { - t.Errorf("unexpected error: %v", err) - } - yaml, err := yaml.Marshal(externalPod) - if err != nil { - t.Errorf("unexpected error: %v", err) - } + for _, version := range registered.RegisteredVersions { + externalPod, err := testapi.Converter().ConvertToVersion(pod, version) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + yaml, err := yaml.Marshal(externalPod) + if err != nil { + t.Errorf("unexpected error: %v", err) + } - parsed, podOut, err = tryDecodeSinglePod(yaml, noDefault) - if !parsed { - t.Errorf("expected to have parsed file: (%s)", string(yaml)) - } - if err != nil { - t.Errorf("unexpected error: %v (%s)", err, string(yaml)) - } - if !reflect.DeepEqual(pod, podOut) { - t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(yaml)) + parsed, podOut, err = tryDecodeSinglePod(yaml, noDefault) + if !parsed { + t.Errorf("expected to have parsed file: (%s)", string(yaml)) + } + if err != nil { + t.Errorf("unexpected error: %v (%s)", err, string(yaml)) + } + if !reflect.DeepEqual(pod, podOut) { + t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(yaml)) + } } } @@ -137,23 +135,25 @@ func TestDecodePodList(t *testing.T) { t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", podList, &podListOut, string(json)) } - externalPodList, err := testapi.Converter().ConvertToVersion(podList, "v1beta3") - if err != nil { - t.Errorf("unexpected error: %v", err) - } - yaml, err := yaml.Marshal(externalPodList) - if err != nil { - t.Errorf("unexpected error: %v", err) - } + for _, version := range registered.RegisteredVersions { + externalPodList, err := testapi.Converter().ConvertToVersion(podList, version) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + yaml, err := yaml.Marshal(externalPodList) + if err != nil { + t.Errorf("unexpected error: %v", err) + } - parsed, podListOut, err = tryDecodePodList(yaml, noDefault) - if !parsed { - t.Errorf("expected to have parsed file: (%s)", string(yaml)) - } - if err != nil { - t.Errorf("unexpected error: %v (%s)", err, string(yaml)) - } - if !reflect.DeepEqual(podList, &podListOut) { - t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, &podListOut, string(yaml)) + parsed, podListOut, err = tryDecodePodList(yaml, noDefault) + if !parsed { + t.Errorf("expected to have parsed file: (%s)", string(yaml)) + } + if err != nil { + t.Errorf("unexpected error: %v (%s)", err, string(yaml)) + } + if !reflect.DeepEqual(podList, &podListOut) { + t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, &podListOut, string(yaml)) + } } } From cb123dc957d202bc80b89e2b0bfa71feaff4528d Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 16:48:05 -0700 Subject: [PATCH 4/7] in api/testapi/testapt_test.go, remove tests for v1beta1, add tests for v1 --- pkg/api/testapi/testapi_test.go | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/api/testapi/testapi_test.go b/pkg/api/testapi/testapi_test.go index 77182c4458b..253c3b735d2 100644 --- a/pkg/api/testapi/testapi_test.go +++ b/pkg/api/testapi/testapi_test.go @@ -46,9 +46,9 @@ func TestResourcePathWithPrefixForV1Beta3(t *testing.T) { } } -func TestResourcePathWithPrefixForV1Beta1(t *testing.T) { - if Version() != "v1beta1" { - // Skip the test if we are not testing v1beta1. +func TestResourcePathWithPrefixForV1(t *testing.T) { + if Version() != "v1" { + // Skip the test if we are not testing v1. return } @@ -59,11 +59,11 @@ func TestResourcePathWithPrefixForV1Beta1(t *testing.T) { name string expected string }{ - {"prefix", "resource", "mynamespace", "myresource", "/api/v1beta1/prefix/resource/myresource"}, - {"prefix", "resource", "", "myresource", "/api/v1beta1/prefix/resource/myresource"}, - {"prefix", "resource", "mynamespace", "", "/api/v1beta1/prefix/resource"}, - {"prefix", "resource", "", "", "/api/v1beta1/prefix/resource"}, - {"", "resource", "mynamespace", "myresource", "/api/v1beta1/resource/myresource"}, + {"prefix", "resource", "mynamespace", "myresource", "/api/v1/prefix/namespaces/mynamespace/resource/myresource"}, + {"prefix", "resource", "", "myresource", "/api/v1/prefix/resource/myresource"}, + {"prefix", "resource", "mynamespace", "", "/api/v1/prefix/namespaces/mynamespace/resource"}, + {"prefix", "resource", "", "", "/api/v1/prefix/resource"}, + {"", "resource", "mynamespace", "myresource", "/api/v1/namespaces/mynamespace/resource/myresource"}, } for _, item := range testCases { if actual := ResourcePathWithPrefix(item.prefix, item.resource, item.namespace, item.name); actual != item.expected { @@ -96,9 +96,9 @@ func TestResourcePathForV1Beta3(t *testing.T) { } } -func TestResourcePathForV1Beta1(t *testing.T) { - if Version() != "v1beta1" { - // Skip the test if we are not testing v1beta1. +func TestResourcePathForV1(t *testing.T) { + if Version() != "v1" { + // Skip the test if we are not testing v1. return } @@ -108,10 +108,10 @@ func TestResourcePathForV1Beta1(t *testing.T) { name string expected string }{ - {"resource", "mynamespace", "myresource", "/api/v1beta1/resource/myresource"}, - {"resource", "", "myresource", "/api/v1beta1/resource/myresource"}, - {"resource", "mynamespace", "", "/api/v1beta1/resource"}, - {"resource", "", "", "/api/v1beta1/resource"}, + {"resource", "mynamespace", "myresource", "/api/v1/namespaces/mynamespace/resource/myresource"}, + {"resource", "", "myresource", "/api/v1/resource/myresource"}, + {"resource", "mynamespace", "", "/api/v1/namespaces/mynamespace/resource"}, + {"resource", "", "", "/api/v1/resource"}, } for _, item := range testCases { if actual := ResourcePath(item.resource, item.namespace, item.name); actual != item.expected { @@ -144,9 +144,9 @@ func TestResourcePathWithNamespaceQueryForV1Beta3(t *testing.T) { } } -func TestResourcePathWithNamespaceQueryForV1Beta1(t *testing.T) { - if Version() != "v1beta1" { - // Skip the test if we are not testing v1beta1. +func TestResourcePathWithNamespaceQueryForV1(t *testing.T) { + if Version() != "v1" { + // Skip the test if we are not testing v1. return } @@ -156,10 +156,10 @@ func TestResourcePathWithNamespaceQueryForV1Beta1(t *testing.T) { name string expected string }{ - {"resource", "mynamespace", "myresource", "/api/v1beta1/resource/myresource?namespace=mynamespace"}, - {"resource", "", "myresource", "/api/v1beta1/resource/myresource"}, - {"resource", "mynamespace", "", "/api/v1beta1/resource?namespace=mynamespace"}, - {"resource", "", "", "/api/v1beta1/resource"}, + {"resource", "mynamespace", "myresource", "/api/v1/namespaces/mynamespace/resource/myresource"}, + {"resource", "", "myresource", "/api/v1/resource/myresource"}, + {"resource", "mynamespace", "", "/api/v1/namespaces/mynamespace/resource"}, + {"resource", "", "", "/api/v1/resource"}, } for _, item := range testCases { if actual := ResourcePathWithNamespaceQuery(item.resource, item.namespace, item.name); actual != item.expected { From 2ee8eb67a9fed6977154649ff8c94dc415de74b9 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 16:50:40 -0700 Subject: [PATCH 5/7] remove import of v1beta3 package in api/conversion_test.go --- pkg/api/conversion_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/api/conversion_test.go b/pkg/api/conversion_test.go index 47832eb37bb..b552d17f633 100644 --- a/pkg/api/conversion_test.go +++ b/pkg/api/conversion_test.go @@ -22,7 +22,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi" - _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3" ) func BenchmarkPodConversion(b *testing.B) { From 6b81c064eda8afc8896b1ed774895469fda72f13 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 17:50:22 -0700 Subject: [PATCH 6/7] change v1beta3 to v1 in test cases --- pkg/apiserver/api_installer_test.go | 4 ++-- pkg/client/record/events_cache_test.go | 6 +++--- pkg/kubectl/cmd/expose_test.go | 8 ++++---- pkg/kubectl/cmd/util/factory_test.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/apiserver/api_installer_test.go b/pkg/apiserver/api_installer_test.go index 1dd42cce2cd..302db3e85e2 100644 --- a/pkg/apiserver/api_installer_test.go +++ b/pkg/apiserver/api_installer_test.go @@ -28,14 +28,14 @@ import ( func TestScopeNamingGenerateLink(t *testing.T) { selfLinker := &setTestSelfLinker{ t: t, - expectedSet: "/api/v1beta3/namespaces/other/services/foo", + expectedSet: "/api/v1/namespaces/other/services/foo", name: "foo", namespace: "other", } s := scopeNaming{ meta.RESTScopeNamespace, selfLinker, - "/api/v1beta3/namespaces/{namespace}/services/{name}", + "/api/v1/namespaces/{namespace}/services/{name}", true, } service := &api.Service{ diff --git a/pkg/client/record/events_cache_test.go b/pkg/client/record/events_cache_test.go index f086ef88ef8..3adbd9cf44b 100644 --- a/pkg/client/record/events_cache_test.go +++ b/pkg/client/record/events_cache_test.go @@ -67,7 +67,7 @@ func TestAddOrUpdateEventExisting(t *testing.T) { Name: "anOkName", Namespace: "someNamespace", UID: "C934D3234CD0242", - APIVersion: "v1beta2", + APIVersion: "version", }, Source: api.EventSource{ Component: "kubelet", @@ -88,7 +88,7 @@ func TestAddOrUpdateEventExisting(t *testing.T) { Name: "anOkName", Namespace: "someNamespace", UID: "C934D3234CD0242", - APIVersion: "v1beta2", + APIVersion: "version", }, Source: api.EventSource{ Component: "kubelet", @@ -119,7 +119,7 @@ func TestGetEventNoExisting(t *testing.T) { Name: "iAmAController", Namespace: "IHaveANamespace", UID: "9039D34AFBCDA42", - APIVersion: "v1beta3", + APIVersion: "version", }, Source: api.EventSource{ Component: "kubelet", diff --git a/pkg/kubectl/cmd/expose_test.go b/pkg/kubectl/cmd/expose_test.go index f1189fc6127..09746fdfef3 100644 --- a/pkg/kubectl/cmd/expose_test.go +++ b/pkg/kubectl/cmd/expose_test.go @@ -49,7 +49,7 @@ func TestRunExposeService(t *testing.T) { }, input: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "baz", Namespace: "test", ResourceVersion: "12"}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, Spec: api.ServiceSpec{ Selector: map[string]string{"app": "go"}, }, @@ -57,7 +57,7 @@ func TestRunExposeService(t *testing.T) { flags: map[string]string{"selector": "func=stream", "protocol": "UDP", "port": "14", "name": "foo", "labels": "svc=test"}, output: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test", ResourceVersion: "12", Labels: map[string]string{"svc": "test"}}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, Spec: api.ServiceSpec{ Ports: []api.ServicePort{ { @@ -82,7 +82,7 @@ func TestRunExposeService(t *testing.T) { }, input: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "mayor", Namespace: "default", ResourceVersion: "12"}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, Spec: api.ServiceSpec{ Selector: map[string]string{"run": "this"}, }, @@ -91,7 +91,7 @@ func TestRunExposeService(t *testing.T) { flags: map[string]string{"selector": "run=this", "port": "80", "labels": "runas=amayor"}, output: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "mayor", Namespace: "default", ResourceVersion: "12", Labels: map[string]string{"runas": "amayor"}}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, Spec: api.ServiceSpec{ Ports: []api.ServicePort{ { diff --git a/pkg/kubectl/cmd/util/factory_test.go b/pkg/kubectl/cmd/util/factory_test.go index ead27c09474..e24609d416a 100644 --- a/pkg/kubectl/cmd/util/factory_test.go +++ b/pkg/kubectl/cmd/util/factory_test.go @@ -117,7 +117,7 @@ func TestLabelsForObject(t *testing.T) { name: "successful re-use of labels", object: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "baz", Namespace: "test", Labels: map[string]string{"svc": "test"}}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, }, expected: "svc=test", err: nil, @@ -126,7 +126,7 @@ func TestLabelsForObject(t *testing.T) { name: "empty labels", object: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test", Labels: map[string]string{}}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, }, expected: "", err: nil, @@ -135,7 +135,7 @@ func TestLabelsForObject(t *testing.T) { name: "nil labels", object: &api.Service{ ObjectMeta: api.ObjectMeta{Name: "zen", Namespace: "test", Labels: nil}, - TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1beta3"}, + TypeMeta: api.TypeMeta{Kind: "Service", APIVersion: "v1"}, }, expected: "", err: nil, From ca72165b20f46cad6305e287e24d498e3c5dc5db Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Wed, 3 Jun 2015 20:09:03 -0700 Subject: [PATCH 7/7] remove most references to api.PreV1Beta3 --- pkg/client/limit_ranges_test.go | 3 - pkg/client/nodes_test.go | 3 - pkg/client/persistentvolume_test.go | 3 - pkg/client/persistentvolumeclaim_test.go | 3 - pkg/client/pod_templates_test.go | 24 ---- pkg/client/replication_controllers_test.go | 3 - pkg/client/resource_quotas_test.go | 3 - pkg/controller/replication_controller_test.go | 5 +- pkg/kubectl/resource_printer_test.go | 15 +-- pkg/kubelet/config/file_test.go | 120 ------------------ 10 files changed, 2 insertions(+), 180 deletions(-) diff --git a/pkg/client/limit_ranges_test.go b/pkg/client/limit_ranges_test.go index b7e05651693..e4eb1fcebb1 100644 --- a/pkg/client/limit_ranges_test.go +++ b/pkg/client/limit_ranges_test.go @@ -28,9 +28,6 @@ import ( ) func getLimitRangesResourceName() string { - if api.PreV1Beta3(testapi.Version()) { - return "limitRanges" - } return "limitranges" } diff --git a/pkg/client/nodes_test.go b/pkg/client/nodes_test.go index 2753a262748..7d9810adeb5 100644 --- a/pkg/client/nodes_test.go +++ b/pkg/client/nodes_test.go @@ -28,9 +28,6 @@ import ( ) func getNodesResourceName() string { - if api.PreV1Beta3(testapi.Version()) { - return "minions" - } return "nodes" } diff --git a/pkg/client/persistentvolume_test.go b/pkg/client/persistentvolume_test.go index f299ed9d893..28777c0f85e 100644 --- a/pkg/client/persistentvolume_test.go +++ b/pkg/client/persistentvolume_test.go @@ -28,9 +28,6 @@ import ( ) func getPersistentVolumesResoureName() string { - if api.PreV1Beta3(testapi.Version()) { - return "persistentVolumes" - } return "persistentvolumes" } diff --git a/pkg/client/persistentvolumeclaim_test.go b/pkg/client/persistentvolumeclaim_test.go index df153d81e69..10e3ca70daf 100644 --- a/pkg/client/persistentvolumeclaim_test.go +++ b/pkg/client/persistentvolumeclaim_test.go @@ -28,9 +28,6 @@ import ( ) func getPersistentVolumeClaimsResoureName() string { - if api.PreV1Beta3(testapi.Version()) { - return "persistentVolumeClaims" - } return "persistentvolumeclaims" } diff --git a/pkg/client/pod_templates_test.go b/pkg/client/pod_templates_test.go index 5c36ebb3fd1..dc81e429079 100644 --- a/pkg/client/pod_templates_test.go +++ b/pkg/client/pod_templates_test.go @@ -31,10 +31,6 @@ func getPodTemplatesResoureName() string { } func TestPodTemplateCreate(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - ns := api.NamespaceDefault podTemplate := api.PodTemplate{ ObjectMeta: api.ObjectMeta{ @@ -58,10 +54,6 @@ func TestPodTemplateCreate(t *testing.T) { } func TestPodTemplateGet(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - ns := api.NamespaceDefault podTemplate := &api.PodTemplate{ ObjectMeta: api.ObjectMeta{ @@ -85,10 +77,6 @@ func TestPodTemplateGet(t *testing.T) { } func TestPodTemplateList(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - ns := api.NamespaceDefault podTemplateList := &api.PodTemplateList{ Items: []api.PodTemplate{ @@ -114,10 +102,6 @@ func TestPodTemplateList(t *testing.T) { } func TestPodTemplateUpdate(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - ns := api.NamespaceDefault podTemplate := &api.PodTemplate{ ObjectMeta: api.ObjectMeta{ @@ -136,10 +120,6 @@ func TestPodTemplateUpdate(t *testing.T) { } func TestPodTemplateDelete(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - ns := api.NamespaceDefault c := &testClient{ Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "foo"), Query: buildQueryValues(ns, nil)}, @@ -150,10 +130,6 @@ func TestPodTemplateDelete(t *testing.T) { } func TestPodTemplateWatch(t *testing.T) { - if api.PreV1Beta3(testapi.Version()) { - return - } - c := &testClient{ Request: testRequest{ Method: "GET", diff --git a/pkg/client/replication_controllers_test.go b/pkg/client/replication_controllers_test.go index 905f0fddb57..e8946a9f02b 100644 --- a/pkg/client/replication_controllers_test.go +++ b/pkg/client/replication_controllers_test.go @@ -25,9 +25,6 @@ import ( ) func getRCResourceName() string { - if api.PreV1Beta3(testapi.Version()) { - return "replicationControllers" - } return "replicationcontrollers" } diff --git a/pkg/client/resource_quotas_test.go b/pkg/client/resource_quotas_test.go index c2ebc2079b9..8874e0e1043 100644 --- a/pkg/client/resource_quotas_test.go +++ b/pkg/client/resource_quotas_test.go @@ -28,9 +28,6 @@ import ( ) func getResourceQuotasResoureName() string { - if api.PreV1Beta3(testapi.Version()) { - return "resourceQuotas" - } return "resourcequotas" } diff --git a/pkg/controller/replication_controller_test.go b/pkg/controller/replication_controller_test.go index a2e960941d0..bdc0f9af144 100644 --- a/pkg/controller/replication_controller_test.go +++ b/pkg/controller/replication_controller_test.go @@ -166,9 +166,6 @@ func validateSyncReplication(t *testing.T, fakePodControl *FakePodControl, expec } func replicationControllerResourceName() string { - if api.PreV1Beta3(testapi.Version()) { - return "replicationControllers" - } return "replicationcontrollers" } @@ -193,7 +190,7 @@ func makeTestServer(t *testing.T, namespace, name string, podResponse, controlle mux := http.NewServeMux() mux.Handle(testapi.ResourcePath("pods", namespace, ""), &fakePodHandler) mux.Handle(testapi.ResourcePath(replicationControllerResourceName(), "", ""), &fakeControllerHandler) - if !api.PreV1Beta3(testapi.Version()) && namespace != "" { + if namespace != "" { mux.Handle(testapi.ResourcePath(replicationControllerResourceName(), namespace, ""), &fakeControllerHandler) } if name != "" { diff --git a/pkg/kubectl/resource_printer_test.go b/pkg/kubectl/resource_printer_test.go index df6e41d3e27..4b447d46f65 100644 --- a/pkg/kubectl/resource_printer_test.go +++ b/pkg/kubectl/resource_printer_test.go @@ -416,20 +416,7 @@ func TestTemplateStrings(t *testing.T) { } // The point of this test is to verify that the below template works. If you change this // template, you need to update hack/e2e-suite/update.sh. - tmpl := `` - if api.PreV1Beta3(testapi.Version()) { - tmpl = `{{exists . "currentState" "info" "foo" "state" "running"}}` - useThisToDebug := ` -a: {{exists . "currentState"}} -b: {{exists . "currentState" "info"}} -c: {{exists . "currentState" "info" "foo"}} -d: {{exists . "currentState" "info" "foo" "state"}} -e: {{exists . "currentState" "info" "foo" "state" "running"}} -f: {{exists . "currentState" "info" "foo" "state" "running" "startedAt"}}` - _ = useThisToDebug // don't complain about unused var - } else { - tmpl = `{{if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "foo") (exists . "state" "running"))}}true{{end}}{{end}}{{end}}` - } + tmpl := `{{if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "foo") (exists . "state" "running"))}}true{{end}}{{end}}{{end}}` p, err := NewTemplatePrinter([]byte(tmpl)) if err != nil { t.Fatalf("tmpl fail: %v", err) diff --git a/pkg/kubelet/config/file_test.go b/pkg/kubelet/config/file_test.go index 7d45ae479e2..c7b115665d4 100644 --- a/pkg/kubelet/config/file_test.go +++ b/pkg/kubelet/config/file_test.go @@ -17,7 +17,6 @@ limitations under the License. package config import ( - "fmt" "io/ioutil" "os" "testing" @@ -68,99 +67,6 @@ func writeTestFile(t *testing.T, dir, name string, contents string) *os.File { return file } -func TestReadContainerManifestFromFile(t *testing.T) { - // ContainerManifest is supported only for pre v1beta3 versions. - if !api.PreV1Beta3(testapi.Version()) { - return - } - hostname := "random-test-hostname" - var testCases = []struct { - desc string - fileContents string - expected kubelet.PodUpdate - }{ - { - desc: "Manifest", - fileContents: fmt.Sprintf(`{ - "version": "%s", - "uuid": "12345", - "id": "test", - "containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}] - }`, testapi.Version()), - expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "test-" + hostname, - UID: "12345", - Namespace: kubelet.NamespaceDefault, - SelfLink: getSelfLink("test-"+hostname, kubelet.NamespaceDefault), - }, - Spec: api.PodSpec{ - NodeName: hostname, - RestartPolicy: api.RestartPolicyAlways, - DNSPolicy: api.DNSClusterFirst, - Containers: []api.Container{{ - Name: "image", - Image: "test/image", - TerminationMessagePath: "/dev/termination-log", - ImagePullPolicy: "Always", - SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}}, - }, - }), - }, - { - desc: "Manifest without ID", - fileContents: fmt.Sprintf(`{ - "version": "%s", - "uuid": "12345", - "containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}] - }`, testapi.Version()), - expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "12345-" + hostname, - UID: "12345", - Namespace: kubelet.NamespaceDefault, - SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault), - }, - Spec: api.PodSpec{ - NodeName: hostname, - RestartPolicy: api.RestartPolicyAlways, - DNSPolicy: api.DNSClusterFirst, - Containers: []api.Container{{ - Name: "image", - Image: "test/image", - TerminationMessagePath: "/dev/termination-log", - ImagePullPolicy: "Always", - SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}}, - }, - }), - }, - } - - for _, testCase := range testCases { - func() { - file := writeTestFile(t, os.TempDir(), "test_pod_config", testCase.fileContents) - defer os.Remove(file.Name()) - - ch := make(chan interface{}) - NewSourceFile(file.Name(), hostname, time.Millisecond, ch) - select { - case got := <-ch: - update := got.(kubelet.PodUpdate) - for _, pod := range update.Pods { - if errs := validation.ValidatePod(pod); len(errs) > 0 { - t.Errorf("%s: Invalid pod %#v, %#v", testCase.desc, pod, errs) - } - } - if !api.Semantic.DeepEqual(testCase.expected, update) { - t.Errorf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update) - } - case <-time.After(time.Second): - t.Errorf("%s: Expected update, timeout instead", testCase.desc) - } - }() - } -} - func TestReadPodsFromFile(t *testing.T) { hostname := "random-test-hostname" var testCases = []struct { @@ -276,32 +182,6 @@ func TestReadPodsFromFile(t *testing.T) { } } -func TestReadManifestFromFileWithDefaults(t *testing.T) { - if !api.PreV1Beta3(testapi.Version()) { - return - } - file := writeTestFile(t, os.TempDir(), "test_pod_config", - fmt.Sprintf(`{ - "version": "%s", - "id": "test", - "containers": [{ "name": "image", "image": "test/image" }] - }`, testapi.Version())) - defer os.Remove(file.Name()) - - ch := make(chan interface{}) - NewSourceFile(file.Name(), "localhost", time.Millisecond, ch) - select { - case got := <-ch: - update := got.(kubelet.PodUpdate) - if update.Pods[0].UID == "" { - t.Errorf("Unexpected UID: %s", update.Pods[0].UID) - } - - case <-time.After(time.Second): - t.Errorf("Expected update, timeout instead") - } -} - func TestExtractFromBadDataFile(t *testing.T) { file := writeTestFile(t, os.TempDir(), "test_pod_config", string([]byte{1, 2, 3})) defer os.Remove(file.Name())