Skip to content

Commit

Permalink
Check output of ls commands to ensure it match whats expected
Browse files Browse the repository at this point in the history
Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>
  • Loading branch information
unexge committed Nov 15, 2024
1 parent 991728e commit fb140b9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/e2e-kubernetes/testsuites/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/rand"
"os"
"path/filepath"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -77,6 +78,16 @@ func checkListingPath(f *framework.Framework, pod *v1.Pod, path string) {
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("ls %s", path))
}

func checkListingPathWithEntries(f *framework.Framework, pod *v1.Pod, path string, entries []string) {
cmd := fmt.Sprintf("ls %s", path)
stdout, stderr, err := e2evolume.PodExec(f, pod, cmd)
framework.ExpectNoError(err,
"%q should succeed, but failed with error message %q\nstdout: %s\nstderr: %s",
cmd, err, stdout, stderr)

gomega.Expect(strings.Fields(stdout)).To(gomega.Equal(entries))
}

// checkBasicFileOperations verifies basic file operations works in the given `basePath` inside the `pod`.
func checkBasicFileOperations(f *framework.Framework, pod *v1.Pod, basePath string) {
framework.Logf("Checking basic file operations inside pod %s at %s", pod.UID, basePath)
Expand All @@ -91,9 +102,8 @@ func checkBasicFileOperations(f *framework.Framework, pod *v1.Pod, basePath stri
checkWriteToPath(f, pod, first, testWriteSize, seed)
checkReadFromPath(f, pod, first, testWriteSize, seed)
e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("mkdir %s && cd %s && touch %s", dir, dir, second))
checkListingPath(f, pod, dir)
checkListingPath(f, pod, basePath)
checkListingPath(f, pod, second)
checkListingPathWithEntries(f, pod, dir, []string{"second"})
checkListingPathWithEntries(f, pod, basePath, []string{"first", "test-dir"})
checkDeletingPath(f, pod, first)
checkDeletingPath(f, pod, second)
}
Expand Down

0 comments on commit fb140b9

Please sign in to comment.