initial rough integration test for replication

This commit is contained in:
Pieter Noordhuis 2010-05-14 20:50:58 +02:00
parent 1c4114be40
commit 85ecc65edc
3 changed files with 43 additions and 0 deletions

View 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}
}
}

View File

@ -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} {
expr {int(rand()*$max)}
}

View File

@ -60,6 +60,7 @@ proc main {} {
execute_tests "unit/sort"
execute_tests "unit/expire"
execute_tests "unit/other"
execute_tests "integration/replication"
puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed"
if {$::failed > 0} {