summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-03-25 15:43:34 +0100
committerantirez <antirez@gmail.com>2020-03-25 15:43:34 +0100
commitc4d7f30e250b4b291e6d5893d9a3323df4a57c7c (patch)
tree9587dd7053d63d7d348bc3b47ef0fe8a1408a014
parent57fa355e56540a6fab61a5b8ecdda96225815632 (diff)
downloadredis-meaningful-offset.tar.gz
PSYNC2: meaningful offset test.meaningful-offset
-rw-r--r--tests/integration/psync2-pingoff.tcl61
-rw-r--r--tests/test_helper.tcl1
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/integration/psync2-pingoff.tcl b/tests/integration/psync2-pingoff.tcl
new file mode 100644
index 000000000..1cea290e7
--- /dev/null
+++ b/tests/integration/psync2-pingoff.tcl
@@ -0,0 +1,61 @@
+# Test the meaningful offset implementation to make sure masters
+# are able to PSYNC with replicas even if the replication stream
+# has pending PINGs at the end.
+
+start_server {tags {"psync2"}} {
+start_server {} {
+ # Config
+ set debug_msg 0 ; # Enable additional debug messages
+
+ for {set j 0} {$j < 2} {incr j} {
+ set R($j) [srv [expr 0-$j] client]
+ set R_host($j) [srv [expr 0-$j] host]
+ set R_port($j) [srv [expr 0-$j] port]
+ $R($j) CONFIG SET repl-ping-replica-period 1
+ if {$debug_msg} {puts "Log file: [srv [expr 0-$j] stdout]"}
+ }
+
+ # Setup replication
+ test "PSYNC2 meaningful offset: setup" {
+ $R(1) replicaof $R_host(0) $R_port(0)
+ $R(0) set foo bar
+ wait_for_condition 50 1000 {
+ [$R(0) dbsize] == 1 && [$R(1) dbsize] == 1
+ } else {
+ fail "Replicas not replicating from master"
+ }
+ }
+
+ test "PSYNC2 meaningful offset: write and wait replication" {
+ $R(0) INCR counter
+ $R(0) INCR counter
+ $R(0) INCR counter
+ wait_for_condition 50 1000 {
+ [$R(0) GET counter] eq [$R(1) GET counter]
+ } else {
+ fail "Master and replica don't agree about counter"
+ }
+ }
+
+ # In this test we'll make sure the replica will get stuck, but with
+ # an active connection: this way the master will continue to send PINGs
+ # every second (we modified the PING period earlier)
+ test "PSYNC2 meaningful offset: pause replica and promote it" {
+ $R(1) MULTI
+ $R(1) DEBUG SLEEP 5
+ $R(1) SLAVEOF NO ONE
+ $R(1) EXEC
+ $R(1) ping ; # Wait for it to return back available
+ }
+
+ test "Make the old master a replica of the new one and check conditions" {
+ set sync_partial [status $R(1) sync_partial_ok]
+ assert {$sync_partial == 0}
+ $R(0) REPLICAOF $R_host(1) $R_port(1)
+ wait_for_condition 50 1000 {
+ [status $R(1) sync_partial_ok] == 1
+ } else {
+ fail "The new master was not able to partial sync"
+ }
+ }
+}}
diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl
index 4dbead193..5cb43104b 100644
--- a/tests/test_helper.tcl
+++ b/tests/test_helper.tcl
@@ -47,6 +47,7 @@ set ::all_tests {
integration/logging
integration/psync2
integration/psync2-reg
+ integration/psync2-pingoff
unit/pubsub
unit/slowlog
unit/scripting