aof-race.tcl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. set defaults { appendonly {yes} appendfilename {appendonly.aof} aof-use-rdb-preamble {no} }
  2. set server_path [tmpdir server.aof]
  3. set aof_path "$server_path/appendonly.aof"
  4. proc start_server_aof {overrides code} {
  5. upvar defaults defaults srv srv server_path server_path
  6. set config [concat $defaults $overrides]
  7. start_server [list overrides $config] $code
  8. }
  9. tags {"aof"} {
  10. # Specific test for a regression where internal buffers were not properly
  11. # cleaned after a child responsible for an AOF rewrite exited. This buffer
  12. # was subsequently appended to the new AOF, resulting in duplicate commands.
  13. start_server_aof [list dir $server_path] {
  14. set client [redis [srv host] [srv port] 0 $::tls]
  15. set bench [open "|src/redis-benchmark -q -s [srv unixsocket] -c 20 -n 20000 incr foo" "r+"]
  16. after 100
  17. # Benchmark should be running by now: start background rewrite
  18. $client bgrewriteaof
  19. # Read until benchmark pipe reaches EOF
  20. while {[string length [read $bench]] > 0} {}
  21. # Check contents of foo
  22. assert_equal 20000 [$client get foo]
  23. }
  24. # Restart server to replay AOF
  25. start_server_aof [list dir $server_path] {
  26. set client [redis [srv host] [srv port] 0 $::tls]
  27. assert_equal 20000 [$client get foo]
  28. }
  29. }