Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test case for shared volumes between the containers in pod #73523

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 74 additions & 0 deletions test/e2e/common/empty_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package common
import (
"fmt"
"path"
"time"

. "github.com/onsi/ginkgo"
"k8s.io/api/core/v1"
Expand Down Expand Up @@ -205,6 +206,79 @@ var _ = Describe("[sig-storage] EmptyDir volumes", func() {
framework.ConformanceIt("should support (non-root,0777,default) [LinuxOnly] [NodeConformance]", func() {
doTest0777(f, testImageNonRootUid, v1.StorageMediumDefault)
})

It("pod should support shared volumes between containers", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we propose this for ConformanceIT ? BTW a nice follow on issue might be to add 'EmptyDir' to all these test descriptions. This is a great test esp w/ diverging container runtimes, thanks !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure the test is stable first before promoting to conformance.

EmptyDir is already specified at the top level describe for these tests.

var (
volumeName = "shared-data"
busyBoxMainVolumeMountPath = "/usr/share/volumeshare"
busyBoxSubVolumeMountPath = "/pod-data"
busyBoxMainVolumeFilePath = fmt.Sprintf("%s/shareddata.txt", busyBoxMainVolumeMountPath)
busyBoxSubVolumeFilePath = fmt.Sprintf("%s/shareddata.txt", busyBoxSubVolumeMountPath)
message = "Hello from the busy-box sub-container"
busyBoxMainContainerName = "busybox-main-container"
busyBoxSubContainerName = "busybox-sub-container"
resultString = ""
)

pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-sharedvolume-" + string(uuid.NewUUID()),
},
Spec: v1.PodSpec{
Volumes: []v1.Volume{
{
Name: volumeName,
VolumeSource: v1.VolumeSource{
EmptyDir: new(v1.EmptyDirVolumeSource),
},
},
},
Containers: []v1.Container{
{
Name: busyBoxMainContainerName,
Image: imageutils.GetE2EImage(imageutils.BusyBox),
Command: []string{"/bin/sh"},
Args: []string{"-c", "sleep 10"},
VolumeMounts: []v1.VolumeMount{
{
Name: volumeName,
MountPath: busyBoxMainVolumeMountPath,
},
},
},
{
Name: busyBoxSubContainerName,
Image: imageutils.GetE2EImage(imageutils.BusyBox),
Command: []string{"/bin/sh"},
Args: []string{"-c", fmt.Sprintf("echo %s > %s", message, busyBoxSubVolumeFilePath)},
VolumeMounts: []v1.VolumeMount{
{
Name: volumeName,
MountPath: busyBoxSubVolumeMountPath,
},
},
},
},
RestartPolicy: v1.RestartPolicyNever,
},
}

var err error
By("Creating Pod")
pod = f.PodClient().CreateSync(pod)

By("Waiting for the pod running")
err = f.WaitForPodRunning(pod.Name)
framework.ExpectNoError(err, "failed to deploy pod %s", pod.Name)

By("Geting the pod")
pod, err = f.PodClient().Get(pod.Name, metav1.GetOptions{})
framework.ExpectNoError(err, "failed to get pod %s", pod.Name)

By("Reading file content from the nginx-container")
resultString, err = framework.LookForStringInFile(f.Namespace.Name, pod.Name, busyBoxMainContainerName, busyBoxMainVolumeFilePath, message, 30*time.Second)
framework.ExpectNoError(err, "failed to match expected string %s with %s", message, resultString)
})
})

const (
Expand Down