diff --git a/pkg/client/limit_ranges_test.go b/pkg/client/limit_ranges_test.go index b7e0565169..e4eb1fcebb 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 2753a26274..7d9810adeb 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 f299ed9d89..28777c0f85 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 df153d81e6..10e3ca70da 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 5c36ebb3fd..dc81e42907 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 905f0fddb5..e8946a9f02 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 c2ebc2079b..8874e0e104 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 a2e960941d..bdc0f9af14 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 df6e41d3e2..4b447d46f6 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 7d45ae479e..c7b115665d 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())