Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing SELECT statement when dumping all dbs #38

Merged
merged 2 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion acceptance-tests/acceptance.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
[ "$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" {
Expand All @@ -31,4 +36,4 @@
@test "Pass when importing 1M key/values" {
run tests/1mkeys.sh
[ "$status" -eq 0 ]
}
}
27 changes: 27 additions & 0 deletions acceptance-tests/tests/multiple-dbs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh -e

NDBS=3

echo "-> Filling Redis with Mock Data..."
redis-cli -h redis FLUSHALL
for DB in `seq 1 $NDBS`; do
redis-cli -h redis -n $DB SET thisdb $DB
done

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

echo "-> Flushing DB and restoring dump..."
redis-cli -h redis FLUSHALL
redis-cli -h redis -n $DB --pipe <backup

NEWNDBS=`redis-cli -h redis info keyspace | grep keys | wc -l`

echo "-> Expecting right amount of DBS..."
if [ $NDBS -ne $NEWNDBS ]; then
echo "ERROR - only $NEWNDBS found, expected $NDBS"
exit 1
else
echo "OK - $NEWNDBS dbs"
exit 0
fi
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