mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
Test: WAIT tests added in wait.tcl unit.
This commit is contained in:
parent
8fb3ad2444
commit
f115461f4e
@ -55,6 +55,7 @@ set ::all_tests {
|
||||
unit/memefficiency
|
||||
unit/hyperloglog
|
||||
unit/lazyfree
|
||||
unit/wait
|
||||
}
|
||||
# Index to the next test to run in the ::all_tests list.
|
||||
set ::next_test 0
|
||||
|
42
tests/unit/wait.tcl
Normal file
42
tests/unit/wait.tcl
Normal file
@ -0,0 +1,42 @@
|
||||
start_server {tags {"wait"}} {
|
||||
start_server {} {
|
||||
set slave [srv 0 client]
|
||||
set slave_host [srv 0 host]
|
||||
set slave_port [srv 0 port]
|
||||
set master [srv -1 client]
|
||||
set master_host [srv -1 host]
|
||||
set master_port [srv -1 port]
|
||||
|
||||
test {Setup slave} {
|
||||
$slave slaveof $master_host $master_port
|
||||
wait_for_condition 50 100 {
|
||||
[s 0 master_link_status] eq {up}
|
||||
} else {
|
||||
fail "Replication not started."
|
||||
}
|
||||
}
|
||||
|
||||
test {WAIT should acknowledge 1 additional copy of the data} {
|
||||
$master set foo 0
|
||||
$master incr foo
|
||||
$master incr foo
|
||||
$master incr foo
|
||||
assert {[$master wait 1 5000] == 1}
|
||||
assert {[$slave get foo] == 3}
|
||||
}
|
||||
|
||||
test {WAIT should not acknowledge 2 additional copies of the data} {
|
||||
$master incr foo
|
||||
assert {[$master wait 2 1000] <= 1}
|
||||
}
|
||||
|
||||
test {WAIT should not acknowledge 1 additional copy if slave is blocked} {
|
||||
exec src/redis-cli -h $slave_host -p $slave_port debug sleep 5 > /dev/null 2> /dev/null &
|
||||
after 1000 ;# Give redis-cli the time to execute the command.
|
||||
$master set foo 0
|
||||
$master incr foo
|
||||
$master incr foo
|
||||
$master incr foo
|
||||
assert {[$master wait 1 3000] == 0}
|
||||
}
|
||||
}}
|
Loading…
Reference in New Issue
Block a user