mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
tests: Refactor agnhost image pod usage - common (part 2)
A previous commit added a few agnhost related functions that creates agnhost pods / containers for general purposes. Refactors tests to use those functions.
This commit is contained in:
parent
6d3ccd8e6c
commit
2161a97505
@ -125,7 +125,6 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
name := "configmap-test-upd-" + string(uuid.NewUUID())
|
name := "configmap-test-upd-" + string(uuid.NewUUID())
|
||||||
volumeName := "configmap-volume"
|
volumeName := "configmap-volume"
|
||||||
volumeMountPath := "/etc/configmap-volume"
|
volumeMountPath := "/etc/configmap-volume"
|
||||||
containerName := "configmap-volume-test"
|
|
||||||
|
|
||||||
configMap := &v1.ConfigMap{
|
configMap := &v1.ConfigMap{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@ -143,45 +142,14 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pod := &v1.Pod{
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, volumeName, name, volumeMountPath,
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
"--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volume/data-1")
|
||||||
Name: "pod-configmaps-" + string(uuid.NewUUID()),
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"mounttest", "--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volume/data-1"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
MountPath: volumeMountPath,
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
ginkgo.By("Creating the pod")
|
ginkgo.By("Creating the pod")
|
||||||
f.PodClient().CreateSync(pod)
|
f.PodClient().CreateSync(pod)
|
||||||
|
|
||||||
pollLogs := func() (string, error) {
|
pollLogs := func() (string, error) {
|
||||||
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName)
|
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
gomega.Eventually(pollLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-1"))
|
gomega.Eventually(pollLogs, podLogTimeout, framework.Poll).Should(gomega.ContainSubstring("value-1"))
|
||||||
@ -208,8 +176,7 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
name := "configmap-test-upd-" + string(uuid.NewUUID())
|
name := "configmap-test-upd-" + string(uuid.NewUUID())
|
||||||
volumeName := "configmap-volume"
|
volumeName := "configmap-volume"
|
||||||
volumeMountPath := "/etc/configmap-volume"
|
volumeMountPath := "/etc/configmap-volume"
|
||||||
containerName1 := "configmap-volume-data-test"
|
containerName := "configmap-volume-binary-test"
|
||||||
containerName2 := "configmap-volume-binary-test"
|
|
||||||
|
|
||||||
configMap := &v1.ConfigMap{
|
configMap := &v1.ConfigMap{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@ -230,60 +197,29 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pod := &v1.Pod{
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, volumeName, name, volumeMountPath,
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
"--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volume/data-1")
|
||||||
Name: "pod-configmaps-" + string(uuid.NewUUID()),
|
pod.Spec.Containers = append(pod.Spec.Containers, v1.Container{
|
||||||
},
|
Name: containerName,
|
||||||
Spec: v1.PodSpec{
|
Image: imageutils.GetE2EImage(imageutils.BusyBox),
|
||||||
Volumes: []v1.Volume{
|
Command: []string{"hexdump", "-C", "/etc/configmap-volume/dump.bin"},
|
||||||
{
|
VolumeMounts: []v1.VolumeMount{
|
||||||
Name: volumeName,
|
{
|
||||||
VolumeSource: v1.VolumeSource{
|
Name: volumeName,
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
MountPath: volumeMountPath,
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
ReadOnly: true,
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: containerName1,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"mounttest", "--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volume/data-1"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
MountPath: volumeMountPath,
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: containerName2,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.BusyBox),
|
|
||||||
Command: []string{"hexdump", "-C", "/etc/configmap-volume/dump.bin"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
MountPath: volumeMountPath,
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
|
|
||||||
ginkgo.By("Creating the pod")
|
ginkgo.By("Creating the pod")
|
||||||
f.PodClient().CreateSync(pod)
|
f.PodClient().CreateSync(pod)
|
||||||
|
|
||||||
pollLogs1 := func() (string, error) {
|
pollLogs1 := func() (string, error) {
|
||||||
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName1)
|
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
|
||||||
}
|
}
|
||||||
pollLogs2 := func() (string, error) {
|
pollLogs2 := func() (string, error) {
|
||||||
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, containerName2)
|
return e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[1].Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Waiting for pod with text data")
|
ginkgo.By("Waiting for pod with text data")
|
||||||
@ -603,9 +539,8 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
// Slow (~5 mins)
|
// Slow (~5 mins)
|
||||||
ginkgo.It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
|
ginkgo.It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
|
||||||
volumeMountPath := "/etc/configmap-volumes"
|
volumeMountPath := "/etc/configmap-volumes"
|
||||||
podName := "pod-configmaps-" + string(uuid.NewUUID())
|
pod, err := createNonOptionalConfigMapPod(f, volumeMountPath)
|
||||||
err := createNonOptionalConfigMapPod(f, volumeMountPath, podName)
|
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", pod.Name, f.Namespace.Name)
|
||||||
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// ConfigMap object defined for the pod, If a key is specified which is not present in the ConfigMap,
|
// ConfigMap object defined for the pod, If a key is specified which is not present in the ConfigMap,
|
||||||
@ -613,9 +548,8 @@ var _ = ginkgo.Describe("[sig-storage] ConfigMap", func() {
|
|||||||
// Slow (~5 mins)
|
// Slow (~5 mins)
|
||||||
ginkgo.It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
|
ginkgo.It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
|
||||||
volumeMountPath := "/etc/configmap-volumes"
|
volumeMountPath := "/etc/configmap-volumes"
|
||||||
podName := "pod-configmaps-" + string(uuid.NewUUID())
|
pod, err := createNonOptionalConfigMapPodWithConfig(f, volumeMountPath)
|
||||||
err := createNonOptionalConfigMapPodWithConfig(f, volumeMountPath, podName)
|
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", pod.Name, f.Namespace.Name)
|
||||||
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -649,45 +583,10 @@ func doConfigMapE2EWithoutMappings(f *framework.Framework, asUser bool, fsGroup
|
|||||||
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, volumeName, name, volumeMountPath,
|
||||||
|
"--file_content=/etc/configmap-volume/data-1", "--file_mode=/etc/configmap-volume/data-1")
|
||||||
one := int64(1)
|
one := int64(1)
|
||||||
pod := &v1.Pod{
|
pod.Spec.TerminationGracePeriodSeconds = &one
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "pod-configmaps-" + string(uuid.NewUUID()),
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
SecurityContext: &v1.PodSecurityContext{},
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "configmap-volume-test",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{
|
|
||||||
"mounttest",
|
|
||||||
"--file_content=/etc/configmap-volume/data-1",
|
|
||||||
"--file_mode=/etc/configmap-volume/data-1"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
MountPath: volumeMountPath,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
TerminationGracePeriodSeconds: &one,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if asUser {
|
if asUser {
|
||||||
setPodNonRootUser(pod)
|
setPodNonRootUser(pod)
|
||||||
@ -726,50 +625,14 @@ func doConfigMapE2EWithMappings(f *framework.Framework, asUser bool, fsGroup int
|
|||||||
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, volumeName, name, volumeMountPath,
|
||||||
|
"--file_content=/etc/configmap-volume/path/to/data-2", "--file_mode=/etc/configmap-volume/path/to/data-2")
|
||||||
one := int64(1)
|
one := int64(1)
|
||||||
pod := &v1.Pod{
|
pod.Spec.TerminationGracePeriodSeconds = &one
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
pod.Spec.Volumes[0].VolumeSource.ConfigMap.Items = []v1.KeyToPath{
|
||||||
Name: "pod-configmaps-" + string(uuid.NewUUID()),
|
{
|
||||||
},
|
Key: "data-2",
|
||||||
Spec: v1.PodSpec{
|
Path: "path/to/data-2",
|
||||||
SecurityContext: &v1.PodSecurityContext{},
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
Items: []v1.KeyToPath{
|
|
||||||
{
|
|
||||||
Key: "data-2",
|
|
||||||
Path: "path/to/data-2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "configmap-volume-test",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{
|
|
||||||
"mounttest",
|
|
||||||
"--file_content=/etc/configmap-volume/path/to/data-2",
|
|
||||||
"--file_mode=/etc/configmap-volume/path/to/data-2"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: volumeName,
|
|
||||||
MountPath: volumeMountPath,
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
TerminationGracePeriodSeconds: &one,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,63 +660,30 @@ func doConfigMapE2EWithMappings(f *framework.Framework, asUser bool, fsGroup int
|
|||||||
f.TestContainerOutputRegexp("consume configMaps", pod, 0, output)
|
f.TestContainerOutputRegexp("consume configMaps", pod, 0, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNonOptionalConfigMapPod(f *framework.Framework, volumeMountPath, podName string) error {
|
func createNonOptionalConfigMapPod(f *framework.Framework, volumeMountPath string) (*v1.Pod, error) {
|
||||||
podLogTimeout := e2epod.GetPodSecretUpdateTimeout(f.ClientSet)
|
podLogTimeout := e2epod.GetPodSecretUpdateTimeout(f.ClientSet)
|
||||||
containerTimeoutArg := fmt.Sprintf("--retry_time=%v", int(podLogTimeout.Seconds()))
|
containerTimeoutArg := fmt.Sprintf("--retry_time=%v", int(podLogTimeout.Seconds()))
|
||||||
falseValue := false
|
falseValue := false
|
||||||
|
|
||||||
createName := "cm-test-opt-create-" + string(uuid.NewUUID())
|
createName := "cm-test-opt-create-" + string(uuid.NewUUID())
|
||||||
createContainerName := "createcm-volume-test"
|
|
||||||
createVolumeName := "createcm-volume"
|
createVolumeName := "createcm-volume"
|
||||||
|
|
||||||
// creating a pod without configMap object created, by mentioning the configMap volume source's local reference name
|
// creating a pod without configMap object created, by mentioning the configMap volume source's local reference name
|
||||||
pod := &v1.Pod{
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, createVolumeName, createName, path.Join(volumeMountPath, "create"),
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
"--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volumes/create/data-1")
|
||||||
Name: podName,
|
pod.Spec.Volumes[0].VolumeSource.ConfigMap.Optional = &falseValue
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Volumes: []v1.Volume{
|
|
||||||
{
|
|
||||||
Name: createVolumeName,
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
|
||||||
Name: createName,
|
|
||||||
},
|
|
||||||
Optional: &falseValue,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: createContainerName,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"mounttest", "--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volumes/create/data-1"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: createVolumeName,
|
|
||||||
MountPath: path.Join(volumeMountPath, "create"),
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
ginkgo.By("Creating the pod")
|
ginkgo.By("Creating the pod")
|
||||||
pod = f.PodClient().Create(pod)
|
pod = f.PodClient().Create(pod)
|
||||||
return e2epod.WaitForPodNameRunningInNamespace(f.ClientSet, pod.Name, f.Namespace.Name)
|
return pod, e2epod.WaitForPodNameRunningInNamespace(f.ClientSet, pod.Name, f.Namespace.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNonOptionalConfigMapPodWithConfig(f *framework.Framework, volumeMountPath, podName string) error {
|
func createNonOptionalConfigMapPodWithConfig(f *framework.Framework, volumeMountPath string) (*v1.Pod, error) {
|
||||||
podLogTimeout := e2epod.GetPodSecretUpdateTimeout(f.ClientSet)
|
podLogTimeout := e2epod.GetPodSecretUpdateTimeout(f.ClientSet)
|
||||||
containerTimeoutArg := fmt.Sprintf("--retry_time=%v", int(podLogTimeout.Seconds()))
|
containerTimeoutArg := fmt.Sprintf("--retry_time=%v", int(podLogTimeout.Seconds()))
|
||||||
falseValue := false
|
falseValue := false
|
||||||
|
|
||||||
createName := "cm-test-opt-create-" + string(uuid.NewUUID())
|
createName := "cm-test-opt-create-" + string(uuid.NewUUID())
|
||||||
createContainerName := "createcm-volume-test"
|
|
||||||
createVolumeName := "createcm-volume"
|
createVolumeName := "createcm-volume"
|
||||||
configMap := newConfigMap(f, createName)
|
configMap := newConfigMap(f, createName)
|
||||||
|
|
||||||
@ -863,48 +693,37 @@ func createNonOptionalConfigMapPodWithConfig(f *framework.Framework, volumeMount
|
|||||||
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
framework.Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||||
}
|
}
|
||||||
// creating a pod with configMap object, but with different key which is not present in configMap object.
|
// creating a pod with configMap object, but with different key which is not present in configMap object.
|
||||||
pod := &v1.Pod{
|
pod := createConfigMapVolumeMounttestPod(f.Namespace.Name, createVolumeName, createName, path.Join(volumeMountPath, "create"),
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
"--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volumes/create/data-1")
|
||||||
Name: podName,
|
pod.Spec.Volumes[0].VolumeSource.ConfigMap.Optional = &falseValue
|
||||||
},
|
pod.Spec.Volumes[0].VolumeSource.ConfigMap.Items = []v1.KeyToPath{
|
||||||
Spec: v1.PodSpec{
|
{
|
||||||
Volumes: []v1.Volume{
|
Key: "data-4",
|
||||||
{
|
Path: "path/to/data-4",
|
||||||
Name: createVolumeName,
|
|
||||||
VolumeSource: v1.VolumeSource{
|
|
||||||
ConfigMap: &v1.ConfigMapVolumeSource{
|
|
||||||
LocalObjectReference: v1.LocalObjectReference{
|
|
||||||
Name: createName,
|
|
||||||
},
|
|
||||||
Items: []v1.KeyToPath{
|
|
||||||
{
|
|
||||||
Key: "data-4",
|
|
||||||
Path: "path/to/data-4",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Optional: &falseValue,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: createContainerName,
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"mounttest", "--break_on_expected_content=false", containerTimeoutArg, "--file_content_in_loop=/etc/configmap-volumes/create/data-1"},
|
|
||||||
VolumeMounts: []v1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: createVolumeName,
|
|
||||||
MountPath: path.Join(volumeMountPath, "create"),
|
|
||||||
ReadOnly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Creating the pod")
|
ginkgo.By("Creating the pod")
|
||||||
pod = f.PodClient().Create(pod)
|
pod = f.PodClient().Create(pod)
|
||||||
return e2epod.WaitForPodNameRunningInNamespace(f.ClientSet, pod.Name, f.Namespace.Name)
|
return pod, e2epod.WaitForPodNameRunningInNamespace(f.ClientSet, pod.Name, f.Namespace.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createConfigMapVolumeMounttestPod(namespace, volumeName, referenceName, mountPath string, mounttestArgs ...string) *v1.Pod {
|
||||||
|
volumes := []v1.Volume{
|
||||||
|
{
|
||||||
|
Name: volumeName,
|
||||||
|
VolumeSource: v1.VolumeSource{
|
||||||
|
ConfigMap: &v1.ConfigMapVolumeSource{
|
||||||
|
LocalObjectReference: v1.LocalObjectReference{
|
||||||
|
Name: referenceName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
podName := "pod-configmaps-" + string(uuid.NewUUID())
|
||||||
|
mounttestArgs = append([]string{"mounttest"}, mounttestArgs...)
|
||||||
|
pod := e2epod.NewAgnhostPod(namespace, podName, volumes, createMounts(volumeName, mountPath, true), nil, mounttestArgs...)
|
||||||
|
pod.Spec.RestartPolicy = v1.RestartPolicyNever
|
||||||
|
return pod
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
InitialDelaySeconds: 15,
|
InitialDelaySeconds: 15,
|
||||||
FailureThreshold: 1,
|
FailureThreshold: 1,
|
||||||
}
|
}
|
||||||
pod := livenessPodSpec(nil, livenessProbe)
|
pod := livenessPodSpec(f.Namespace.Name, nil, livenessProbe)
|
||||||
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
InitialDelaySeconds: 15,
|
InitialDelaySeconds: 15,
|
||||||
FailureThreshold: 1,
|
FailureThreshold: 1,
|
||||||
}
|
}
|
||||||
pod := livenessPodSpec(nil, livenessProbe)
|
pod := livenessPodSpec(f.Namespace.Name, nil, livenessProbe)
|
||||||
RunLivenessTest(f, pod, 0, defaultObservationTimeout)
|
RunLivenessTest(f, pod, 0, defaultObservationTimeout)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
InitialDelaySeconds: 5,
|
InitialDelaySeconds: 5,
|
||||||
FailureThreshold: 1,
|
FailureThreshold: 1,
|
||||||
}
|
}
|
||||||
pod := livenessPodSpec(nil, livenessProbe)
|
pod := livenessPodSpec(f.Namespace.Name, nil, livenessProbe)
|
||||||
RunLivenessTest(f, pod, 5, time.Minute*5)
|
RunLivenessTest(f, pod, 5, time.Minute*5)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
InitialDelaySeconds: 15,
|
InitialDelaySeconds: 15,
|
||||||
FailureThreshold: 1,
|
FailureThreshold: 1,
|
||||||
}
|
}
|
||||||
pod := livenessPodSpec(nil, livenessProbe)
|
pod := livenessPodSpec(f.Namespace.Name, nil, livenessProbe)
|
||||||
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
RunLivenessTest(f, pod, 1, defaultObservationTimeout)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ var _ = framework.KubeDescribe("Probing container", func() {
|
|||||||
InitialDelaySeconds: 15,
|
InitialDelaySeconds: 15,
|
||||||
FailureThreshold: 1,
|
FailureThreshold: 1,
|
||||||
}
|
}
|
||||||
pod := livenessPodSpec(nil, livenessProbe)
|
pod := livenessPodSpec(f.Namespace.Name, nil, livenessProbe)
|
||||||
RunLivenessTest(f, pod, 0, defaultObservationTimeout)
|
RunLivenessTest(f, pod, 0, defaultObservationTimeout)
|
||||||
// Expect an event of type "ProbeWarning".
|
// Expect an event of type "ProbeWarning".
|
||||||
expectedEvent := fields.Set{
|
expectedEvent := fields.Set{
|
||||||
@ -472,24 +472,12 @@ func busyBoxPodSpec(readinessProbe, livenessProbe *v1.Probe, cmd []string) *v1.P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func livenessPodSpec(readinessProbe, livenessProbe *v1.Probe) *v1.Pod {
|
func livenessPodSpec(namespace string, readinessProbe, livenessProbe *v1.Probe) *v1.Pod {
|
||||||
return &v1.Pod{
|
pod := e2epod.NewAgnhostPod(namespace, "liveness-"+string(uuid.NewUUID()), nil, nil, nil, "liveness")
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
pod.ObjectMeta.Labels = map[string]string{"test": "liveness"}
|
||||||
Name: "liveness-" + string(uuid.NewUUID()),
|
pod.Spec.Containers[0].LivenessProbe = livenessProbe
|
||||||
Labels: map[string]string{"test": "liveness"},
|
pod.Spec.Containers[0].ReadinessProbe = readinessProbe
|
||||||
},
|
return pod
|
||||||
Spec: v1.PodSpec{
|
|
||||||
Containers: []v1.Container{
|
|
||||||
{
|
|
||||||
Name: "liveness",
|
|
||||||
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
|
||||||
Args: []string{"liveness"},
|
|
||||||
LivenessProbe: livenessProbe,
|
|
||||||
ReadinessProbe: readinessProbe,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func startupPodSpec(startupProbe, readinessProbe, livenessProbe *v1.Probe, cmd []string) *v1.Pod {
|
func startupPodSpec(startupProbe, readinessProbe, livenessProbe *v1.Probe, cmd []string) *v1.Pod {
|
||||||
|
@ -459,9 +459,8 @@ var _ = ginkgo.Describe("[sig-storage] Projected configMap", func() {
|
|||||||
//Slow (~5 mins)
|
//Slow (~5 mins)
|
||||||
ginkgo.It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
|
ginkgo.It("Should fail non-optional pod creation due to configMap object does not exist [Slow]", func() {
|
||||||
volumeMountPath := "/etc/projected-configmap-volumes"
|
volumeMountPath := "/etc/projected-configmap-volumes"
|
||||||
podName := "pod-projected-configmaps-" + string(uuid.NewUUID())
|
pod, err := createNonOptionalConfigMapPod(f, volumeMountPath)
|
||||||
err := createNonOptionalConfigMapPod(f, volumeMountPath, podName)
|
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", pod.Name, f.Namespace.Name)
|
||||||
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//ConfigMap object defined for the pod, If a key is specified which is not present in the ConfigMap,
|
//ConfigMap object defined for the pod, If a key is specified which is not present in the ConfigMap,
|
||||||
@ -469,9 +468,8 @@ var _ = ginkgo.Describe("[sig-storage] Projected configMap", func() {
|
|||||||
//Slow (~5 mins)
|
//Slow (~5 mins)
|
||||||
ginkgo.It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
|
ginkgo.It("Should fail non-optional pod creation due to the key in the configMap object does not exist [Slow]", func() {
|
||||||
volumeMountPath := "/etc/configmap-volumes"
|
volumeMountPath := "/etc/configmap-volumes"
|
||||||
podName := "pod-configmaps-" + string(uuid.NewUUID())
|
pod, err := createNonOptionalConfigMapPodWithConfig(f, volumeMountPath)
|
||||||
err := createNonOptionalConfigMapPodWithConfig(f, volumeMountPath, podName)
|
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", pod.Name, f.Namespace.Name)
|
||||||
framework.ExpectError(err, "created pod %q with non-optional configMap in namespace %q", podName, f.Namespace.Name)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user