mirror of
https://github.com/fluencelabs/redis
synced 2025-03-31 14:51:04 +00:00
initial rough integration test for replication
This commit is contained in:
parent
1c4114be40
commit
85ecc65edc
tests
32
tests/integration/replication.tcl
Normal file
32
tests/integration/replication.tcl
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
start_server default.conf {} {
|
||||||
|
r set mykey foo
|
||||||
|
|
||||||
|
start_server default.conf {} {
|
||||||
|
test {Second server should have role master at first} {
|
||||||
|
s role
|
||||||
|
} {master}
|
||||||
|
|
||||||
|
test {SLAVEOF should start with link status "down"} {
|
||||||
|
r slaveof [srv -1 host] [srv -1 port]
|
||||||
|
s master_link_status
|
||||||
|
} {down}
|
||||||
|
|
||||||
|
test {The role should immediately be changed to "slave"} {
|
||||||
|
s role
|
||||||
|
} {slave}
|
||||||
|
|
||||||
|
wait_for_sync r
|
||||||
|
test {Sync should have transferred keys from master} {
|
||||||
|
r get mykey
|
||||||
|
} {foo}
|
||||||
|
|
||||||
|
test {The link status should be up} {
|
||||||
|
s master_link_status
|
||||||
|
} {up}
|
||||||
|
|
||||||
|
test {SET on the master should immediately propagate} {
|
||||||
|
r -1 set mykey bar
|
||||||
|
r 0 get mykey
|
||||||
|
} {bar}
|
||||||
|
}
|
||||||
|
}
|
@ -56,6 +56,16 @@ proc waitForBgrewriteaof r {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc wait_for_sync r {
|
||||||
|
while 1 {
|
||||||
|
if {[status r master_link_status] eq "down"} {
|
||||||
|
after 10
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proc randomInt {max} {
|
proc randomInt {max} {
|
||||||
expr {int(rand()*$max)}
|
expr {int(rand()*$max)}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ proc main {} {
|
|||||||
execute_tests "unit/sort"
|
execute_tests "unit/sort"
|
||||||
execute_tests "unit/expire"
|
execute_tests "unit/expire"
|
||||||
execute_tests "unit/other"
|
execute_tests "unit/other"
|
||||||
|
execute_tests "integration/replication"
|
||||||
|
|
||||||
puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed"
|
puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed"
|
||||||
if {$::failed > 0} {
|
if {$::failed > 0} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user