File: aof-race.tcl

package info (click to toggle)
redis 2%3A2.8.17-1%2Bdeb8u5
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 6,524 kB
  • ctags: 9,607
  • sloc: ansic: 71,922; tcl: 9,383; perl: 3,931; sh: 3,602; makefile: 1,001; ruby: 244
file content (35 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
set defaults { appendonly {yes} appendfilename {appendonly.aof} }
set server_path [tmpdir server.aof]
set aof_path "$server_path/appendonly.aof"

proc start_server_aof {overrides code} {
    upvar defaults defaults srv srv server_path server_path
    set config [concat $defaults $overrides]
    start_server [list overrides $config] $code
}

tags {"aof"} {
    # Specific test for a regression where internal buffers were not properly
    # cleaned after a child responsible for an AOF rewrite exited. This buffer
    # was subsequently appended to the new AOF, resulting in duplicate commands.
    start_server_aof [list dir $server_path] {
        set client [redis [srv host] [srv port]]
        set bench [open "|src/redis-benchmark -q -p [srv port] -c 20 -n 20000 incr foo" "r+"]
        after 100

        # Benchmark should be running by now: start background rewrite
        $client bgrewriteaof

        # Read until benchmark pipe reaches EOF
        while {[string length [read $bench]] > 0} {}

        # Check contents of foo
        assert_equal 20000 [$client get foo]
    }

    # Restart server to replay AOF
    start_server_aof [list dir $server_path] {
        set client [redis [srv host] [srv port]]
        assert_equal 20000 [$client get foo]
    }
}