mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #92205 from mrunalp/fix_host_path_socket_tests
test: Start a pod with nc instead of execing a background command
This commit is contained in:
commit
0bb640c25a
@ -193,12 +193,9 @@ var _ = utils.SIGDescribe("HostPathType Socket [Slow]", func() {
|
|||||||
ginkgo.By("Create a pod for further testing")
|
ginkgo.By("Create a pod for further testing")
|
||||||
hostBaseDir = path.Join("/tmp", ns)
|
hostBaseDir = path.Join("/tmp", ns)
|
||||||
mountBaseDir = "/mnt/test"
|
mountBaseDir = "/mnt/test"
|
||||||
basePod = f.PodClient().CreateSync(newHostPathTypeTestPod(map[string]string{}, hostBaseDir, mountBaseDir, &hostPathDirectoryOrCreate))
|
basePod = f.PodClient().CreateSync(newHostPathTypeTestPodWithCommand(map[string]string{}, hostBaseDir, mountBaseDir, &hostPathDirectoryOrCreate, fmt.Sprintf("nc -lU %s", path.Join(mountBaseDir, "asocket"))))
|
||||||
ginkgo.By(fmt.Sprintf("running on node %s", basePod.Spec.NodeName))
|
ginkgo.By(fmt.Sprintf("running on node %s", basePod.Spec.NodeName))
|
||||||
targetSocket = path.Join(hostBaseDir, "asocket")
|
targetSocket = path.Join(hostBaseDir, "asocket")
|
||||||
ginkgo.By("Create a socket for further testing")
|
|
||||||
_, err := utils.PodExec(f, basePod, fmt.Sprintf("nc -lU %s &", path.Join(mountBaseDir, "asocket")))
|
|
||||||
framework.ExpectNoError(err)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("Should fail on mounting non-existent socket 'does-not-exist-socket' when HostPathType is HostPathSocket", func() {
|
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
|
|||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newHostPathTypeTestPodWithCommand(nodeSelector map[string]string, hostDir, mountDir string, hostPathType *v1.HostPathType, command string) *v1.Pod {
|
||||||
|
pod := &v1.Pod{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
GenerateName: "test-hostpath-type-",
|
||||||
|
},
|
||||||
|
Spec: v1.PodSpec{
|
||||||
|
NodeSelector: nodeSelector,
|
||||||
|
RestartPolicy: v1.RestartPolicyNever,
|
||||||
|
Containers: []v1.Container{
|
||||||
|
{
|
||||||
|
Name: "host-path-sh-testing",
|
||||||
|
Image: imageutils.GetE2EImage(imageutils.Agnhost),
|
||||||
|
VolumeMounts: []v1.VolumeMount{
|
||||||
|
{
|
||||||
|
Name: "host",
|
||||||
|
MountPath: mountDir,
|
||||||
|
ReadOnly: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Command: []string{"sh"},
|
||||||
|
Args: []string{"-c", command},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Volumes: []v1.Volume{
|
||||||
|
{
|
||||||
|
Name: "host",
|
||||||
|
VolumeSource: v1.VolumeSource{
|
||||||
|
HostPath: &v1.HostPathVolumeSource{
|
||||||
|
Path: hostDir,
|
||||||
|
Type: hostPathType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return pod
|
||||||
|
}
|
||||||
|
|
||||||
func verifyPodHostPathTypeFailure(f *framework.Framework, nodeSelector map[string]string, hostDir, pattern string, hostPathType *v1.HostPathType) {
|
func verifyPodHostPathTypeFailure(f *framework.Framework, nodeSelector map[string]string, hostDir, pattern string, hostPathType *v1.HostPathType) {
|
||||||
pod := newHostPathTypeTestPod(nodeSelector, hostDir, "/mnt/test", hostPathType)
|
pod := newHostPathTypeTestPod(nodeSelector, hostDir, "/mnt/test", hostPathType)
|
||||||
ginkgo.By(fmt.Sprintf("Creating pod %s", pod.Name))
|
ginkgo.By(fmt.Sprintf("Creating pod %s", pod.Name))
|
||||||
|
Loading…
Reference in New Issue
Block a user