From 2d72550a398ca5115c5ac6308ab1634a4a7a7a9d Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Mon, 3 Aug 2020 22:25:44 +0530 Subject: [PATCH] e2e: introduce writeDataInPod() to write data to an attached PVC writeDataInPod() write data to the attached PVC using `dd` command It leave the pod and pvc state as it is. Signed-off-by: Humble Chirammal --- e2e/utils.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/e2e/utils.go b/e2e/utils.go index 6f1aa423e..3f2f9b0d3 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -283,7 +283,6 @@ func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, en Expect(stdErr).Should(BeEmpty()) // remove new line present in fsID fsID = strings.Trim(fsID, "\n") - if clusterID != "" { fsID = clusterID } @@ -928,6 +927,27 @@ func listRBDImages(f *framework.Framework) []string { return imgInfos } +// writeDataInPod fill zero content to a file in the provided POD volume. +func writeDataInPod(app *v1.Pod, f *framework.Framework) error { + app.Labels = map[string]string{"app": "write-data-in-pod"} + app.Namespace = f.UniqueName + + err := createApp(f.ClientSet, app, deployTimeout) + if err != nil { + return err + } + opt := metav1.ListOptions{ + LabelSelector: "app=write-data-in-pod", + } + // write data to PVC. The idea here is to fill some content in the file + // instead of filling and reverifying the md5sum/data integrity + filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" + // While writing more data we are encountering issues in E2E timeout, so keeping it low for now + _, writeErr := execCommandInPod(f, fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10 status=none", filePath), app.Namespace, &opt) + Expect(writeErr).Should(BeEmpty()) + return nil +} + func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error { data := "checking data persist" pvc, err := loadPVC(pvcPath)