1
0

wait.tcl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. source tests/support/cli.tcl
  2. start_server {tags {"wait network external:skip"}} {
  3. start_server {} {
  4. set slave [srv 0 client]
  5. set slave_host [srv 0 host]
  6. set slave_port [srv 0 port]
  7. set slave_pid [srv 0 pid]
  8. set master [srv -1 client]
  9. set master_host [srv -1 host]
  10. set master_port [srv -1 port]
  11. test {Setup slave} {
  12. $slave slaveof $master_host $master_port
  13. wait_for_condition 50 100 {
  14. [s 0 master_link_status] eq {up}
  15. } else {
  16. fail "Replication not started."
  17. }
  18. }
  19. test {WAIT should acknowledge 1 additional copy of the data} {
  20. $master set foo 0
  21. $master incr foo
  22. $master incr foo
  23. $master incr foo
  24. assert {[$master wait 1 5000] == 1}
  25. assert {[$slave get foo] == 3}
  26. }
  27. test {WAIT should not acknowledge 2 additional copies of the data} {
  28. $master incr foo
  29. assert {[$master wait 2 1000] <= 1}
  30. }
  31. test {WAIT should not acknowledge 1 additional copy if slave is blocked} {
  32. exec kill -SIGSTOP $slave_pid
  33. $master set foo 0
  34. $master incr foo
  35. $master incr foo
  36. $master incr foo
  37. assert {[$master wait 1 1000] == 0}
  38. exec kill -SIGCONT $slave_pid
  39. assert {[$master wait 1 1000] == 1}
  40. }
  41. test {WAIT implicitly blocks on client pause since ACKs aren't sent} {
  42. exec kill -SIGSTOP $slave_pid
  43. $master multi
  44. $master incr foo
  45. $master client pause 10000 write
  46. $master exec
  47. assert {[$master wait 1 1000] == 0}
  48. $master client unpause
  49. exec kill -SIGCONT $slave_pid
  50. assert {[$master wait 1 1000] == 1}
  51. }
  52. }}