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:
Kubernetes Prow Robot 2019-10-01 15:27:08 -07:00 committed by GitHub
commit 867fef5851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -49,6 +49,7 @@ go_library(
"//test/e2e/framework/volume:go_default_library",
"//test/e2e/perftype:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/e2e/storage/utils:go_default_library",
"//test/utils:go_default_library",
"//test/utils/image:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",

View File

@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/test/e2e/framework"
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"
"github.com/onsi/ginkgo"
@ -85,6 +85,9 @@ var _ = SIGDescribe("Mount propagation", func() {
// tmpfs to a subdirectory there. We check that these mounts are
// propagated to the right places.
hostExec := utils.NewHostExec(f)
defer hostExec.Cleanup()
// Pick a node where all pods will run.
node, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
framework.ExpectNoError(err)
@ -101,8 +104,8 @@ var _ = SIGDescribe("Mount propagation", func() {
// running in parallel.
hostDir := "/var/lib/kubelet/" + f.Namespace.Name
defer func() {
cleanCmd := fmt.Sprintf("sudo rm -rf %q", hostDir)
e2essh.IssueSSHCommand(cleanCmd, framework.TestContext.Provider, node)
cleanCmd := fmt.Sprintf("rm -rf %q", hostDir)
hostExec.IssueCommand(cleanCmd, node)
}()
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
// 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)
err = e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
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 = hostExec.IssueCommand(cmd, node)
framework.ExpectNoError(err)
defer func() {
cmd := fmt.Sprintf("sudo umount %q/host", hostDir)
e2essh.IssueSSHCommand(cmd, framework.TestContext.Provider, node)
cmd := fmt.Sprintf("umount %q/host", hostDir)
hostExec.IssueCommand(cmd, node)
}()
// 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.
// Host can see mount from master
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")
// Host can't see mount from slave
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")
})
})