mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
enable gcpdcsi multivolume tests with windows nodes
This commit is contained in:
@@ -37,17 +37,9 @@ func NodeOSDistroIs(distro string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GenerateScriptCmd generates the corresponding command lines to execute a command.
|
// GenerateScriptCmd generates the corresponding command lines to execute a command.
|
||||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
|
||||||
func GenerateScriptCmd(command string) []string {
|
func GenerateScriptCmd(command string) []string {
|
||||||
var commands []string
|
var commands []string
|
||||||
if command == "" {
|
|
||||||
return commands
|
|
||||||
}
|
|
||||||
if !NodeOSDistroIs("windows") {
|
|
||||||
commands = []string{"/bin/sh", "-c", command}
|
commands = []string{"/bin/sh", "-c", command}
|
||||||
} else {
|
|
||||||
commands = []string{"powershell", "/c", command}
|
|
||||||
}
|
|
||||||
return commands
|
return commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -619,6 +619,13 @@ func generateWriteFileCmd(content, fullPath string) []string {
|
|||||||
|
|
||||||
// CheckVolumeModeOfPath check mode of volume
|
// CheckVolumeModeOfPath check mode of volume
|
||||||
func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) {
|
func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) {
|
||||||
|
// in windows a symlink is created instead of mounting a volume
|
||||||
|
// we just check if the symlink exists
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("ls %s", path))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if volMode == v1.PersistentVolumeBlock {
|
if volMode == v1.PersistentVolumeBlock {
|
||||||
// Check if block exists
|
// Check if block exists
|
||||||
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("test -b %s", path))
|
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("test -b %s", path))
|
||||||
|
@@ -132,7 +132,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
|||||||
// [ node1 ] ==> [ node1 ]
|
// [ node1 ] ==> [ node1 ]
|
||||||
// / \ <- same volume mode / \
|
// / \ <- same volume mode / \
|
||||||
// [volume1] [volume2] [volume1] [volume2]
|
// [volume1] [volume2] [volume1] [volume2]
|
||||||
ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on the same node [LinuxOnly]", func() {
|
ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on the same node", func() {
|
||||||
// Currently, multiple volumes are not generally available for pre-provisoined volume,
|
// Currently, multiple volumes are not generally available for pre-provisoined volume,
|
||||||
// because containerized storage servers, such as iSCSI and rbd, are just returning
|
// because containerized storage servers, such as iSCSI and rbd, are just returning
|
||||||
// a static volume inside container, not actually creating a new volume per request.
|
// a static volume inside container, not actually creating a new volume per request.
|
||||||
@@ -510,7 +510,7 @@ func testAccessMultipleVolumes(f *framework.Framework, cs clientset.Interface, n
|
|||||||
// CreateSecPodWithNodeSelection make volumes accessible via /mnt/volume({i} + 1)
|
// CreateSecPodWithNodeSelection make volumes accessible via /mnt/volume({i} + 1)
|
||||||
index := i + 1
|
index := i + 1
|
||||||
path := fmt.Sprintf("/mnt/volume%d", index)
|
path := fmt.Sprintf("/mnt/volume%d", index)
|
||||||
ginkgo.By(fmt.Sprintf("Checking if the volume%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode))
|
ginkgo.By(fmt.Sprintf("Checking if the volume=%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode))
|
||||||
e2evolume.CheckVolumeModeOfPath(f, pod, *pvc.Spec.VolumeMode, path)
|
e2evolume.CheckVolumeModeOfPath(f, pod, *pvc.Spec.VolumeMode, path)
|
||||||
|
|
||||||
if readSeedBase > 0 {
|
if readSeedBase > 0 {
|
||||||
|
@@ -543,9 +543,14 @@ func CheckReadFromPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persisten
|
|||||||
|
|
||||||
sum := sha256.Sum256(genBinDataFromSeed(len, seed))
|
sum := sha256.Sum256(genBinDataFromSeed(len, seed))
|
||||||
|
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum", pathForVolMode))
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum | grep -Fq %x", pathForVolMode, sum))
|
||||||
|
} else {
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len))
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len))
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum))
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CheckWriteToPath that file can be properly written.
|
// CheckWriteToPath that file can be properly written.
|
||||||
//
|
//
|
||||||
@@ -568,9 +573,14 @@ func CheckWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persistent
|
|||||||
|
|
||||||
encoded := base64.StdEncoding.EncodeToString(genBinDataFromSeed(len, seed))
|
encoded := base64.StdEncoding.EncodeToString(genBinDataFromSeed(len, seed))
|
||||||
|
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded))
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d > %s", encoded, pathForVolMode))
|
||||||
|
} else {
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded))
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded))
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len))
|
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetSectorSize returns the sector size of the device.
|
// GetSectorSize returns the sector size of the device.
|
||||||
func GetSectorSize(f *framework.Framework, pod *v1.Pod, device string) int {
|
func GetSectorSize(f *framework.Framework, pod *v1.Pod, device string) int {
|
||||||
|
Reference in New Issue
Block a user