@@ -3,8 +3,6 @@ package pika_integration
33import (
44 "context"
55 "time"
6- "os"
7- "path/filepath"
86 . "github.com/bsm/ginkgo/v2"
97 . "github.com/bsm/gomega"
108 "github.com/redis/go-redis/v9"
@@ -161,88 +159,6 @@ var _ = Describe("Server", func() {
161159 Expect (err ).NotTo (HaveOccurred ())
162160 Expect (val ).To (ContainSubstring ("Background append only file rewriting" ))
163161 })
164-
165- It ("should BgSave" , func () {
166- res := client .Set (ctx , "bgsava_key1" , "bgsava_value1" , 0 )
167- Expect (res .Err ()).NotTo (HaveOccurred ())
168- _ = client .Set (ctx , "bgsava_key2" , "bgsava_value2" , 0 )
169- Expect (res .Err ()).NotTo (HaveOccurred ())
170-
171- lastSaveBefore , err := client .LastSave (ctx ).Result ()
172- Expect (err ).NotTo (HaveOccurred ())
173-
174- currentDir , err := os .Getwd ()
175- Expect (err ).NotTo (HaveOccurred ())
176-
177- var pikaDir string
178- for currentDir != "/" {
179- if filepath .Base (currentDir ) == "pika" {
180- pikaDir = currentDir
181- break
182- }
183- currentDir = filepath .Dir (currentDir )
184- }
185- Expect (pikaDir ).NotTo (BeEmpty (), "Could not find 'pika' directory" )
186-
187- var dumpDirs []string
188- err = filepath .WalkDir (pikaDir , func (path string , info os.DirEntry , err error ) error {
189- if err != nil {
190- return err
191- }
192- if info .IsDir () && info .Name () == "dump" {
193- absPath , err := filepath .Abs (path )
194- if err != nil {
195- return err
196- }
197- dumpDirs = append (dumpDirs , absPath )
198- }
199- return nil
200- })
201- Expect (err ).NotTo (HaveOccurred (), "Error while searching for 'dump' directories" )
202- Expect (len (dumpDirs )).To (BeNumerically (">" , 0 ), "No 'dump' directories found in 'pika'" )
203-
204- shortestDumpDir := dumpDirs [0 ]
205- for _ , dir := range dumpDirs {
206- if len (dir ) < len (shortestDumpDir ) {
207- shortestDumpDir = dir
208- }
209- }
210-
211- dumpConfig := client .ConfigGet (ctx , "dump-path" )
212- Expect (dumpConfig .Err ()).NotTo (HaveOccurred ())
213- originalDumpPath , ok := dumpConfig .Val ()["dump-path" ]
214- Expect (ok ).To (BeTrue ())
215-
216- dumpPath := filepath .Join (filepath .Dir (shortestDumpDir ), originalDumpPath )
217-
218- res2 , err2 := client .BgSave (ctx ).Result ()
219- Expect (err2 ).NotTo (HaveOccurred ())
220- Expect (res .Err ()).NotTo (HaveOccurred ())
221- Expect (res2 ).To (ContainSubstring ("Background saving started" ))
222-
223- startTime := time .Now ()
224- maxWaitTime := 10 * time .Second
225-
226- for {
227- lastSaveAfter , err := client .LastSave (ctx ).Result ()
228- Expect (err ).NotTo (HaveOccurred ())
229-
230- if lastSaveAfter > lastSaveBefore {
231- break
232- }
233-
234- if time .Since (startTime ) > maxWaitTime {
235- Fail ("BGSAVE did not complete within the expected time" )
236- }
237-
238- time .Sleep (500 * time .Millisecond )
239- }
240-
241-
242- files , err := os .ReadDir (dumpPath )
243- Expect (err ).NotTo (HaveOccurred (), "Failed to read dump_path" )
244- Expect (len (files )).To (BeNumerically (">" , 0 ), "dump_tmp directory is empty, BGSAVE failed to create a file" )
245- })
246162
247163 It ("should FlushDb" , func () {
248164 res := client .Do (ctx , "flushdb" )
0 commit comments