]>
Commit | Line | Data |
---|---|---|
08f55b78 | 1 | start_server {tags {"other"}} { |
98578b57 PN |
2 | test {SAVE - make sure there are all the types as values} { |
3 | # Wait for a background saving in progress to terminate | |
4 | waitForBgsave r | |
5 | r lpush mysavelist hello | |
6 | r lpush mysavelist world | |
7 | r set myemptykey {} | |
8 | r set mynormalkey {blablablba} | |
9 | r zadd mytestzset 10 a | |
10 | r zadd mytestzset 20 b | |
11 | r zadd mytestzset 30 c | |
12 | r save | |
13 | } {OK} | |
14 | ||
6b6f101c PN |
15 | tags {"slow"} { |
16 | foreach fuzztype {binary alpha compr} { | |
17 | test "FUZZ stresser with data model $fuzztype" { | |
18 | set err 0 | |
19 | for {set i 0} {$i < 10000} {incr i} { | |
20 | set fuzz [randstring 0 512 $fuzztype] | |
21 | r set foo $fuzz | |
22 | set got [r get foo] | |
23 | if {$got ne $fuzz} { | |
24 | set err [list $fuzz $got] | |
25 | break | |
26 | } | |
98578b57 | 27 | } |
6b6f101c PN |
28 | set _ $err |
29 | } {0} | |
30 | } | |
98578b57 PN |
31 | } |
32 | ||
33 | test {BGSAVE} { | |
34 | waitForBgsave r | |
35 | r flushdb | |
36 | r save | |
37 | r set x 10 | |
38 | r bgsave | |
39 | waitForBgsave r | |
40 | r debug reload | |
41 | r get x | |
42 | } {10} | |
43 | ||
44 | test {SELECT an out of range DB} { | |
45 | catch {r select 1000000} err | |
46 | set _ $err | |
47 | } {*invalid*} | |
48 | ||
69bfffb4 | 49 | tags {consistency nodiskstore} { |
dd3f505f | 50 | if {![catch {package require sha1}]} { |
51 | test {Check consistency of different data types after a reload} { | |
52 | r flushdb | |
53 | createComplexDataset r 10000 | |
54 | set dump [csvdump r] | |
55 | set sha1 [r debug digest] | |
56 | r debug reload | |
dd3f505f | 57 | set sha1_after [r debug digest] |
58 | if {$sha1 eq $sha1_after} { | |
59 | set _ 1 | |
60 | } else { | |
61 | set newdump [csvdump r] | |
62 | puts "Consistency test failed!" | |
63 | puts "You can inspect the two dumps in /tmp/repldump*.txt" | |
98578b57 | 64 | |
dd3f505f | 65 | set fd [open /tmp/repldump1.txt w] |
66 | puts $fd $dump | |
67 | close $fd | |
68 | set fd [open /tmp/repldump2.txt w] | |
69 | puts $fd $newdump | |
70 | close $fd | |
71 | ||
72 | set _ 0 | |
73 | } | |
74 | } {1} | |
75 | ||
76 | test {Same dataset digest if saving/reloading as AOF?} { | |
77 | r bgrewriteaof | |
78 | waitForBgrewriteaof r | |
79 | r debug loadaof | |
80 | set sha1_after [r debug digest] | |
81 | if {$sha1 eq $sha1_after} { | |
82 | set _ 1 | |
83 | } else { | |
84 | set newdump [csvdump r] | |
85 | puts "Consistency test failed!" | |
86 | puts "You can inspect the two dumps in /tmp/aofdump*.txt" | |
87 | ||
88 | set fd [open /tmp/aofdump1.txt w] | |
89 | puts $fd $dump | |
90 | close $fd | |
91 | set fd [open /tmp/aofdump2.txt w] | |
92 | puts $fd $newdump | |
93 | close $fd | |
94 | ||
95 | set _ 0 | |
96 | } | |
97 | } {1} | |
98 | } | |
98578b57 PN |
99 | } |
100 | ||
101 | test {EXPIRES after a reload (snapshot + append only file)} { | |
102 | r flushdb | |
103 | r set x 10 | |
104 | r expire x 1000 | |
69bfffb4 | 105 | if {$::diskstore} { |
106 | r debug flushcache | |
107 | } else { | |
108 | r save | |
109 | r debug reload | |
110 | } | |
98578b57 PN |
111 | set ttl [r ttl x] |
112 | set e1 [expr {$ttl > 900 && $ttl <= 1000}] | |
69bfffb4 | 113 | if {!$::diskstore} { |
114 | r bgrewriteaof | |
115 | waitForBgrewriteaof r | |
116 | r debug loadaof | |
117 | } | |
98578b57 PN |
118 | set ttl [r ttl x] |
119 | set e2 [expr {$ttl > 900 && $ttl <= 1000}] | |
120 | list $e1 $e2 | |
121 | } {1 1} | |
122 | ||
123 | test {PIPELINING stresser (also a regression for the old epoll bug)} { | |
124 | set fd2 [socket $::host $::port] | |
125 | fconfigure $fd2 -encoding binary -translation binary | |
126 | puts -nonewline $fd2 "SELECT 9\r\n" | |
127 | flush $fd2 | |
128 | gets $fd2 | |
129 | ||
130 | for {set i 0} {$i < 100000} {incr i} { | |
131 | set q {} | |
132 | set val "0000${i}0000" | |
dc11daf3 | 133 | append q "SET key:$i $val\r\n" |
98578b57 PN |
134 | puts -nonewline $fd2 $q |
135 | set q {} | |
136 | append q "GET key:$i\r\n" | |
137 | puts -nonewline $fd2 $q | |
138 | } | |
139 | flush $fd2 | |
140 | ||
141 | for {set i 0} {$i < 100000} {incr i} { | |
142 | gets $fd2 line | |
143 | gets $fd2 count | |
144 | set count [string range $count 1 end] | |
145 | set val [read $fd2 $count] | |
146 | read $fd2 2 | |
147 | } | |
148 | close $fd2 | |
149 | set _ 1 | |
150 | } {1} | |
151 | ||
152 | test {MUTLI / EXEC basics} { | |
153 | r del mylist | |
154 | r rpush mylist a | |
155 | r rpush mylist b | |
156 | r rpush mylist c | |
157 | r multi | |
158 | set v1 [r lrange mylist 0 -1] | |
159 | set v2 [r ping] | |
160 | set v3 [r exec] | |
161 | list $v1 $v2 $v3 | |
162 | } {QUEUED QUEUED {{a b c} PONG}} | |
163 | ||
164 | test {DISCARD} { | |
165 | r del mylist | |
166 | r rpush mylist a | |
167 | r rpush mylist b | |
168 | r rpush mylist c | |
169 | r multi | |
170 | set v1 [r del mylist] | |
171 | set v2 [r discard] | |
172 | set v3 [r lrange mylist 0 -1] | |
173 | list $v1 $v2 $v3 | |
174 | } {QUEUED OK {a b c}} | |
175 | ||
4ea93ad3 | 176 | test {Nested MULTI are not allowed} { |
177 | set err {} | |
178 | r multi | |
179 | catch {[r multi]} err | |
180 | r exec | |
181 | set _ $err | |
182 | } {*ERR MULTI*} | |
183 | ||
184 | test {WATCH inside MULTI is not allowed} { | |
185 | set err {} | |
186 | r multi | |
187 | catch {[r watch x]} err | |
188 | r exec | |
189 | set _ $err | |
190 | } {*ERR WATCH*} | |
191 | ||
98578b57 PN |
192 | test {APPEND basics} { |
193 | list [r append foo bar] [r get foo] \ | |
194 | [r append foo 100] [r get foo] | |
195 | } {3 bar 6 bar100} | |
196 | ||
197 | test {APPEND basics, integer encoded values} { | |
198 | set res {} | |
199 | r del foo | |
200 | r append foo 1 | |
201 | r append foo 2 | |
202 | lappend res [r get foo] | |
203 | r set foo 1 | |
204 | r append foo 2 | |
205 | lappend res [r get foo] | |
206 | } {12 12} | |
207 | ||
208 | test {APPEND fuzzing} { | |
209 | set err {} | |
210 | foreach type {binary alpha compr} { | |
211 | set buf {} | |
212 | r del x | |
213 | for {set i 0} {$i < 1000} {incr i} { | |
214 | set bin [randstring 0 10 $type] | |
215 | append buf $bin | |
216 | r append x $bin | |
217 | } | |
218 | if {$buf != [r get x]} { | |
219 | set err "Expected '$buf' found '[r get x]'" | |
220 | break | |
221 | } | |
222 | } | |
223 | set _ $err | |
224 | } {} | |
225 | ||
98578b57 PN |
226 | # Leave the user with a clean DB before to exit |
227 | test {FLUSHDB} { | |
228 | set aux {} | |
229 | r select 9 | |
230 | r flushdb | |
231 | lappend aux [r dbsize] | |
232 | r select 10 | |
233 | r flushdb | |
234 | lappend aux [r dbsize] | |
235 | } {0 0} | |
236 | ||
237 | test {Perform a final SAVE to leave a clean DB on disk} { | |
238 | r save | |
239 | } {OK} | |
240 | } |