Commit e6ac6a17 authored by antirez's avatar antirez
Browse files

Cluster test: test that writes are retained during failovers.

In the test we use WAIT when the master and slave are up, and only later the
partition is created killing the master, so we are sure we don't incur
in failure modes that may lose writes in this test: the goal here is to
make sure that the elected slave was replicating correctly with the
master.
parent d080eea0
...@@ -49,6 +49,15 @@ while {[incr iterations -1]} { ...@@ -49,6 +49,15 @@ while {[incr iterations -1]} {
set slave_config_epoch [CI $slave cluster_my_epoch] set slave_config_epoch [CI $slave cluster_my_epoch]
} }
test "Cluster is writable before failover" {
for {set i 0} {$i < 100} {incr i} {
catch {$cluster set $key:$i $val:$i} err
assert {$err eq {OK}}
}
# Wait for the write to propagate to the slave
R $tokill wait 1 20000
}
test "Killing node #$tokill" { test "Killing node #$tokill" {
kill_instance redis $tokill kill_instance redis $tokill
} }
...@@ -67,9 +76,9 @@ while {[incr iterations -1]} { ...@@ -67,9 +76,9 @@ while {[incr iterations -1]} {
assert_cluster_state ok assert_cluster_state ok
} }
test "Cluster is writable" { test "Cluster is writable again" {
for {set i 0} {$i < 100} {incr i} { for {set i 0} {$i < 100} {incr i} {
catch {$cluster set $key:$i $val:$i} err catch {$cluster set $key:$i:2 $val:$i:2} err
assert {$err eq {OK}} assert {$err eq {OK}}
} }
} }
...@@ -90,6 +99,8 @@ while {[incr iterations -1]} { ...@@ -90,6 +99,8 @@ while {[incr iterations -1]} {
for {set i 0} {$i < 100} {incr i} { for {set i 0} {$i < 100} {incr i} {
catch {$cluster get $key:$i} err catch {$cluster get $key:$i} err
assert {$err eq "$val:$i"} assert {$err eq "$val:$i"}
catch {$cluster get $key:$i:2} err
assert {$err eq "$val:$i:2"}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment