fix host dir, to test volume r/w with different containers within a pod
Signed-off-by: He Simei <hesimei@zju.edu.cn>
This commit is contained in:
@@ -21,7 +21,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/latest"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
@@ -77,18 +76,24 @@ var _ = Describe("hostPath", func() {
|
||||
It("should support r/w", func() {
|
||||
volumePath := "/test-volume"
|
||||
filePath := path.Join(volumePath, "test-file")
|
||||
retryDuration := 180
|
||||
source := &api.HostPathVolumeSource{
|
||||
Path: "/tmp",
|
||||
}
|
||||
pod := testPodWithHostVol(volumePath, source)
|
||||
|
||||
pod.Spec.Containers[0].Args = []string{
|
||||
fmt.Sprintf("--fs_type=%v", volumePath),
|
||||
fmt.Sprintf("--rw_new_file=%v", filePath),
|
||||
fmt.Sprintf("--new_file_0644=%v", filePath),
|
||||
fmt.Sprintf("--file_mode=%v", filePath),
|
||||
}
|
||||
testContainerOutputInNamespace("hostPath r/w", c, pod, 0, []string{
|
||||
"mode of file \"/test-volume/test-file\": -rw-r--r--",
|
||||
|
||||
pod.Spec.Containers[1].Args = []string{
|
||||
fmt.Sprintf("--file_content_in_loop=%v", filePath),
|
||||
fmt.Sprintf("--retry_time=%d", retryDuration),
|
||||
}
|
||||
//Read the content of the file with the second container to
|
||||
//verify volumes being shared properly among continers within the pod.
|
||||
testContainerOutputInNamespace("hostPath r/w", c, pod, 1, []string{
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
}, namespace.Name,
|
||||
)
|
||||
@@ -96,8 +101,9 @@ var _ = Describe("hostPath", func() {
|
||||
})
|
||||
|
||||
//These constants are borrowed from the other test.
|
||||
//const containerName = "test-container"
|
||||
//const volumeName = "test-volume"
|
||||
const containerName1 = "test-container-1"
|
||||
const containerName2 = "test-container-2"
|
||||
|
||||
func mount(source *api.HostPathVolumeSource) []api.Volume {
|
||||
return []api.Volume{
|
||||
@@ -112,7 +118,7 @@ func mount(source *api.HostPathVolumeSource) []api.Volume {
|
||||
|
||||
//TODO: To merge this with the emptyDir tests, we can make source a lambda.
|
||||
func testPodWithHostVol(path string, source *api.HostPathVolumeSource) *api.Pod {
|
||||
podName := "pod-" + string(util.NewUUID())
|
||||
podName := "pod-host-path-test"
|
||||
|
||||
return &api.Pod{
|
||||
TypeMeta: api.TypeMeta{
|
||||
@@ -125,8 +131,18 @@ func testPodWithHostVol(path string, source *api.HostPathVolumeSource) *api.Pod
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: containerName,
|
||||
Image: "gcr.io/google_containers/mounttest:0.2",
|
||||
Name: containerName1,
|
||||
Image: "gcr.io/google_containers/mounttest:0.4",
|
||||
VolumeMounts: []api.VolumeMount{
|
||||
{
|
||||
Name: volumeName,
|
||||
MountPath: path,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: containerName2,
|
||||
Image: "gcr.io/google_containers/mounttest:0.4",
|
||||
VolumeMounts: []api.VolumeMount{
|
||||
{
|
||||
Name: volumeName,
|
||||
|
||||
Reference in New Issue
Block a user