Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify storage snapshottable test for Windows #96330

Merged
merged 1 commit into from Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/e2e/framework/volume/fixtures.go
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
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
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