2
0

wait.tcl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. start_server {tags {"wait"}} {
  2. start_server {} {
  3. set slave [srv 0 client]
  4. set slave_host [srv 0 host]
  5. set slave_port [srv 0 port]
  6. set master [srv -1 client]
  7. set master_host [srv -1 host]
  8. set master_port [srv -1 port]
  9. test {Setup slave} {
  10. $slave slaveof $master_host $master_port
  11. wait_for_condition 50 100 {
  12. [s 0 master_link_status] eq {up}
  13. } else {
  14. fail "Replication not started."
  15. }
  16. }
  17. test {WAIT should acknowledge 1 additional copy of the data} {
  18. $master set foo 0
  19. $master incr foo
  20. $master incr foo
  21. $master incr foo
  22. assert {[$master wait 1 5000] == 1}
  23. assert {[$slave get foo] == 3}
  24. }
  25. test {WAIT should not acknowledge 2 additional copies of the data} {
  26. $master incr foo
  27. assert {[$master wait 2 1000] <= 1}
  28. }
  29. test {WAIT should not acknowledge 1 additional copy if slave is blocked} {
  30. exec src/redis-cli -h $slave_host -p $slave_port debug sleep 5 > /dev/null 2> /dev/null &
  31. after 1000 ;# Give redis-cli the time to execute the command.
  32. $master set foo 0
  33. $master incr foo
  34. $master incr foo
  35. $master incr foo
  36. assert {[$master wait 1 3000] == 0}
  37. }
  38. }}