mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Test global block directory in reconstruction tests
This commit is contained in:
parent
ec05944b13
commit
612fb1793e
@ -140,8 +140,9 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range disruptiveTestTable {
|
for _, test := range disruptiveTestTable {
|
||||||
if test.runTestFile != nil {
|
|
||||||
func(t disruptiveTest) {
|
func(t disruptiveTest) {
|
||||||
|
if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) ||
|
||||||
|
(pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) {
|
||||||
ginkgo.It(t.testItStmt, func() {
|
ginkgo.It(t.testItStmt, func() {
|
||||||
init()
|
init()
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
@ -158,13 +159,14 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
|
|||||||
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, l.ns.Name, pvcs, inlineSources, false, "", false, false, e2epv.SELinuxLabel, nil, e2epod.NodeSelection{Name: l.config.ClientNodeName}, framework.PodStartTimeout)
|
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, l.ns.Name, pvcs, inlineSources, false, "", false, false, e2epv.SELinuxLabel, nil, e2epod.NodeSelection{Name: l.config.ClientNodeName}, framework.PodStartTimeout)
|
||||||
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
||||||
|
|
||||||
if pattern.VolMode == v1.PersistentVolumeBlock {
|
if pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil {
|
||||||
t.runTestBlock(l.cs, l.config.Framework, l.pod)
|
t.runTestBlock(l.cs, l.config.Framework, l.pod)
|
||||||
} else {
|
}
|
||||||
|
if pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil {
|
||||||
t.runTestFile(l.cs, l.config.Framework, l.pod)
|
t.runTestFile(l.cs, l.config.Framework, l.pod)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}(test)
|
}(test)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -318,18 +318,28 @@ func TestVolumeUnmapsFromDeletedPodWithForceOption(c clientset.Interface, f *fra
|
|||||||
nodeIP = nodeIP + ":22"
|
nodeIP = nodeIP + ":22"
|
||||||
|
|
||||||
// Creating command to check whether path exists
|
// Creating command to check whether path exists
|
||||||
command := fmt.Sprintf("ls /var/lib/kubelet/pods/%s/volumeDevices/*/ | grep '.'", clientPod.UID)
|
podDirectoryCmd := fmt.Sprintf("ls /var/lib/kubelet/pods/%s/volumeDevices/*/ | grep '.'", clientPod.UID)
|
||||||
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
||||||
command = fmt.Sprintf("sudo sh -c \"%s\"", command)
|
podDirectoryCmd = fmt.Sprintf("sudo sh -c \"%s\"", podDirectoryCmd)
|
||||||
|
}
|
||||||
|
// Directories in the global directory have unpredictable names, however, device symlinks
|
||||||
|
// have the same name as pod.UID. So just find anything with pod.UID name.
|
||||||
|
globalBlockDirectoryCmd := fmt.Sprintf("find /var/lib/kubelet/plugins -name %s", clientPod.UID)
|
||||||
|
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
||||||
|
globalBlockDirectoryCmd = fmt.Sprintf("sudo sh -c \"%s\"", globalBlockDirectoryCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Expecting the symlinks from PodDeviceMapPath to be found.")
|
ginkgo.By("Expecting the symlinks from PodDeviceMapPath to be found.")
|
||||||
result, err := e2essh.SSH(command, nodeIP, framework.TestContext.Provider)
|
result, err := e2essh.SSH(podDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
e2essh.LogResult(result)
|
e2essh.LogResult(result)
|
||||||
framework.ExpectNoError(err, "Encountered SSH error.")
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
||||||
|
|
||||||
// TODO: Needs to check GetGlobalMapPath and descriptor lock, as well.
|
ginkgo.By("Expecting the symlinks from global map path to be found.")
|
||||||
|
result, err = e2essh.SSH(globalBlockDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
|
e2essh.LogResult(result)
|
||||||
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
|
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected find exit code of 0, got %d", result.Code))
|
||||||
|
|
||||||
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
|
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -358,12 +368,16 @@ func TestVolumeUnmapsFromDeletedPodWithForceOption(c clientset.Interface, f *fra
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Expecting the symlink from PodDeviceMapPath not to be found.")
|
ginkgo.By("Expecting the symlink from PodDeviceMapPath not to be found.")
|
||||||
result, err = e2essh.SSH(command, nodeIP, framework.TestContext.Provider)
|
result, err = e2essh.SSH(podDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
e2essh.LogResult(result)
|
e2essh.LogResult(result)
|
||||||
framework.ExpectNoError(err, "Encountered SSH error.")
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected grep stdout to be empty.")
|
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected grep stdout to be empty.")
|
||||||
|
|
||||||
// TODO: Needs to check GetGlobalMapPath and descriptor lock, as well.
|
ginkgo.By("Expecting the symlinks from global map path not to be found.")
|
||||||
|
result, err = e2essh.SSH(globalBlockDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
|
e2essh.LogResult(result)
|
||||||
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
|
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected find stdout to be empty.")
|
||||||
|
|
||||||
framework.Logf("Volume unmaped on node %s", clientPod.Spec.NodeName)
|
framework.Logf("Volume unmaped on node %s", clientPod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user