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
]
58 set sha1_after
[r debug digest
]
59 if {$sha1 eq
$sha1_after} {
62 set newdump
[csvdump r
]
63 puts "Consistency test failed!"
64 puts "You can inspect the two dumps in /tmp/repldump*.txt"
66 set fd
[open /tmp
/repldump1.txt w
]
69 set fd
[open /tmp
/repldump2.txt w
]
77 test
{Same dataset digest
if saving
/reloading as AOF?
} {
81 set sha1_after
[r debug digest
]
82 if {$sha1 eq
$sha1_after} {
85 set newdump
[csvdump r
]
86 puts "Consistency test failed!"
87 puts "You can inspect the two dumps in /tmp/aofdump*.txt"
89 set fd
[open /tmp
/aofdump1.txt w
]
92 set fd
[open /tmp
/aofdump2.txt w
]
102 test
{EXPIRES
after a reload
(snapshot
+ append only
file)} {
109 set e1
[expr {$ttl > 900 && $ttl <= 1000}]
111 waitForBgrewriteaof r
113 set e2
[expr {$ttl > 900 && $ttl <= 1000}]
117 test
{PIPELINING stresser
(also a regression
for the old epoll bug
)} {
118 set fd2
[socket $::host $::port]
119 fconfigure $fd2 -encoding binary -translation binary
120 puts -nonewline $fd2 "SELECT 9\r\n"
124 for {set i
0} {$i < 100000} {incr i
} {
126 set val
"0000${i}0000"
127 append q
"SET key:$i [string length $val]\r\n$val\r\n"
128 puts -nonewline $fd2 $q
130 append q
"GET key:$i\r\n"
131 puts -nonewline $fd2 $q
135 for {set i
0} {$i < 100000} {incr i
} {
138 set count
[string range
$count 1 end
]
139 set val
[read $fd2 $count]
146 test
{MUTLI
/ EXEC basics
} {
152 set v1
[r
lrange mylist
0 -1]
156 } {QUEUED QUEUED
{{a b c
} PONG
}}
164 set v1
[r del mylist
]
166 set v3
[r
lrange mylist
0 -1]
168 } {QUEUED OK
{a b c
}}
170 test
{Nested MULTI are not allowed
} {
173 catch {[r multi
]} err
178 test
{WATCH inside MULTI is not allowed
} {
181 catch {[r watch x
]} err
186 test
{APPEND basics
} {
187 list [r
append foo bar
] [r get foo
] \
188 [r
append foo
100] [r get foo
]
191 test
{APPEND basics
, integer encoded values
} {
196 lappend res
[r get foo
]
199 lappend res
[r get foo
]
202 test
{APPEND fuzzing
} {
204 foreach type
{binary alpha compr
} {
207 for {set i
0} {$i < 1000} {incr i
} {
208 set bin
[randstring
0 10 $type]
212 if {$buf != [r get x
]} {
213 set err
"Expected '$buf' found '[r get x]'"
220 test
{SUBSTR basics
} {
222 r
set foo
"Hello World"
223 lappend res
[r substr foo
0 3]
224 lappend res
[r substr foo
0 -1]
225 lappend res
[r substr foo
-4 -1]
226 lappend res
[r substr foo
5 3]
227 lappend res
[r substr foo
5 5000]
228 lappend res
[r substr foo
-5000 10000]
230 } {Hell
{Hello World
} orld
{} { World
} {Hello World
}}
232 test
{SUBSTR against integer encoded values
} {
237 test
{SUBSTR fuzzing
} {
239 for {set i
0} {$i < 1000} {incr i
} {
240 set bin
[randstring
0 1024 binary]
241 set _start
[set start
[randomInt
1500]]
242 set _end
[set end
[randomInt
1500]]
243 if {$_start < 0} {set _start
"end-[abs($_start)-1]"}
244 if {$_end < 0} {set _end
"end-[abs($_end)-1]"}
245 set s1
[string range
$bin $_start $_end]
247 set s2
[r substr bin
$start $end]
249 set err
"String mismatch"
256 # Leave the user with a clean DB before to exit
261 lappend aux
[r dbsize
]
264 lappend aux
[r dbsize
]
267 test
{Perform a final SAVE to leave a clean DB on disk
} {