mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #82424 from jsafrane/mount-propagation-remove-ssh
Use pod + nsenter instead of SSH in mount propagation tests
This commit is contained in:
commit
867fef5851
@ -49,6 +49,7 @@ go_library(
|
|||||||
"//test/e2e/framework/volume:go_default_library",
|
"//test/e2e/framework/volume:go_default_library",
|
||||||
"//test/e2e/perftype:go_default_library",
|
"//test/e2e/perftype:go_default_library",
|
||||||
"//test/e2e/scheduling:go_default_library",
|
"//test/e2e/scheduling:go_default_library",
|
||||||
|
"//test/e2e/storage/utils:go_default_library",
|
||||||
"//test/utils:go_default_library",
|
"//test/utils:go_default_library",
|
||||||
"//test/utils/image:go_default_library",
|
"//test/utils/image:go_default_library",
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||||
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
@ -85,6 +85,9 @@ var _ = SIGDescribe("Mount propagation", func() {
|
|||||||
// tmpfs to a subdirectory there. We check that these mounts are
|
// tmpfs to a subdirectory there. We check that these mounts are
|
||||||
// propagated to the right places.
|
// propagated to the right places.
|
||||||
|
|
||||||
|
hostExec := utils.NewHostExec(f)
|
||||||
|
defer hostExec.Cleanup()
|
||||||
|
|
||||||
// Pick a node where all pods will run.
|
// Pick a node where all pods will run.
|
||||||
node, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
|
node, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
@ -101,8 +104,8 @@ var _ = SIGDescribe("Mount propagation", func() {
|
|||||||
// running in parallel.
|
// running in parallel.
|
||||||
hostDir := "/var/lib/kubelet/" + f.Namespace.Name
|
hostDir := "/var/lib/kubelet/" + f.Namespace.Name
|
||||||
defer func() {
|
defer func() {
|
||||||
cleanCmd := fmt.Sprintf("sudo rm -rf %q", hostDir)
|
cleanCmd := fmt.Sprintf("rm -rf %q", hostDir)
|
||||||
e2essh.IssueSSHCommand(cleanCmd, framework.TestContext.Provider, node)
|
hostExec.IssueCommand(cleanCmd, node)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
podClient := f.PodClient()
|
podClient := f.PodClient()
|
||||||
@ -138,13 +141,13 @@ var _ = SIGDescribe("Mount propagation", func() {
|
|||||||
|
|
||||||
// The host mounts one tmpfs to testdir/host and puts a file there so we
|
// The host mounts one tmpfs to testdir/host and puts a file there so we
|
||||||
// can check mount propagation from the host to pods.
|
// can check mount propagation from the host to pods.
|
||||||
cmd := fmt.Sprintf("sudo mkdir %[1]q/host; sudo mount -t tmpfs e2e-mount-propagation-host %[1]q/host; echo host > %[1]q/host/file", hostDir)
|
cmd := fmt.Sprintf("mkdir %[1]q/host; mount -t tmpfs e2e-mount-propagation-host %[1]q/host; echo host > %[1]q/host/file", hostDir)
|
||||||
err = e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
|
err = hostExec.IssueCommand(cmd, node)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
cmd := fmt.Sprintf("sudo umount %q/host", hostDir)
|
cmd := fmt.Sprintf("umount %q/host", hostDir)
|
||||||
e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
|
hostExec.IssueCommand(cmd, node)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Now check that mounts are propagated to the right containers.
|
// Now check that mounts are propagated to the right containers.
|
||||||
@ -180,12 +183,12 @@ var _ = SIGDescribe("Mount propagation", func() {
|
|||||||
// Check that the mounts are/are not propagated to the host.
|
// Check that the mounts are/are not propagated to the host.
|
||||||
// Host can see mount from master
|
// Host can see mount from master
|
||||||
cmd = fmt.Sprintf("test `cat %q/master/file` = master", hostDir)
|
cmd = fmt.Sprintf("test `cat %q/master/file` = master", hostDir)
|
||||||
err = e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
|
err = hostExec.IssueCommand(cmd, node)
|
||||||
framework.ExpectNoError(err, "host should see mount from master")
|
framework.ExpectNoError(err, "host should see mount from master")
|
||||||
|
|
||||||
// Host can't see mount from slave
|
// Host can't see mount from slave
|
||||||
cmd = fmt.Sprintf("test ! -e %q/slave/file", hostDir)
|
cmd = fmt.Sprintf("test ! -e %q/slave/file", hostDir)
|
||||||
err = e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
|
err = hostExec.IssueCommand(cmd, node)
|
||||||
framework.ExpectNoError(err, "host shouldn't see mount from slave")
|
framework.ExpectNoError(err, "host shouldn't see mount from slave")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user