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