@@ -193,12 +193,9 @@ var _ = utils.SIGDescribe("HostPathType Socket [Slow]", func() {
193
193
ginkgo .By ("Create a pod for further testing" )
194
194
hostBaseDir = path .Join ("/tmp" , ns )
195
195
mountBaseDir = "/mnt/test"
196
- basePod = f .PodClient ().CreateSync (newHostPathTypeTestPod (map [string ]string {}, hostBaseDir , mountBaseDir , & hostPathDirectoryOrCreate ))
196
+ basePod = f .PodClient ().CreateSync (newHostPathTypeTestPodWithCommand (map [string ]string {}, hostBaseDir , mountBaseDir , & hostPathDirectoryOrCreate , fmt . Sprintf ( "nc -lU %s" , path . Join ( mountBaseDir , "asocket" )) ))
197
197
ginkgo .By (fmt .Sprintf ("running on node %s" , basePod .Spec .NodeName ))
198
198
targetSocket = path .Join (hostBaseDir , "asocket" )
199
- ginkgo .By ("Create a socket for further testing" )
200
- _ , err := utils .PodExec (f , basePod , fmt .Sprintf ("nc -lU %s &" , path .Join (mountBaseDir , "asocket" )))
201
- framework .ExpectNoError (err )
202
199
})
203
200
204
201
ginkgo .It ("Should fail on mounting non-existent socket 'does-not-exist-socket' when HostPathType is HostPathSocket" , func () {
@@ -409,6 +406,45 @@ func newHostPathTypeTestPod(nodeSelector map[string]string, hostDir, mountDir st
409
406
return pod
410
407
}
411
408
409
+ func newHostPathTypeTestPodWithCommand (nodeSelector map [string ]string , hostDir , mountDir string , hostPathType * v1.HostPathType , command string ) * v1.Pod {
410
+ pod := & v1.Pod {
411
+ ObjectMeta : metav1.ObjectMeta {
412
+ GenerateName : "test-hostpath-type-" ,
413
+ },
414
+ Spec : v1.PodSpec {
415
+ NodeSelector : nodeSelector ,
416
+ RestartPolicy : v1 .RestartPolicyNever ,
417
+ Containers : []v1.Container {
418
+ {
419
+ Name : "host-path-sh-testing" ,
420
+ Image : imageutils .GetE2EImage (imageutils .Agnhost ),
421
+ VolumeMounts : []v1.VolumeMount {
422
+ {
423
+ Name : "host" ,
424
+ MountPath : mountDir ,
425
+ ReadOnly : false ,
426
+ },
427
+ },
428
+ Command : []string {"sh" },
429
+ Args : []string {"-c" , command },
430
+ },
431
+ },
432
+ Volumes : []v1.Volume {
433
+ {
434
+ Name : "host" ,
435
+ VolumeSource : v1.VolumeSource {
436
+ HostPath : & v1.HostPathVolumeSource {
437
+ Path : hostDir ,
438
+ Type : hostPathType ,
439
+ },
440
+ },
441
+ },
442
+ },
443
+ },
444
+ }
445
+ return pod
446
+ }
447
+
412
448
func verifyPodHostPathTypeFailure (f * framework.Framework , nodeSelector map [string ]string , hostDir , pattern string , hostPathType * v1.HostPathType ) {
413
449
pod := newHostPathTypeTestPod (nodeSelector , hostDir , "/mnt/test" , hostPathType )
414
450
ginkgo .By (fmt .Sprintf ("Creating pod %s" , pod .Name ))
0 commit comments