From de7eb9438886f450ebba37dc0d5ea2d00eb3117b Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Fri, 6 Nov 2020 18:48:07 -0800 Subject: [PATCH] Modify storage snapshottable and disruptive test for Windows Update snapshottable and disable disruptive test for Windows Change-Id: I9d6beb25078c1941e405bf61545caae30326ddd1 --- test/e2e/framework/volume/fixtures.go | 6 +++--- test/e2e/storage/testsuites/disruptive.go | 3 ++- test/e2e/storage/testsuites/snapshottable.go | 16 ++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 7e687f3ef8a..e01f8b257b6 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -466,7 +466,7 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy } else { // Filesystem: check content fileName := fmt.Sprintf("/opt/%d/%s", i, test.File) - commands := generateReadFileCmd(fileName) + commands := GenerateReadFileCmd(fileName) _, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, commands, test.ExpectedContent, time.Minute) framework.ExpectNoError(err, "failed: finding the contents of the mounted file %s.", fileName) @@ -608,9 +608,9 @@ 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. +// 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 { +func GenerateReadFileCmd(fullPath string) []string { var commands []string if !framework.NodeOSDistroIs("windows") { commands = []string{"cat", fullPath} diff --git a/test/e2e/storage/testsuites/disruptive.go b/test/e2e/storage/testsuites/disruptive.go index bc259d2d93f..0649cb4dadb 100644 --- a/test/e2e/storage/testsuites/disruptive.go +++ b/test/e2e/storage/testsuites/disruptive.go @@ -41,7 +41,7 @@ func InitDisruptiveTestSuite() TestSuite { return &disruptiveTestSuite{ tsInfo: TestSuiteInfo{ Name: "disruptive", - FeatureTag: "[Disruptive]", + FeatureTag: "[Disruptive][LinuxOnly]", TestPatterns: []testpatterns.TestPattern{ // FSVolMode is already covered in subpath testsuite testpatterns.DefaultFsInlineVolume, @@ -166,6 +166,7 @@ func (s *disruptiveTestSuite) DefineTests(driver TestDriver, pattern testpattern InlineVolumeSources: inlineSources, SeLinuxLabel: e2epv.SELinuxLabel, NodeSelection: l.config.ClientNodeSelection, + ImageID: getTestImage(), } l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, &podConfig, framework.PodStartTimeout) framework.ExpectNoError(err, "While creating pods for kubelet restart test") diff --git a/test/e2e/storage/testsuites/snapshottable.go b/test/e2e/storage/testsuites/snapshottable.go index 3f8a958937d..8d928281ea8 100644 --- a/test/e2e/storage/testsuites/snapshottable.go +++ b/test/e2e/storage/testsuites/snapshottable.go @@ -48,6 +48,9 @@ const snapshotGroup = "snapshot.storage.k8s.io" // snapshot CRD api version const snapshotAPIVersion = "snapshot.storage.k8s.io/v1beta1" +// data file name +const datapath = "/mnt/test/data" + var ( // SnapshotGVR is GroupVersionResource for volumesnapshots SnapshotGVR = schema.GroupVersionResource{Group: snapshotGroup, Version: "v1beta1", Resource: "volumesnapshots"} @@ -151,13 +154,12 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt ginkgo.By("starting a pod to use the claim") originalMntTestData = fmt.Sprintf("hello from %s namespace", pvc.GetNamespace()) - command := fmt.Sprintf("echo '%s' > /mnt/test/data", originalMntTestData) + command := fmt.Sprintf("echo '%s' > %s", originalMntTestData, datapath) RunInPodWithVolume(cs, pvc.Namespace, pvc.Name, "pvc-snapshottable-tester", command, config.ClientNodeSelection) err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout) framework.ExpectNoError(err) - ginkgo.By("checking the claim") // Get new copy of the claim pvc, err = cs.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{}) @@ -239,7 +241,7 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt ginkgo.By("modifying the data in the source PVC") - command := fmt.Sprintf("echo '%s' > /mnt/test/data", modifiedMntTestData) + command := fmt.Sprintf("echo '%s' > %s", modifiedMntTestData, datapath) RunInPodWithVolume(cs, pvc.Namespace, pvc.Name, "pvc-snapshottable-data-tester", command, config.ClientNodeSelection) ginkgo.By("creating a pvc from the snapshot") @@ -274,11 +276,9 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt StopPod(cs, restoredPod) }) framework.ExpectNoError(e2epod.WaitForPodRunningInNamespaceSlow(cs, restoredPod.Name, restoredPod.Namespace)) - - command = "cat /mnt/test/data" - actualData, stderr, err := utils.PodExec(f, restoredPod, command) - framework.ExpectNoError(err, "command %q: stdout: %s\nstderr: %s", command, actualData, stderr) - framework.ExpectEqual(actualData, originalMntTestData) + commands := e2evolume.GenerateReadFileCmd(datapath) + _, err = framework.LookForStringInPodExec(restoredPod.Namespace, restoredPod.Name, commands, originalMntTestData, time.Minute) + framework.ExpectNoError(err) ginkgo.By("should delete the VolumeSnapshotContent according to its deletion policy") err = DeleteAndWaitSnapshot(dc, vs.GetNamespace(), vs.GetName(), framework.Poll, framework.SnapshotDeleteTimeout)