diff --git a/hack/verify-flags/exceptions.txt b/hack/verify-flags/exceptions.txt index a27cf2534ae..f0de06547d0 100644 --- a/hack/verify-flags/exceptions.txt +++ b/hack/verify-flags/exceptions.txt @@ -94,7 +94,7 @@ pkg/util/oom/oom_linux.go: return fmt.Errorf("invalid PID %d specified for oom_ pkg/util/oom/oom_linux.go: oomScoreAdjPath := path.Join("/proc", pidStr, "oom_score_adj") pkg/util/oom/oom_linux.go:// Writes 'value' to /proc//oom_score_adj for all processes in cgroup cgroupName. pkg/util/oom/oom_linux.go:// Writes 'value' to /proc//oom_score_adj. PID = 0 means self -test/e2e/configmap.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=/etc/configmap-volume/data-1"}, +test/e2e/common/configmap.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=/etc/configmap-volume/data-1"}, test/e2e/common/downwardapi_volume.go: Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=" + filePath}, test/e2e/es_cluster_logging.go: framework.Failf("No cluster_name field in Elasticsearch response: %v", esResponse) test/e2e/es_cluster_logging.go: // Check to see if have a cluster_name field. diff --git a/test/e2e/configmap.go b/test/e2e/common/configmap.go similarity index 97% rename from test/e2e/configmap.go rename to test/e2e/common/configmap.go index f8d6b48a259..554120a5144 100644 --- a/test/e2e/configmap.go +++ b/test/e2e/common/configmap.go @@ -1,5 +1,5 @@ /* -Copyright 2014 The Kubernetes Authors. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package e2e +package common import ( "fmt" @@ -127,13 +127,10 @@ var _ = framework.KubeDescribe("ConfigMap", func() { defer func() { By("Deleting the pod") - f.Client.Pods(f.Namespace.Name).Delete(pod.Name, api.NewDeleteOptions(0)) + f.PodClient().Delete(pod.Name, api.NewDeleteOptions(0)) }() By("Creating the pod") - pod, err = f.Client.Pods(f.Namespace.Name).Create(pod) - Expect(err).NotTo(HaveOccurred()) - - framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.Client, pod)) + f.PodClient().CreateSync(pod) pollLogs := func() (string, error) { return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) diff --git a/test/e2e/docker_containers.go b/test/e2e/common/docker_containers.go similarity index 97% rename from test/e2e/docker_containers.go rename to test/e2e/common/docker_containers.go index 2b2bf008cda..329c2faa7ba 100644 --- a/test/e2e/docker_containers.go +++ b/test/e2e/common/docker_containers.go @@ -1,5 +1,5 @@ /* -Copyright 2015 The Kubernetes Authors. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package e2e +package common import ( "k8s.io/kubernetes/pkg/api" diff --git a/test/e2e/downward_api.go b/test/e2e/common/downward_api.go similarity index 98% rename from test/e2e/downward_api.go rename to test/e2e/common/downward_api.go index a35167e52ac..9f9a6c52a1e 100644 --- a/test/e2e/downward_api.go +++ b/test/e2e/common/downward_api.go @@ -1,5 +1,5 @@ /* -Copyright 2015 The Kubernetes Authors. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package e2e +package common import ( "fmt" diff --git a/test/e2e/expansion.go b/test/e2e/common/expansion.go similarity index 98% rename from test/e2e/expansion.go rename to test/e2e/common/expansion.go index 30860bbe1b3..c7be116541e 100644 --- a/test/e2e/expansion.go +++ b/test/e2e/common/expansion.go @@ -1,5 +1,5 @@ /* -Copyright 2015 The Kubernetes Authors. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package e2e +package common import ( "k8s.io/kubernetes/pkg/api" diff --git a/test/e2e/secrets.go b/test/e2e/common/secrets.go similarity index 99% rename from test/e2e/secrets.go rename to test/e2e/common/secrets.go index 58b9784d9b4..e542d07eae0 100644 --- a/test/e2e/secrets.go +++ b/test/e2e/common/secrets.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package e2e +package common import ( "fmt" diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index e19b1633391..aa16a251586 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4319,6 +4319,7 @@ func ScaleRCByLabels(client *client.Client, ns string, l map[string]string, repl return nil } +// TODO(random-liu): Change this to be a member function of the framework. func GetPodLogs(c *client.Client, namespace, podName, containerName string) (string, error) { return getPodLogsInternal(c, namespace, podName, containerName, false) } diff --git a/test/e2e_node/configmap_test.go b/test/e2e_node/configmap_test.go deleted file mode 100644 index 6dd06dbd574..00000000000 --- a/test/e2e_node/configmap_test.go +++ /dev/null @@ -1,335 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e_node - -import ( - "fmt" - "time" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/util/uuid" - "k8s.io/kubernetes/test/e2e/framework" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = framework.KubeDescribe("ConfigMap", func() { - - f := framework.NewDefaultFramework("configmap") - - It("should be consumable from pods in volume [Conformance]", func() { - doConfigMapE2EWithoutMappings(f, 0, 0) - }) - - It("should be consumable from pods in volume as non-root [Conformance]", func() { - doConfigMapE2EWithoutMappings(f, 1000, 0) - }) - - It("should be consumable from pods in volume as non-root with FSGroup [Feature:FSGroup]", func() { - doConfigMapE2EWithoutMappings(f, 1000, 1001) - }) - - It("should be consumable from pods in volume with mappings [Conformance]", func() { - doConfigMapE2EWithMappings(f, 0, 0) - }) - - It("should be consumable from pods in volume with mappings as non-root [Conformance]", func() { - doConfigMapE2EWithMappings(f, 1000, 0) - }) - - It("should be consumable from pods in volume with mappings as non-root with FSGroup [Feature:FSGroup]", func() { - doConfigMapE2EWithMappings(f, 1000, 1001) - }) - - It("updates should be reflected in volume [Conformance]", func() { - - // We may have to wait or a full sync period to elapse before the - // Kubelet projects the update into the volume and the container picks - // it up. This timeout is based on the default Kubelet sync period (1 - // minute) plus additional time for fudge factor. - const podLogTimeout = 300 * time.Second - - name := "configmap-test-upd-" + string(uuid.NewUUID()) - volumeName := "configmap-volume" - volumeMountPath := "/etc/configmap-volume" - containerName := "configmap-volume-test" - - configMap := &api.ConfigMap{ - ObjectMeta: api.ObjectMeta{ - Namespace: f.Namespace.Name, - Name: name, - }, - Data: map[string]string{ - "data-1": "value-1", - }, - } - - By(fmt.Sprintf("Creating configMap with name %s", configMap.Name)) - - var err error - if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { - framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) - } - - pod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "pod-configmaps-" + string(uuid.NewUUID()), - }, - Spec: api.PodSpec{ - Volumes: []api.Volume{ - { - Name: volumeName, - VolumeSource: api.VolumeSource{ - ConfigMap: &api.ConfigMapVolumeSource{ - LocalObjectReference: api.LocalObjectReference{ - Name: name, - }, - }, - }, - }, - }, - Containers: []api.Container{ - { - Name: containerName, - Image: ImageRegistry[mountTestImage], - Command: []string{"/mt", "--break_on_expected_content=false", "--retry_time=120", "--file_content_in_loop=/etc/configmap-volume/data-1"}, - VolumeMounts: []api.VolumeMount{ - { - Name: volumeName, - MountPath: volumeMountPath, - ReadOnly: true, - }, - }, - }, - }, - RestartPolicy: api.RestartPolicyNever, - }, - } - - By("Creating the pod") - f.PodClient().CreateSync(pod) - - pollLogs := func() (string, error) { - return framework.GetPodLogs(f.Client, f.Namespace.Name, pod.Name, containerName) - } - - Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-1")) - - By(fmt.Sprintf("Updating configmap %v", configMap.Name)) - configMap.ResourceVersion = "" // to force update - configMap.Data["data-1"] = "value-2" - _, err = f.Client.ConfigMaps(f.Namespace.Name).Update(configMap) - Expect(err).NotTo(HaveOccurred()) - - By("waiting to observe update in volume") - Eventually(pollLogs, podLogTimeout, framework.Poll).Should(ContainSubstring("value-2")) - }) - - It("should be consumable via environment variable [Conformance]", func() { - name := "configmap-test-" + string(uuid.NewUUID()) - configMap := newConfigMap(f, name) - By(fmt.Sprintf("Creating configMap %v/%v", f.Namespace.Name, configMap.Name)) - - var err error - if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { - framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) - } - - pod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "pod-configmaps-" + string(uuid.NewUUID()), - }, - Spec: api.PodSpec{ - Containers: []api.Container{ - { - Name: "env-test", - Image: ImageRegistry[busyBoxImage], - Command: []string{"sh", "-c", "env"}, - Env: []api.EnvVar{ - { - Name: "CONFIG_DATA_1", - ValueFrom: &api.EnvVarSource{ - ConfigMapKeyRef: &api.ConfigMapKeySelector{ - LocalObjectReference: api.LocalObjectReference{ - Name: name, - }, - Key: "data-1", - }, - }, - }, - }, - }, - }, - RestartPolicy: api.RestartPolicyNever, - }, - } - - f.TestContainerOutput("consume configMaps", pod, 0, []string{ - "CONFIG_DATA_1=value-1", - }) - }) -}) - -func newConfigMap(f *framework.Framework, name string) *api.ConfigMap { - return &api.ConfigMap{ - ObjectMeta: api.ObjectMeta{ - Namespace: f.Namespace.Name, - Name: name, - }, - Data: map[string]string{ - "data-1": "value-1", - "data-2": "value-2", - "data-3": "value-3", - }, - } -} - -func doConfigMapE2EWithoutMappings(f *framework.Framework, uid, fsGroup int64) { - var ( - name = "configmap-test-volume-" + string(uuid.NewUUID()) - volumeName = "configmap-volume" - volumeMountPath = "/etc/configmap-volume" - configMap = newConfigMap(f, name) - ) - - By(fmt.Sprintf("Creating configMap with name %s", configMap.Name)) - - var err error - if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { - framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) - } - - pod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "pod-configmaps-" + string(uuid.NewUUID()), - }, - Spec: api.PodSpec{ - SecurityContext: &api.PodSecurityContext{}, - Volumes: []api.Volume{ - { - Name: volumeName, - VolumeSource: api.VolumeSource{ - ConfigMap: &api.ConfigMapVolumeSource{ - LocalObjectReference: api.LocalObjectReference{ - Name: name, - }, - }, - }, - }, - }, - Containers: []api.Container{ - { - Name: "configmap-volume-test", - Image: ImageRegistry[mountTestImage], - Args: []string{"--file_content=/etc/configmap-volume/data-1"}, - VolumeMounts: []api.VolumeMount{ - { - Name: volumeName, - MountPath: volumeMountPath, - ReadOnly: true, - }, - }, - }, - }, - RestartPolicy: api.RestartPolicyNever, - }, - } - - if uid != 0 { - pod.Spec.SecurityContext.RunAsUser = &uid - } - - if fsGroup != 0 { - pod.Spec.SecurityContext.FSGroup = &fsGroup - } - - f.TestContainerOutput("consume configMaps", pod, 0, []string{ - "content of file \"/etc/configmap-volume/data-1\": value-1", - }) - -} - -func doConfigMapE2EWithMappings(f *framework.Framework, uid, fsGroup int64) { - var ( - name = "configmap-test-volume-map-" + string(uuid.NewUUID()) - volumeName = "configmap-volume" - volumeMountPath = "/etc/configmap-volume" - configMap = newConfigMap(f, name) - ) - - By(fmt.Sprintf("Creating configMap with name %s", configMap.Name)) - - var err error - if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil { - framework.Failf("unable to create test configMap %s: %v", configMap.Name, err) - } - - pod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: "pod-configmaps-" + string(uuid.NewUUID()), - }, - Spec: api.PodSpec{ - SecurityContext: &api.PodSecurityContext{}, - Volumes: []api.Volume{ - { - Name: volumeName, - VolumeSource: api.VolumeSource{ - ConfigMap: &api.ConfigMapVolumeSource{ - LocalObjectReference: api.LocalObjectReference{ - Name: name, - }, - Items: []api.KeyToPath{ - { - Key: "data-2", - Path: "path/to/data-2", - }, - }, - }, - }, - }, - }, - Containers: []api.Container{ - { - Name: "configmap-volume-test", - Image: ImageRegistry[mountTestImage], - Args: []string{"--file_content=/etc/configmap-volume/path/to/data-2"}, - VolumeMounts: []api.VolumeMount{ - { - Name: volumeName, - MountPath: volumeMountPath, - ReadOnly: true, - }, - }, - }, - }, - RestartPolicy: api.RestartPolicyNever, - }, - } - - if uid != 0 { - pod.Spec.SecurityContext.RunAsUser = &uid - } - - if fsGroup != 0 { - pod.Spec.SecurityContext.FSGroup = &fsGroup - } - - f.TestContainerOutput("consume configMaps", pod, 0, []string{ - "content of file \"/etc/configmap-volume/path/to/data-2\": value-2", - }) -} diff --git a/test/e2e_node/downward_api_test.go b/test/e2e_node/downward_api_test.go deleted file mode 100644 index 05d0bdfe6c4..00000000000 --- a/test/e2e_node/downward_api_test.go +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e_node - -import ( - "fmt" - - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/resource" - "k8s.io/kubernetes/pkg/util/uuid" - "k8s.io/kubernetes/test/e2e/framework" - - . "github.com/onsi/ginkgo" -) - -// Ported from test/e2e/downard_api_test.go - -var _ = framework.KubeDescribe("Downward API", func() { - f := framework.NewDefaultFramework("downward-api") - It("should provide pod name and namespace as env vars [Conformance]", func() { - podName := "downward-api-" + string(uuid.NewUUID()) - env := []api.EnvVar{ - { - Name: "POD_NAME", - ValueFrom: &api.EnvVarSource{ - FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1", - FieldPath: "metadata.name", - }, - }, - }, - { - Name: "POD_NAMESPACE", - ValueFrom: &api.EnvVarSource{ - FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1", - FieldPath: "metadata.namespace", - }, - }, - }, - } - - expectations := []string{ - fmt.Sprintf("POD_NAME=%v", podName), - fmt.Sprintf("POD_NAMESPACE=%v", f.Namespace.Name), - } - - testDownwardAPI(f, podName, env, expectations) - }) - - It("should provide pod IP as an env var", func() { - podName := "downward-api-" + string(uuid.NewUUID()) - env := []api.EnvVar{ - { - Name: "POD_IP", - ValueFrom: &api.EnvVarSource{ - FieldRef: &api.ObjectFieldSelector{ - APIVersion: "v1", - FieldPath: "status.podIP", - }, - }, - }, - } - - expectations := []string{ - "POD_IP=(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)\\.(?:\\d+)", - } - - testDownwardAPI(f, podName, env, expectations) - }) - - It("should provide container's limits.cpu/memory and requests.cpu/memory as env vars", func() { - podName := "downward-api-" + string(uuid.NewUUID()) - env := []api.EnvVar{ - { - Name: "CPU_LIMIT", - ValueFrom: &api.EnvVarSource{ - ResourceFieldRef: &api.ResourceFieldSelector{ - Resource: "limits.cpu", - }, - }, - }, - { - Name: "MEMORY_LIMIT", - ValueFrom: &api.EnvVarSource{ - ResourceFieldRef: &api.ResourceFieldSelector{ - Resource: "limits.memory", - }, - }, - }, - { - Name: "CPU_REQUEST", - ValueFrom: &api.EnvVarSource{ - ResourceFieldRef: &api.ResourceFieldSelector{ - Resource: "requests.cpu", - }, - }, - }, - { - Name: "MEMORY_REQUEST", - ValueFrom: &api.EnvVarSource{ - ResourceFieldRef: &api.ResourceFieldSelector{ - Resource: "requests.memory", - }, - }, - }, - } - expectations := []string{ - fmt.Sprintf("CPU_LIMIT=2"), - fmt.Sprintf("MEMORY_LIMIT=67108864"), - fmt.Sprintf("CPU_REQUEST=1"), - fmt.Sprintf("MEMORY_REQUEST=33554432"), - } - - testDownwardAPI(f, podName, env, expectations) - }) -}) - -func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, expectations []string) { - pod := &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Name: podName, - Labels: map[string]string{"name": podName}, - }, - Spec: api.PodSpec{ - Containers: []api.Container{ - { - Name: "dapi-container", - Image: ImageRegistry[busyBoxImage], - Command: []string{"sh", "-c", "env"}, - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceCPU: resource.MustParse("250m"), - api.ResourceMemory: resource.MustParse("32Mi"), - }, - Limits: api.ResourceList{ - api.ResourceCPU: resource.MustParse("1250m"), - api.ResourceMemory: resource.MustParse("64Mi"), - }, - }, - Env: env, - }, - }, - RestartPolicy: api.RestartPolicyNever, - }, - } - f.TestContainerOutputRegexp("downward api env vars", pod, 0, expectations) -}