summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-01-12 09:41:57 +0200
committerOran Agra <oran@redislabs.com>2021-01-12 16:25:37 +0200
commit615eb0db86d01eb3cb3d0e78979a3482a7abfb43 (patch)
treed07c29d9d24afd3362f27d0ec179f11f5450f120
parent203feb6ea26b106765051dc96e5f7a4e6b2ee11d (diff)
downloadredis-615eb0db86d01eb3cb3d0e78979a3482a7abfb43.tar.gz
Fix cluster diskless load swapdb test (#8308)
The test was trying to wait for the replica to start loading the rdb from the master before it kills the master, but it was actually waiting for ROLE to be in "sync" mode, which corresponds to REPL_STATE_TRANSFER that starts before the actual loading starts. now instead it waits for the loading flag to be set. Besides, the test was dependent on the previous configuration of the servers, relying on the fact the replica is configured to persist (either RDB of AOF), now it is set explicitly. (cherry picked from commit 264953871b97bcc3d663cd006578c151a13b48ca)
-rw-r--r--tests/cluster/cluster.tcl5
-rw-r--r--tests/cluster/tests/17-diskless-load-swapdb.tcl12
2 files changed, 12 insertions, 5 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl
index f9a0e180d..ae0743c51 100644
--- a/tests/cluster/cluster.tcl
+++ b/tests/cluster/cluster.tcl
@@ -57,6 +57,11 @@ proc CI {n field} {
get_info_field [R $n cluster info] $field
}
+# Return the value of the specified INFO field.
+proc s {n field} {
+ get_info_field [R $n info] $field
+}
+
# Assuming nodes are reest, this function performs slots allocation.
# Only the first 'n' nodes are used.
proc cluster_allocate_slots {n} {
diff --git a/tests/cluster/tests/17-diskless-load-swapdb.tcl b/tests/cluster/tests/17-diskless-load-swapdb.tcl
index a035be7be..612818cb7 100644
--- a/tests/cluster/tests/17-diskless-load-swapdb.tcl
+++ b/tests/cluster/tests/17-diskless-load-swapdb.tcl
@@ -22,6 +22,8 @@ test "Right to restore backups when fail to diskless load " {
$replica READONLY
$replica config set repl-diskless-load swapdb
+ $replica config set appendonly no
+ $replica config set save ""
$replica config rewrite
$master config set repl-backlog-size 1024
$master config set repl-diskless-sync yes
@@ -38,7 +40,8 @@ test "Right to restore backups when fail to diskless load " {
assert_equal {1} [$replica get $slot0_key]
assert_equal $slot0_key [$replica CLUSTER GETKEYSINSLOT 0 1]
- # Kill the replica
+ # Save an RDB and kill the replica
+ $replica save
kill_instance redis $replica_id
# Delete the key from master
@@ -60,13 +63,12 @@ test "Right to restore backups when fail to diskless load " {
restart_instance redis $replica_id
$replica READONLY
- # Start full sync
+ # Start full sync, wait till after db is flushed (backed up)
wait_for_condition 500 10 {
- [string match "*sync*" [$replica role]]
+ [s $replica_id loading] eq 1
} else {
fail "Fail to full sync"
}
- after 100
# Kill master, abort full sync
kill_instance redis $master_id
@@ -74,4 +76,4 @@ test "Right to restore backups when fail to diskless load " {
# Replica keys and keys to slots map still both are right
assert_equal {1} [$replica get $slot0_key]
assert_equal $slot0_key [$replica CLUSTER GETKEYSINSLOT 0 1]
-} \ No newline at end of file
+}