diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index 520fec4465c..6ddbbca1f00 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -490,7 +490,7 @@ func TestConcurrentAccessToSingleVolume(f *framework.Framework, cs clientset.Int SeLinuxLabel: e2epod.GetLinuxLabel(), NodeSelection: node, PVCsReadOnly: readOnly, - ImageID: e2epod.GetTestImageID(imageutils.DebianIptables), + ImageID: e2epod.GetTestImageID(imageutils.JessieDnsutils), } pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, f.Timeouts.PodStart) defer func() { @@ -510,17 +510,21 @@ func TestConcurrentAccessToSingleVolume(f *framework.Framework, cs clientset.Int } } + path := "/mnt/volume1" + var seed int64 byteLen := 64 directIO := false // direct IO is needed for Block-mode PVs if *pvc.Spec.VolumeMode == v1.PersistentVolumeBlock { + if len(pods) < 1 { + framework.Failf("Number of pods shouldn't be less than 1, but got %d", len(pods)) + } // byteLen should be the size of a sector to enable direct I/O - byteLen = 512 + byteLen = utils.GetSectorSize(f, pods[0], path) directIO = true } - path := "/mnt/volume1" // Check if volume can be accessed from each pod for i, pod := range pods { index := i + 1 diff --git a/test/e2e/storage/utils/utils.go b/test/e2e/storage/utils/utils.go index 958f84b7ed9..50b1f6eca0f 100644 --- a/test/e2e/storage/utils/utils.go +++ b/test/e2e/storage/utils/utils.go @@ -24,6 +24,7 @@ import ( "math" "math/rand" "path/filepath" + "strconv" "strings" "time" @@ -571,6 +572,16 @@ func CheckWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persistent 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. +func GetSectorSize(f *framework.Framework, pod *v1.Pod, device string) int { + stdout, _, err := e2evolume.PodExec(f, pod, fmt.Sprintf("blockdev --getss %s", device)) + framework.ExpectNoError(err, "Failed to get sector size of %s", device) + ss, err := strconv.Atoi(stdout) + framework.ExpectNoError(err, "Sector size returned by blockdev command isn't integer value.") + + return ss +} + // findMountPoints returns all mount points on given node under specified directory. func findMountPoints(hostExec HostExec, node *v1.Node, dir string) []string { result, err := hostExec.IssueCommandWithResult(fmt.Sprintf(`find %s -type d -exec mountpoint {} \; | grep 'is a mountpoint$' || true`, dir), node)