@@ -19,6 +19,7 @@ package common
19
19
import (
20
20
"fmt"
21
21
"path"
22
+ "time"
22
23
23
24
. "github.com/onsi/ginkgo"
24
25
"k8s.io/api/core/v1"
@@ -205,6 +206,79 @@ var _ = Describe("[sig-storage] EmptyDir volumes", func() {
205
206
framework .ConformanceIt ("should support (non-root,0777,default) [LinuxOnly] [NodeConformance]" , func () {
206
207
doTest0777 (f , testImageNonRootUid , v1 .StorageMediumDefault )
207
208
})
209
+
210
+ It ("pod should support shared volumes between containers" , func () {
211
+ var (
212
+ volumeName = "shared-data"
213
+ busyBoxMainVolumeMountPath = "/usr/share/volumeshare"
214
+ busyBoxSubVolumeMountPath = "/pod-data"
215
+ busyBoxMainVolumeFilePath = fmt .Sprintf ("%s/shareddata.txt" , busyBoxMainVolumeMountPath )
216
+ busyBoxSubVolumeFilePath = fmt .Sprintf ("%s/shareddata.txt" , busyBoxSubVolumeMountPath )
217
+ message = "Hello from the busy-box sub-container"
218
+ busyBoxMainContainerName = "busybox-main-container"
219
+ busyBoxSubContainerName = "busybox-sub-container"
220
+ resultString = ""
221
+ )
222
+
223
+ pod := & v1.Pod {
224
+ ObjectMeta : metav1.ObjectMeta {
225
+ Name : "pod-sharedvolume-" + string (uuid .NewUUID ()),
226
+ },
227
+ Spec : v1.PodSpec {
228
+ Volumes : []v1.Volume {
229
+ {
230
+ Name : volumeName ,
231
+ VolumeSource : v1.VolumeSource {
232
+ EmptyDir : new (v1.EmptyDirVolumeSource ),
233
+ },
234
+ },
235
+ },
236
+ Containers : []v1.Container {
237
+ {
238
+ Name : busyBoxMainContainerName ,
239
+ Image : imageutils .GetE2EImage (imageutils .BusyBox ),
240
+ Command : []string {"/bin/sh" },
241
+ Args : []string {"-c" , "sleep 10" },
242
+ VolumeMounts : []v1.VolumeMount {
243
+ {
244
+ Name : volumeName ,
245
+ MountPath : busyBoxMainVolumeMountPath ,
246
+ },
247
+ },
248
+ },
249
+ {
250
+ Name : busyBoxSubContainerName ,
251
+ Image : imageutils .GetE2EImage (imageutils .BusyBox ),
252
+ Command : []string {"/bin/sh" },
253
+ Args : []string {"-c" , fmt .Sprintf ("echo %s > %s" , message , busyBoxSubVolumeFilePath )},
254
+ VolumeMounts : []v1.VolumeMount {
255
+ {
256
+ Name : volumeName ,
257
+ MountPath : busyBoxSubVolumeMountPath ,
258
+ },
259
+ },
260
+ },
261
+ },
262
+ RestartPolicy : v1 .RestartPolicyNever ,
263
+ },
264
+ }
265
+
266
+ var err error
267
+ By ("Creating Pod" )
268
+ pod = f .PodClient ().CreateSync (pod )
269
+
270
+ By ("Waiting for the pod running" )
271
+ err = f .WaitForPodRunning (pod .Name )
272
+ framework .ExpectNoError (err , "failed to deploy pod %s" , pod .Name )
273
+
274
+ By ("Geting the pod" )
275
+ pod , err = f .PodClient ().Get (pod .Name , metav1.GetOptions {})
276
+ framework .ExpectNoError (err , "failed to get pod %s" , pod .Name )
277
+
278
+ By ("Reading file content from the nginx-container" )
279
+ resultString , err = framework .LookForStringInFile (f .Namespace .Name , pod .Name , busyBoxMainContainerName , busyBoxMainVolumeFilePath , message , 30 * time .Second )
280
+ framework .ExpectNoError (err , "failed to match expected string %s with %s" , message , resultString )
281
+ })
208
282
})
209
283
210
284
const (
0 commit comments