1 start_server
{tags
{"other"}} {
2 test
{SAVE
- make sure there are all the types as values
} {
3 # Wait for a background saving in progress to terminate
5 r lpush mysavelist hello
6 r lpush mysavelist world
8 r
set mynormalkey
{blablablba
}
10 r zadd mytestzset
20 b
11 r zadd mytestzset
30 c
16 foreach fuzztype
{binary alpha compr
} {
17 test
"FUZZ stresser with data model $fuzztype" {
19 for {set i
0} {$i < 10000} {incr i
} {
20 set fuzz
[randstring
0 512 $fuzztype]
24 set err
[list $fuzz $got]
44 test
{SELECT an out of range DB
} {
45 catch {r select
1000000} err
50 if {![catch {package require sha1
}]} {
51 test
{Check consistency of different data types
after a reload
} {
53 createComplexDataset r
10000
55 set sha1
[r debug digest
]
57 set sha1_after
[r debug digest
]
58 if {$sha1 eq
$sha1_after} {
61 set newdump
[csvdump r
]
62 puts "Consistency test failed!"
63 puts "You can inspect the two dumps in /tmp/repldump*.txt"
65 set fd
[open /tmp
/repldump1.txt w
]
68 set fd
[open /tmp
/repldump2.txt w
]
76 test
{Same dataset digest
if saving
/reloading as AOF?
} {
80 set sha1_after
[r debug digest
]
81 if {$sha1 eq
$sha1_after} {
84 set newdump
[csvdump r
]
85 puts "Consistency test failed!"
86 puts "You can inspect the two dumps in /tmp/aofdump*.txt"
88 set fd
[open /tmp
/aofdump1.txt w
]
91 set fd
[open /tmp
/aofdump2.txt w
]
101 test
{EXPIRES
after a reload
(snapshot
+ append only
file)} {
108 set e1
[expr {$ttl > 900 && $ttl <= 1000}]
110 waitForBgrewriteaof r
112 set e2
[expr {$ttl > 900 && $ttl <= 1000}]
116 test
{PIPELINING stresser
(also a regression
for the old epoll bug
)} {
117 set fd2
[socket $::host $::port]
118 fconfigure $fd2 -encoding binary -translation binary
119 puts -nonewline $fd2 "SELECT 9\r\n"
123 for {set i
0} {$i < 100000} {incr i
} {
125 set val
"0000${i}0000"
126 append q
"SET key:$i [string length $val]\r\n$val\r\n"
127 puts -nonewline $fd2 $q
129 append q
"GET key:$i\r\n"
130 puts -nonewline $fd2 $q
134 for {set i
0} {$i < 100000} {incr i
} {
137 set count
[string range
$count 1 end
]
138 set val
[read $fd2 $count]
145 test
{MUTLI
/ EXEC basics
} {
151 set v1
[r
lrange mylist
0 -1]
155 } {QUEUED QUEUED
{{a b c
} PONG
}}
163 set v1
[r del mylist
]
165 set v3
[r
lrange mylist
0 -1]
167 } {QUEUED OK
{a b c
}}
169 test
{Nested MULTI are not allowed
} {
172 catch {[r multi
]} err
177 test
{WATCH inside MULTI is not allowed
} {
180 catch {[r watch x
]} err
185 test
{APPEND basics
} {
186 list [r
append foo bar
] [r get foo
] \
187 [r
append foo
100] [r get foo
]
190 test
{APPEND basics
, integer encoded values
} {
195 lappend res
[r get foo
]
198 lappend res
[r get foo
]
201 test
{APPEND fuzzing
} {
203 foreach type
{binary alpha compr
} {
206 for {set i
0} {$i < 1000} {incr i
} {
207 set bin
[randstring
0 10 $type]
211 if {$buf != [r get x
]} {
212 set err
"Expected '$buf' found '[r get x]'"
219 test
{SUBSTR basics
} {
221 r
set foo
"Hello World"
222 lappend res
[r substr foo
0 3]
223 lappend res
[r substr foo
0 -1]
224 lappend res
[r substr foo
-4 -1]
225 lappend res
[r substr foo
5 3]
226 lappend res
[r substr foo
5 5000]
227 lappend res
[r substr foo
-5000 10000]
229 } {Hell
{Hello World
} orld
{} { World
} {Hello World
}}
231 test
{SUBSTR against integer encoded values
} {
236 test
{SUBSTR fuzzing
} {
238 for {set i
0} {$i < 1000} {incr i
} {
239 set bin
[randstring
0 1024 binary]
240 set _start
[set start
[randomInt
1500]]
241 set _end
[set end
[randomInt
1500]]
242 if {$_start < 0} {set _start
"end-[abs($_start)-1]"}
243 if {$_end < 0} {set _end
"end-[abs($_end)-1]"}
244 set s1
[string range
$bin $_start $_end]
246 set s2
[r substr bin
$start $end]
248 set err
"String mismatch"
255 # Leave the user with a clean DB before to exit
260 lappend aux
[r dbsize
]
263 lappend aux
[r dbsize
]
266 test
{Perform a final SAVE to leave a clean DB on disk
} {