Skip to content

Commit

Permalink
Add missing SELECT when dumping DB
Browse files Browse the repository at this point in the history
  • Loading branch information
yannh committed Apr 23, 2022
1 parent a08705f commit 65f0d87
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions acceptance-tests/acceptance.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
#!/usr/bin/env bats

@test "Prints help on -h" {
run /redis-dump-go -h
[ "${lines[0]}" == 'Usage: /redis-dump-go [OPTION]...' ]
[ "$status" -eq 0 ]
}

@test "fail on incorrect parameters" {
run /redis-dump-go -fail
[ "$status" -eq 1 ]
}

@test "Pass when using a non-default db" {
run tests/select-db.sh
[ "$status" -eq 0 ]
}

@test "Pass when using a non-default db, and a password" {
run tests/select-db-with-password.sh
[ "$status" -eq 0 ]
}

@test "Dumping / restoring all databases" {
run tests/multiple-dbs.sh
[ "$status" -eq 0 ]
}

# https://github.com/yannh/redis-dump-go/issues/11
# https://github.com/yannh/redis-dump-go/issues/18
@test "Pass when importing a ZSET with 1M entries" {
run tests/large-zset.sh
[ "$status" -eq 0 ]
}

@test "Pass when importing 1M key/values" {
run tests/1mkeys.sh
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion acceptance-tests/tests/multiple-dbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ for DB in `seq 1 $NDBS`; do
done

echo "-> Dumping DB..."
time /redis-dump-go -host redis -n 250 -output resp >backup
time /redis-dump-go -host redis -n 250 -output commands >backup

echo "-> Flushing DB and restoring dump..."
redis-cli -h redis FLUSHALL
Expand Down
2 changes: 2 additions & 0 deletions pkg/redisdump/redisdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ func dumpDB(client radix.Client, db *uint8, filter string, nWorkers int, withTTL
keyGenerator = scanKeysLegacy
}

logger.Print(serializer([]string{"SELECT", fmt.Sprint(*db)}))

errors := make(chan error)
nErrors := 0
go func() {
Expand Down

0 comments on commit 65f0d87

Please sign in to comment.