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
49 if {![catch {package require sha1
}]} {
50 test
{Check consistency of different data types
after a reload
} {
52 createComplexDataset r
10000
53 set sha1
[r debug digest
]
55 set sha1_after
[r debug digest
]
56 expr {$sha1 eq
$sha1_after}
59 test
{Same dataset digest
if saving
/reloading as AOF?
} {
63 set sha1_after
[r debug digest
]
64 expr {$sha1 eq
$sha1_after}
68 test
{EXPIRES
after a reload
(snapshot
+ append only
file)} {
75 set e1
[expr {$ttl > 900 && $ttl <= 1000}]
79 set e2
[expr {$ttl > 900 && $ttl <= 1000}]
83 test
{PIPELINING stresser
(also a regression
for the old epoll bug
)} {
84 set fd2
[socket $::host $::port]
85 fconfigure $fd2 -encoding binary -translation binary
86 puts -nonewline $fd2 "SELECT 9\r\n"
90 for {set i
0} {$i < 100000} {incr i
} {
92 set val
"0000${i}0000"
93 append q
"SET key:$i [string length $val]\r\n$val\r\n"
94 puts -nonewline $fd2 $q
96 append q
"GET key:$i\r\n"
97 puts -nonewline $fd2 $q
101 for {set i
0} {$i < 100000} {incr i
} {
104 set count
[string range
$count 1 end
]
105 set val
[read $fd2 $count]
112 test
{MUTLI
/ EXEC basics
} {
118 set v1
[r
lrange mylist
0 -1]
122 } {QUEUED QUEUED
{{a b c
} PONG
}}
130 set v1
[r del mylist
]
132 set v3
[r
lrange mylist
0 -1]
134 } {QUEUED OK
{a b c
}}
136 test
{Nested MULTI are not allowed
} {
139 catch {[r multi
]} err
144 test
{WATCH inside MULTI is not allowed
} {
147 catch {[r watch x
]} err
152 test
{APPEND basics
} {
153 list [r
append foo bar
] [r get foo
] \
154 [r
append foo
100] [r get foo
]
157 test
{APPEND basics
, integer encoded values
} {
162 lappend res
[r get foo
]
165 lappend res
[r get foo
]
168 test
{APPEND fuzzing
} {
170 foreach type
{binary alpha compr
} {
173 for {set i
0} {$i < 1000} {incr i
} {
174 set bin
[randstring
0 10 $type]
178 if {$buf != [r get x
]} {
179 set err
"Expected '$buf' found '[r get x]'"
186 test
{SUBSTR basics
} {
188 r
set foo
"Hello World"
189 lappend res
[r substr foo
0 3]
190 lappend res
[r substr foo
0 -1]
191 lappend res
[r substr foo
-4 -1]
192 lappend res
[r substr foo
5 3]
193 lappend res
[r substr foo
5 5000]
194 lappend res
[r substr foo
-5000 10000]
196 } {Hell
{Hello World
} orld
{} { World
} {Hello World
}}
198 test
{SUBSTR against integer encoded values
} {
203 test
{SUBSTR fuzzing
} {
205 for {set i
0} {$i < 1000} {incr i
} {
206 set bin
[randstring
0 1024 binary]
207 set _start
[set start
[randomInt
1500]]
208 set _end
[set end
[randomInt
1500]]
209 if {$_start < 0} {set _start
"end-[abs($_start)-1]"}
210 if {$_end < 0} {set _end
"end-[abs($_end)-1]"}
211 set s1
[string range
$bin $_start $_end]
213 set s2
[r substr bin
$start $end]
215 set err
"String mismatch"
222 # Leave the user with a clean DB before to exit
227 lappend aux
[r dbsize
]
230 lappend aux
[r dbsize
]
233 test
{Perform a final SAVE to leave a clean DB on disk
} {