Skip to content

Commit

Permalink
Modify storage snapshottable and disruptive test for Windows
Browse files Browse the repository at this point in the history
Update snapshottable and disable disruptive test for Windows

Change-Id: I9d6beb25078c1941e405bf61545caae30326ddd1
  • Loading branch information
jingxu97 committed Feb 19, 2021
1 parent 9b3febc commit e2ec769
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions test/e2e/framework/volume/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/storage/testsuites/disruptive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/storage/testsuites/snapshottable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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{})
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e2ec769

Please sign in to comment.