]> git.saurik.com Git - redis.git/blame - tests/unit/aofrw.tcl
A test modified to pass with the new AOF start/stop semantics.
[redis.git] / tests / unit / aofrw.tcl
CommitLineData
570bbcf8 1start_server {tags {"aofrw"}} {
2 foreach d {string int} {
3 foreach e {ziplist linkedlist} {
4 test "AOF rewrite of list with $e encoding, $d data" {
5 r flushall
6 if {$e eq {ziplist}} {set len 10} else {set len 1000}
7 for {set j 0} {$j < $len} {incr j} {
8 if {$d eq {string}} {
9 set data [randstring 0 16 alpha]
10 } else {
11 set data [randomInt 4000000000]
12 }
13 r lpush key $data
14 }
15 assert_equal [r object encoding key] $e
16 set d1 [r debug digest]
17 r bgrewriteaof
18 waitForBgrewriteaof r
19 r debug loadaof
20 set d2 [r debug digest]
21 if {$d1 ne $d2} {
22 error "assertion:$d1 is not equal to $d2"
23 }
24 }
25 }
26 }
27
28 foreach d {string int} {
29 foreach e {intset hashtable} {
30 test "AOF rewrite of set with $e encoding, $d data" {
31 r flushall
32 if {$e eq {intset}} {set len 10} else {set len 1000}
33 for {set j 0} {$j < $len} {incr j} {
34 if {$d eq {string}} {
35 set data [randstring 0 16 alpha]
36 } else {
37 set data [randomInt 4000000000]
38 }
39 r sadd key $data
40 }
41 if {$d ne {string}} {
42 assert_equal [r object encoding key] $e
43 }
44 set d1 [r debug digest]
45 r bgrewriteaof
46 waitForBgrewriteaof r
47 r debug loadaof
48 set d2 [r debug digest]
49 if {$d1 ne $d2} {
50 error "assertion:$d1 is not equal to $d2"
51 }
52 }
53 }
54 }
55
56 foreach d {string int} {
57 foreach e {zipmap hashtable} {
58 test "AOF rewrite of hash with $e encoding, $d data" {
59 r flushall
60 if {$e eq {zipmap}} {set len 10} else {set len 1000}
61 for {set j 0} {$j < $len} {incr j} {
62 if {$d eq {string}} {
63 set data [randstring 0 16 alpha]
64 } else {
65 set data [randomInt 4000000000]
66 }
67 r hset key $data $data
68 }
69 assert_equal [r object encoding key] $e
70 set d1 [r debug digest]
71 r bgrewriteaof
72 waitForBgrewriteaof r
73 r debug loadaof
74 set d2 [r debug digest]
75 if {$d1 ne $d2} {
76 error "assertion:$d1 is not equal to $d2"
77 }
78 }
79 }
80 }
81
82 foreach d {string int} {
83 foreach e {ziplist skiplist} {
84 test "AOF rewrite of zset with $e encoding, $d data" {
85 r flushall
86 if {$e eq {ziplist}} {set len 10} else {set len 1000}
87 for {set j 0} {$j < $len} {incr j} {
88 if {$d eq {string}} {
89 set data [randstring 0 16 alpha]
90 } else {
91 set data [randomInt 4000000000]
92 }
93 r zadd key [expr rand()] $data
94 }
95 assert_equal [r object encoding key] $e
96 set d1 [r debug digest]
97 r bgrewriteaof
98 waitForBgrewriteaof r
99 r debug loadaof
100 set d2 [r debug digest]
101 if {$d1 ne $d2} {
102 error "assertion:$d1 is not equal to $d2"
103 }
104 }
105 }
106 }
107}