Skip to content

Commit

Permalink
find dump dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tsinow committed Sep 19, 2024
1 parent b21137c commit 0acbc38
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions tests/integration/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"
"os"
"fmt"
"path/filepath"
. "github.com/bsm/ginkgo/v2"
. "github.com/bsm/gomega"
"github.com/redis/go-redis/v9"
Expand Down Expand Up @@ -198,21 +199,40 @@ var _ = Describe("Server", func() {
dumpPath, ok := dumpConfig.Val()["dump-path"]
Expect(ok).To(BeTrue())

currentDir, err := os.Getwd()
Expect(err).NotTo(HaveOccurred())
fmt.Printf("Current working directory: %s\n", currentDir)
// Convert dumpPath to absolute path
baseDir := "/home/runner/work/pika/"
absDumpPath := filepath.Join(baseDir, dumpPath)

fmt.Printf("Dump path: %s\n", dumpPath)

// Check if dumpPath exists and is a directory
info, err := os.Stat(dumpPath)
info, err := os.Stat(absDumpPath)
if os.IsNotExist(err) {
Fail("Directory does not exist: " + dumpPath)
// If dumpPath does not exist, search for 'dump' directories
fmt.Println("Dump path does not exist. Searching for 'dump' directories...")

err = filepath.WalkDir(baseDir, func(path string, info os.DirEntry, err error) error {
if err != nil {
return err
}

if info.IsDir() && info.Name() == "dump" {
absPath, err := filepath.Abs(path)
if err != nil {
return err
}
fmt.Println("Found dump directory:", absPath)
}

return nil
})

if err != nil {
Fail("Error while searching for dump directories: " + err.Error())
}
} else if err != nil {
Fail("Error accessing directory: " + err.Error())
Fail("Error accessing dump path: " + err.Error())
} else {
Expect(info.IsDir()).To(BeTrue(), "dump path should be a directory")
}
Expect(info.IsDir()).To(BeTrue(), "dump path should be a directory")

files, err := os.ReadDir(dumpPath)
Expect(err).NotTo(HaveOccurred())
//need to delete test bgsave file?
Expand Down

0 comments on commit 0acbc38

Please sign in to comment.