mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Merge pull request #100641 from mauriciopoppe/external-storage-multivolume-windows
Enable GCE PD CSI multivolume tests with windows nodes
This commit is contained in:
commit
0ae157df39
@ -37,17 +37,9 @@ func NodeOSDistroIs(distro string) bool {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
var commands []string
|
||||
if command == "" {
|
||||
return commands
|
||||
}
|
||||
if !NodeOSDistroIs("windows") {
|
||||
commands = []string{"/bin/sh", "-c", command}
|
||||
} else {
|
||||
commands = []string{"powershell", "/c", command}
|
||||
}
|
||||
commands = []string{"/bin/sh", "-c", command}
|
||||
return commands
|
||||
}
|
||||
|
||||
|
@ -368,11 +368,7 @@ func runVolumeTesterPod(client clientset.Interface, timeouts *framework.TimeoutC
|
||||
var gracePeriod int64 = 1
|
||||
var command string
|
||||
|
||||
if !framework.NodeOSDistroIs("windows") {
|
||||
command = "while true ; do sleep 2; done "
|
||||
} else {
|
||||
command = "while(1) {sleep 2}"
|
||||
}
|
||||
command = "while true ; do sleep 2; done "
|
||||
seLinuxOptions := &v1.SELinuxOptions{Level: "s0:c0,c1"}
|
||||
clientPod := &v1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
@ -572,47 +568,30 @@ func InjectContent(f *framework.Framework, config TestConfig, fsGroup *int64, fs
|
||||
// generateWriteCmd is used by generateWriteBlockCmd and generateWriteFileCmd
|
||||
func generateWriteCmd(content, path string) []string {
|
||||
var commands []string
|
||||
if !framework.NodeOSDistroIs("windows") {
|
||||
commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path}
|
||||
} else {
|
||||
commands = []string{"powershell", "/c", "echo '" + content + "' > " + path}
|
||||
}
|
||||
commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path}
|
||||
return commands
|
||||
}
|
||||
|
||||
// generateReadBlockCmd generates the corresponding command lines to read from a block device with the given file path.
|
||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
||||
func generateReadBlockCmd(fullPath string, numberOfCharacters int) []string {
|
||||
var commands []string
|
||||
if !framework.NodeOSDistroIs("windows") {
|
||||
commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath}
|
||||
} else {
|
||||
// TODO: is there a way on windows to get the first X bytes from a device?
|
||||
commands = []string{"powershell", "/c", "type " + fullPath}
|
||||
}
|
||||
commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath}
|
||||
return commands
|
||||
}
|
||||
|
||||
// generateWriteBlockCmd generates the corresponding command lines to write to a block device the given content.
|
||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
||||
func generateWriteBlockCmd(content, fullPath string) []string {
|
||||
return generateWriteCmd(content, fullPath)
|
||||
}
|
||||
|
||||
// GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path.
|
||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
||||
func GenerateReadFileCmd(fullPath string) []string {
|
||||
var commands []string
|
||||
if !framework.NodeOSDistroIs("windows") {
|
||||
commands = []string{"cat", fullPath}
|
||||
} else {
|
||||
commands = []string{"powershell", "/c", "type " + fullPath}
|
||||
}
|
||||
commands = []string{"cat", fullPath}
|
||||
return commands
|
||||
}
|
||||
|
||||
// generateWriteFileCmd generates the corresponding command lines to write a file with the given content and file path.
|
||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
||||
func generateWriteFileCmd(content, fullPath string) []string {
|
||||
return generateWriteCmd(content, fullPath)
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
||||
// [ node1 ] ==> [ node1 ]
|
||||
// / \ <- same volume mode / \
|
||||
// [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,
|
||||
// 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.
|
||||
@ -162,7 +162,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
||||
// [ node1 ] ==> [ node2 ]
|
||||
// / \ <- same volume mode / \
|
||||
// [volume1] [volume2] [volume1] [volume2]
|
||||
ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on different node [LinuxOnly]", func() {
|
||||
ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on different node", func() {
|
||||
// Currently, multiple volumes are not generally available for pre-provisoined volume,
|
||||
// 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.
|
||||
@ -203,7 +203,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
||||
// [ node1 ] ==> [ node1 ]
|
||||
// / \ <- different volume mode / \
|
||||
// [volume1] [volume2] [volume1] [volume2]
|
||||
ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on the same node [LinuxOnly]", func() {
|
||||
ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on the same node", func() {
|
||||
if pattern.VolMode == v1.PersistentVolumeFilesystem {
|
||||
e2eskipper.Skipf("Filesystem volume case should be covered by block volume case -- skipping")
|
||||
}
|
||||
@ -242,7 +242,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
||||
// [ node1 ] ==> [ node2 ]
|
||||
// / \ <- different volume mode / \
|
||||
// [volume1] [volume2] [volume1] [volume2]
|
||||
ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on different node [LinuxOnly]", func() {
|
||||
ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on different node", func() {
|
||||
if pattern.VolMode == v1.PersistentVolumeFilesystem {
|
||||
e2eskipper.Skipf("Filesystem volume case should be covered by block volume case -- skipping")
|
||||
}
|
||||
@ -292,7 +292,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p
|
||||
// [ node1 ]
|
||||
// \ / <- same volume mode
|
||||
// [volume1]
|
||||
ginkgo.It("should concurrently access the single volume from pods on the same node [LinuxOnly]", func() {
|
||||
ginkgo.It("should concurrently access the single volume from pods on the same node", func() {
|
||||
init()
|
||||
defer cleanup()
|
||||
|
||||
|
@ -551,7 +551,8 @@ func PVWriteReadSingleNodeCheck(client clientset.Interface, timeouts *framework.
|
||||
command += " || (mount | grep 'on /mnt/test'; false)"
|
||||
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
command = "select-string 'hello world' /mnt/test/data"
|
||||
// agnhost doesn't support mount
|
||||
command = "grep 'hello world' /mnt/test/data"
|
||||
}
|
||||
RunInPodWithVolume(client, timeouts, claim.Namespace, claim.Name, "pvc-volume-tester-reader", command, e2epod.NodeSelection{Name: actualNodeName})
|
||||
|
||||
@ -596,9 +597,6 @@ func PVMultiNodeCheck(client clientset.Interface, timeouts *framework.TimeoutCon
|
||||
e2epod.SetAntiAffinity(&secondNode, actualNodeName)
|
||||
ginkgo.By(fmt.Sprintf("checking the created volume is readable and retains data on another node %+v", secondNode))
|
||||
command = "grep 'hello world' /mnt/test/data"
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
command = "select-string 'hello world' /mnt/test/data"
|
||||
}
|
||||
pod = StartInPodWithVolume(client, claim.Namespace, claim.Name, "pvc-reader-node2", command, secondNode)
|
||||
framework.ExpectNoError(e2epod.WaitForPodSuccessInNamespaceTimeout(client, pod.Name, pod.Namespace, timeouts.PodStartSlow))
|
||||
runningPod, err = client.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
|
||||
|
@ -323,11 +323,7 @@ func (s *subPathTestSuite) DefineTests(driver storageframework.TestDriver, patte
|
||||
|
||||
// Create the directory
|
||||
var command string
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
command = fmt.Sprintf("mkdir -p %v; New-Item -itemtype File -path %v", l.subPathDir, probeFilePath)
|
||||
} else {
|
||||
command = fmt.Sprintf("mkdir -p %v; touch %v", l.subPathDir, probeFilePath)
|
||||
}
|
||||
command = fmt.Sprintf("mkdir -p %v; touch %v", l.subPathDir, probeFilePath)
|
||||
setInitCommand(l.pod, command)
|
||||
testPodContainerRestart(f, l.pod)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user