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.
This commit is contained in:
antirez 2014-07-18 17:13:46 +02:00
parent 509c888dfa
commit 8d4ff87b26

View File

@ -49,6 +49,15 @@ while {[incr iterations -1]} {
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" {
kill_instance redis $tokill
}
@ -67,9 +76,9 @@ while {[incr iterations -1]} {
assert_cluster_state ok
}
test "Cluster is writable" {
test "Cluster is writable again" {
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}}
}
}
@ -90,6 +99,8 @@ while {[incr iterations -1]} {
for {set i 0} {$i < 100} {incr i} {
catch {$cluster get $key:$i} err
assert {$err eq "$val:$i"}
catch {$cluster get $key:$i:2} err
assert {$err eq "$val:$i:2"}
}
}
}