mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Update storage test suits for Windows
Update storage test suits to enable some tests on Windows Change-Id: I1f596bb9f7a0f41ae398aec43406ee5c753cdce3
This commit is contained in:
parent
0469db9fe7
commit
56373aa10d
@ -388,7 +388,7 @@ func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Prefix + "-" + podSuffix,
|
Name: config.Prefix + "-" + podSuffix,
|
||||||
Image: GetTestImage(framework.BusyBoxImage),
|
Image: GetDefaultTestImage(),
|
||||||
WorkingDir: "/opt",
|
WorkingDir: "/opt",
|
||||||
// An imperative and easily debuggable container which reads/writes vol contents for
|
// An imperative and easily debuggable container which reads/writes vol contents for
|
||||||
// us to scan in the tests or by eye.
|
// us to scan in the tests or by eye.
|
||||||
@ -654,9 +654,45 @@ func GeneratePodSecurityContext(fsGroup *int64, seLinuxOptions *v1.SELinuxOption
|
|||||||
// GetTestImage returns the image name with the given input
|
// GetTestImage returns the image name with the given input
|
||||||
// If the Node OS is windows, currently we return Agnhost image for Windows node
|
// If the Node OS is windows, currently we return Agnhost image for Windows node
|
||||||
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
|
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
|
||||||
func GetTestImage(image string) string {
|
func GetTestImage(id int) string {
|
||||||
if framework.NodeOSDistroIs("windows") {
|
if framework.NodeOSDistroIs("windows") {
|
||||||
return imageutils.GetE2EImage(imageutils.Agnhost)
|
return imageutils.GetE2EImage(imageutils.Agnhost)
|
||||||
}
|
}
|
||||||
return image
|
return imageutils.GetE2EImage(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTestImageID returns the image id with the given input
|
||||||
|
// If the Node OS is windows, currently we return Agnhost image for Windows node
|
||||||
|
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
|
||||||
|
func GetTestImageID(id int) int {
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
return imageutils.Agnhost
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDefaultTestImage returns the default test image based on OS.
|
||||||
|
// If the node OS is windows, currently we return Agnhost image for Windows node
|
||||||
|
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
|
||||||
|
// If the node OS is linux, return busybox image
|
||||||
|
func GetDefaultTestImage() string {
|
||||||
|
return imageutils.GetE2EImage(GetDefaultTestImageID())
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDefaultTestImageID returns the default test image id based on OS.
|
||||||
|
// If the node OS is windows, currently we return Agnhost image for Windows node
|
||||||
|
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
|
||||||
|
// If the node OS is linux, return busybox image
|
||||||
|
func GetDefaultTestImageID() int {
|
||||||
|
return GetTestImageID(imageutils.BusyBox)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinuxLabel returns the default SELinuxLabel based on OS.
|
||||||
|
// If the node OS is windows, it will return nil
|
||||||
|
func GetLinuxLabel() *v1.SELinuxOptions {
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &v1.SELinuxOptions{
|
||||||
|
Level: "s0:c0,c1"}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||||
|
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/utils"
|
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||||
)
|
)
|
||||||
@ -166,7 +167,7 @@ func (s *disruptiveTestSuite) DefineTests(driver TestDriver, pattern testpattern
|
|||||||
InlineVolumeSources: inlineSources,
|
InlineVolumeSources: inlineSources,
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2epv.SELinuxLabel,
|
||||||
NodeSelection: l.config.ClientNodeSelection,
|
NodeSelection: l.config.ClientNodeSelection,
|
||||||
ImageID: getTestImage(),
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, &podConfig, framework.PodStartTimeout)
|
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, &podConfig, framework.PodStartTimeout)
|
||||||
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
||||||
|
@ -352,7 +352,7 @@ func StartInPodWithInlineVolume(c clientset.Interface, ns, podName, command stri
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: "csi-volume-tester",
|
Name: "csi-volume-tester",
|
||||||
Image: e2evolume.GetTestImage(framework.BusyBoxImage),
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
Command: e2evolume.GenerateScriptCmd(command),
|
Command: e2evolume.GenerateScriptCmd(command),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||||
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
|
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
||||||
@ -405,8 +404,9 @@ func testAccessMultipleVolumes(f *framework.Framework, cs clientset.Interface, n
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: ns,
|
NS: ns,
|
||||||
PVCs: pvcs,
|
PVCs: pvcs,
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: node,
|
NodeSelection: node,
|
||||||
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, framework.PodStartTimeout)
|
pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, framework.PodStartTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -482,11 +482,11 @@ func TestConcurrentAccessToSingleVolume(f *framework.Framework, cs clientset.Int
|
|||||||
ginkgo.By(fmt.Sprintf("Creating pod%d with a volume on %+v", index, node))
|
ginkgo.By(fmt.Sprintf("Creating pod%d with a volume on %+v", index, node))
|
||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: ns,
|
NS: ns,
|
||||||
ImageID: imageutils.DebianIptables,
|
|
||||||
PVCs: []*v1.PersistentVolumeClaim{pvc},
|
PVCs: []*v1.PersistentVolumeClaim{pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: node,
|
NodeSelection: node,
|
||||||
PVCsReadOnly: readOnly,
|
PVCsReadOnly: readOnly,
|
||||||
|
ImageID: e2evolume.GetTestImageID(imageutils.DebianIptables),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, framework.PodStartTimeout)
|
pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, framework.PodStartTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -649,8 +649,9 @@ func initializeVolume(cs clientset.Interface, ns string, pvc *v1.PersistentVolum
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: ns,
|
NS: ns,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{pvc},
|
PVCs: []*v1.PersistentVolumeClaim{pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: node,
|
NodeSelection: node,
|
||||||
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.CreateSecPod(cs, &podConfig, framework.PodStartTimeout)
|
pod, err := e2epod.CreateSecPod(cs, &podConfig, framework.PodStartTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -666,7 +666,7 @@ func StartInPodWithVolume(c clientset.Interface, ns, claimName, podName, command
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: "volume-tester",
|
Name: "volume-tester",
|
||||||
Image: e2evolume.GetTestImage(framework.BusyBoxImage),
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
Command: e2evolume.GenerateScriptCmd(command),
|
Command: e2evolume.GenerateScriptCmd(command),
|
||||||
VolumeMounts: []v1.VolumeMount{
|
VolumeMounts: []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
|
@ -443,7 +443,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
|
|||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// Change volume container to busybox so we can exec later
|
// Change volume container to busybox so we can exec later
|
||||||
l.pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
|
l.pod.Spec.Containers[1].Image = e2evolume.GetDefaultTestImage()
|
||||||
l.pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
l.pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
||||||
l.pod.Spec.Containers[1].Args = nil
|
l.pod.Spec.Containers[1].Args = nil
|
||||||
|
|
||||||
@ -541,7 +541,7 @@ func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source *
|
|||||||
InitContainers: []v1.Container{
|
InitContainers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: fmt.Sprintf("init-volume-%s", suffix),
|
Name: fmt.Sprintf("init-volume-%s", suffix),
|
||||||
Image: e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)),
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
VolumeMounts: []v1.VolumeMount{volumeMount, probeMount},
|
VolumeMounts: []v1.VolumeMount{volumeMount, probeMount},
|
||||||
SecurityContext: e2evolume.GenerateSecurityContext(privilegedSecurityContext),
|
SecurityContext: e2evolume.GenerateSecurityContext(privilegedSecurityContext),
|
||||||
},
|
},
|
||||||
@ -610,7 +610,7 @@ func volumeFormatPod(f *framework.Framework, volumeSource *v1.VolumeSource) *v1.
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: fmt.Sprintf("init-volume-%s", f.Namespace.Name),
|
Name: fmt.Sprintf("init-volume-%s", f.Namespace.Name),
|
||||||
Image: e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)),
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
Command: e2evolume.GenerateScriptCmd("echo nothing"),
|
Command: e2evolume.GenerateScriptCmd("echo nothing"),
|
||||||
VolumeMounts: []v1.VolumeMount{
|
VolumeMounts: []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
@ -789,10 +789,10 @@ func (h *podContainerRestartHooks) FixLivenessProbe(pod *v1.Pod, probeFilePath s
|
|||||||
func testPodContainerRestartWithHooks(f *framework.Framework, pod *v1.Pod, hooks *podContainerRestartHooks) {
|
func testPodContainerRestartWithHooks(f *framework.Framework, pod *v1.Pod, hooks *podContainerRestartHooks) {
|
||||||
pod.Spec.RestartPolicy = v1.RestartPolicyOnFailure
|
pod.Spec.RestartPolicy = v1.RestartPolicyOnFailure
|
||||||
|
|
||||||
pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
|
pod.Spec.Containers[0].Image = e2evolume.GetDefaultTestImage()
|
||||||
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
||||||
pod.Spec.Containers[0].Args = nil
|
pod.Spec.Containers[0].Args = nil
|
||||||
pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
|
pod.Spec.Containers[1].Image = e2evolume.GetDefaultTestImage()
|
||||||
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
||||||
pod.Spec.Containers[1].Args = nil
|
pod.Spec.Containers[1].Args = nil
|
||||||
hooks.AddLivenessProbe(pod, probeFilePath)
|
hooks.AddLivenessProbe(pod, probeFilePath)
|
||||||
@ -963,10 +963,10 @@ func testSubpathReconstruction(f *framework.Framework, hostExec utils.HostExec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Change to busybox
|
// Change to busybox
|
||||||
pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
|
pod.Spec.Containers[0].Image = e2evolume.GetDefaultTestImage()
|
||||||
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
||||||
pod.Spec.Containers[0].Args = nil
|
pod.Spec.Containers[0].Args = nil
|
||||||
pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
|
pod.Spec.Containers[1].Image = e2evolume.GetDefaultTestImage()
|
||||||
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
|
||||||
pod.Spec.Containers[1].Args = nil
|
pod.Spec.Containers[1].Args = nil
|
||||||
// If grace period is too short, then there is not enough time for the volume
|
// If grace period is too short, then there is not enough time for the volume
|
||||||
|
@ -32,11 +32,9 @@ import (
|
|||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
|
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||||
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
|
e2evolume "k8s.io/kubernetes/test/e2e/framework/volume"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -177,9 +175,9 @@ func (v *volumeExpandTestSuite) DefineTests(driver TestDriver, pattern testpatte
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: f.Namespace.Name,
|
NS: f.Namespace.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: l.config.ClientNodeSelection,
|
NodeSelection: l.config.ClientNodeSelection,
|
||||||
ImageID: getTestImage(),
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
l.pod, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, framework.PodStartTimeout)
|
l.pod, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, framework.PodStartTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -221,9 +219,9 @@ func (v *volumeExpandTestSuite) DefineTests(driver TestDriver, pattern testpatte
|
|||||||
podConfig = e2epod.Config{
|
podConfig = e2epod.Config{
|
||||||
NS: f.Namespace.Name,
|
NS: f.Namespace.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: l.config.ClientNodeSelection,
|
NodeSelection: l.config.ClientNodeSelection,
|
||||||
ImageID: getTestImage(),
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
l.pod2, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, resizedPodStartupTimeout)
|
l.pod2, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, resizedPodStartupTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -249,9 +247,9 @@ func (v *volumeExpandTestSuite) DefineTests(driver TestDriver, pattern testpatte
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: f.Namespace.Name,
|
NS: f.Namespace.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.resource.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: l.config.ClientNodeSelection,
|
NodeSelection: l.config.ClientNodeSelection,
|
||||||
ImageID: getTestImage(),
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
l.pod, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, framework.PodStartTimeout)
|
l.pod, err = e2epod.CreateSecPodWithNodeSelection(f.ClientSet, &podConfig, framework.PodStartTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -426,12 +424,3 @@ func WaitForFSResize(pvc *v1.PersistentVolumeClaim, c clientset.Interface) (*v1.
|
|||||||
}
|
}
|
||||||
return updatedPVC, nil
|
return updatedPVC, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: after issue https://github.com/kubernetes/kubernetes/issues/81245 is resolved
|
|
||||||
// this utility can be moved to e2epod
|
|
||||||
func getTestImage() int {
|
|
||||||
if framework.NodeOSDistroIs("windows") {
|
|
||||||
return imageutils.Agnhost
|
|
||||||
}
|
|
||||||
return imageutils.BusyBox
|
|
||||||
}
|
|
||||||
|
@ -141,7 +141,7 @@ func (t *volumeIOTestSuite) DefineTests(driver TestDriver, pattern testpatterns.
|
|||||||
l.migrationCheck.validateMigrationVolumeOpCounts()
|
l.migrationCheck.validateMigrationVolumeOpCounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.It("should write files of various sizes, verify size, validate content [Slow]", func() {
|
ginkgo.It("should write files of various sizes, verify size, validate content [Slow][LinuxOnly]", func() {
|
||||||
init()
|
init()
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ func makePodSpec(config e2evolume.TestConfig, initCmd string, volsrc v1.VolumeSo
|
|||||||
InitContainers: []v1.Container{
|
InitContainers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Prefix + "-io-init",
|
Name: config.Prefix + "-io-init",
|
||||||
Image: framework.BusyBoxImage,
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
Command: []string{
|
Command: []string{
|
||||||
"/bin/sh",
|
"/bin/sh",
|
||||||
"-c",
|
"-c",
|
||||||
@ -214,7 +214,7 @@ func makePodSpec(config e2evolume.TestConfig, initCmd string, volsrc v1.VolumeSo
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: config.Prefix + "-io-client",
|
Name: config.Prefix + "-io-client",
|
||||||
Image: framework.BusyBoxImage,
|
Image: e2evolume.GetDefaultTestImage(),
|
||||||
Command: []string{
|
Command: []string{
|
||||||
"/bin/sh",
|
"/bin/sh",
|
||||||
"-c",
|
"-c",
|
||||||
|
@ -215,8 +215,9 @@ func (t *volumeModeTestSuite) DefineTests(driver TestDriver, pattern testpattern
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: l.ns.Name,
|
NS: l.ns.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
NodeSelection: l.config.ClientNodeSelection,
|
NodeSelection: l.config.ClientNodeSelection,
|
||||||
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.MakeSecPod(&podConfig)
|
pod, err := e2epod.MakeSecPod(&podConfig)
|
||||||
framework.ExpectNoError(err, "Failed to create pod")
|
framework.ExpectNoError(err, "Failed to create pod")
|
||||||
@ -300,7 +301,8 @@ func (t *volumeModeTestSuite) DefineTests(driver TestDriver, pattern testpattern
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: l.ns.Name,
|
NS: l.ns.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.MakeSecPod(&podConfig)
|
pod, err := e2epod.MakeSecPod(&podConfig)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
@ -356,7 +358,8 @@ func (t *volumeModeTestSuite) DefineTests(driver TestDriver, pattern testpattern
|
|||||||
podConfig := e2epod.Config{
|
podConfig := e2epod.Config{
|
||||||
NS: l.ns.Name,
|
NS: l.ns.Name,
|
||||||
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
PVCs: []*v1.PersistentVolumeClaim{l.Pvc},
|
||||||
SeLinuxLabel: e2epv.SELinuxLabel,
|
SeLinuxLabel: e2evolume.GetLinuxLabel(),
|
||||||
|
ImageID: e2evolume.GetDefaultTestImageID(),
|
||||||
}
|
}
|
||||||
pod, err := e2epod.MakeSecPod(&podConfig)
|
pod, err := e2epod.MakeSecPod(&podConfig)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
@ -227,7 +227,7 @@ func testScriptInPod(
|
|||||||
Containers: []v1.Container{
|
Containers: []v1.Container{
|
||||||
{
|
{
|
||||||
Name: fmt.Sprintf("exec-container-%s", suffix),
|
Name: fmt.Sprintf("exec-container-%s", suffix),
|
||||||
Image: e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.Nginx)),
|
Image: e2evolume.GetTestImage(imageutils.Nginx),
|
||||||
Command: command,
|
Command: command,
|
||||||
VolumeMounts: []v1.VolumeMount{
|
VolumeMounts: []v1.VolumeMount{
|
||||||
{
|
{
|
||||||
|
@ -69,14 +69,18 @@ const (
|
|||||||
|
|
||||||
// PodExec runs f.ExecCommandInContainerWithFullOutput to execute a shell cmd in target pod
|
// PodExec runs f.ExecCommandInContainerWithFullOutput to execute a shell cmd in target pod
|
||||||
func PodExec(f *framework.Framework, pod *v1.Pod, shExec string) (string, string, error) {
|
func PodExec(f *framework.Framework, pod *v1.Pod, shExec string) (string, string, error) {
|
||||||
stdout, stderr, err := f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", shExec)
|
if framework.NodeOSDistroIs("windows") {
|
||||||
return stdout, stderr, err
|
return f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "powershell", "/c", shExec)
|
||||||
|
}
|
||||||
|
return f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", shExec)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyExecInPodSucceed verifies shell cmd in target pod succeed
|
// VerifyExecInPodSucceed verifies shell cmd in target pod succeed
|
||||||
func VerifyExecInPodSucceed(f *framework.Framework, pod *v1.Pod, shExec string) {
|
func VerifyExecInPodSucceed(f *framework.Framework, pod *v1.Pod, shExec string) {
|
||||||
stdout, stderr, err := PodExec(f, pod, shExec)
|
stdout, stderr, err := PodExec(f, pod, shExec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
if exiterr, ok := err.(uexec.CodeExitError); ok {
|
if exiterr, ok := err.(uexec.CodeExitError); ok {
|
||||||
exitCode := exiterr.ExitStatus()
|
exitCode := exiterr.ExitStatus()
|
||||||
framework.ExpectNoError(err,
|
framework.ExpectNoError(err,
|
||||||
@ -636,13 +640,19 @@ func CheckReadWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persis
|
|||||||
// text -> file1 (write to file)
|
// text -> file1 (write to file)
|
||||||
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo 'Hello world.' > %s/file1.txt", path))
|
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo 'Hello world.' > %s/file1.txt", path))
|
||||||
// grep file1 (read from file and check contents)
|
// grep file1 (read from file and check contents)
|
||||||
VerifyExecInPodSucceed(f, pod, fmt.Sprintf("grep 'Hello world.' %s/file1.txt", path))
|
VerifyExecInPodSucceed(f, pod, readFile("Hello word.", path))
|
||||||
|
|
||||||
// Check that writing to directory as block volume fails
|
// Check that writing to directory as block volume fails
|
||||||
VerifyExecInPodFail(f, pod, fmt.Sprintf("dd if=/dev/urandom of=%s bs=64 count=1", path), 1)
|
VerifyExecInPodFail(f, pod, fmt.Sprintf("dd if=/dev/urandom of=%s bs=64 count=1", path), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readFile(content, path string) string {
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
return fmt.Sprintf("Select-String '%s' %s/file1.txt", content, path)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("grep 'Hello world.' %s/file1.txt", path)
|
||||||
|
}
|
||||||
|
|
||||||
// genBinDataFromSeed generate binData with random seed
|
// genBinDataFromSeed generate binData with random seed
|
||||||
func genBinDataFromSeed(len int, seed int64) []byte {
|
func genBinDataFromSeed(len int, seed int64) []byte {
|
||||||
binData := make([]byte, len)
|
binData := make([]byte, len)
|
||||||
|
Loading…
Reference in New Issue
Block a user