block-repl.tcl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Test replication of blocking lists and zset operations.
  2. # Unlike stream operations such operations are "pop" style, so they consume
  3. # the list or sorted set, and must be replicated correctly.
  4. proc start_bg_block_op {host port db ops tls} {
  5. set tclsh [info nameofexecutable]
  6. exec $tclsh tests/helpers/bg_block_op.tcl $host $port $db $ops $tls &
  7. }
  8. proc stop_bg_block_op {handle} {
  9. catch {exec /bin/kill -9 $handle}
  10. }
  11. start_server {tags {"repl" "external:skip"}} {
  12. start_server {} {
  13. set master [srv -1 client]
  14. set master_host [srv -1 host]
  15. set master_port [srv -1 port]
  16. set slave [srv 0 client]
  17. set load_handle0 [start_bg_block_op $master_host $master_port 9 100000 $::tls]
  18. set load_handle1 [start_bg_block_op $master_host $master_port 9 100000 $::tls]
  19. set load_handle2 [start_bg_block_op $master_host $master_port 9 100000 $::tls]
  20. test {First server should have role slave after SLAVEOF} {
  21. $slave slaveof $master_host $master_port
  22. after 1000
  23. s 0 role
  24. } {slave}
  25. test {Test replication with blocking lists and sorted sets operations} {
  26. after 25000
  27. stop_bg_block_op $load_handle0
  28. stop_bg_block_op $load_handle1
  29. stop_bg_block_op $load_handle2
  30. wait_for_condition 100 100 {
  31. [$master debug digest] == [$slave debug digest]
  32. } else {
  33. set csv1 [csvdump r]
  34. set csv2 [csvdump {r -1}]
  35. set fd [open /tmp/repldump1.txt w]
  36. puts -nonewline $fd $csv1
  37. close $fd
  38. set fd [open /tmp/repldump2.txt w]
  39. puts -nonewline $fd $csv2
  40. close $fd
  41. fail "Master - Replica inconsistency, Run diff -u against /tmp/repldump*.txt for more info"
  42. }
  43. }
  44. }
  45. }