1 start_server
{tags
{"other"}} {
2 if {$::force_failure} {
3 # This is used just for test suite development purposes.
9 test
{SAVE
- make sure there are all the types as values
} {
10 # Wait for a background saving in progress to terminate
12 r lpush mysavelist hello
13 r lpush mysavelist world
15 r
set mynormalkey
{blablablba
}
16 r zadd mytestzset
10 a
17 r zadd mytestzset
20 b
18 r zadd mytestzset
30 c
23 if {$::accurate} {set iterations
10000} else {set iterations
1000}
24 foreach fuzztype
{binary alpha compr
} {
25 test
"FUZZ stresser with data model $fuzztype" {
27 for {set i
0} {$i < $iterations} {incr i
} {
28 set fuzz
[randstring
0 512 $fuzztype]
32 set err
[list $fuzz $got]
52 test
{SELECT an out of range DB
} {
53 catch {r select
1000000} err
58 if {![catch {package require sha1
}]} {
59 if {$::accurate} {set numops
10000} else {set numops
1000}
60 test
{Check consistency of different data types
after a reload
} {
62 createComplexDataset r
$numops
64 set sha1
[r debug digest
]
66 set sha1_after
[r debug digest
]
67 if {$sha1 eq
$sha1_after} {
70 set newdump
[csvdump r
]
71 puts "Consistency test failed!"
72 puts "You can inspect the two dumps in /tmp/repldump*.txt"
74 set fd
[open /tmp
/repldump1.txt w
]
77 set fd
[open /tmp
/repldump2.txt w
]
85 test
{Same dataset digest
if saving
/reloading as AOF?
} {
89 set sha1_after
[r debug digest
]
90 if {$sha1 eq
$sha1_after} {
93 set newdump
[csvdump r
]
94 puts "Consistency test failed!"
95 puts "You can inspect the two dumps in /tmp/aofdump*.txt"
97 set fd
[open /tmp
/aofdump1.txt w
]
100 set fd
[open /tmp
/aofdump2.txt w
]
110 test
{EXPIRES
after a reload
(snapshot
+ append only
file rewrite
)} {
117 set e1
[expr {$ttl > 900 && $ttl <= 1000}]
119 waitForBgrewriteaof r
122 set e2
[expr {$ttl > 900 && $ttl <= 1000}]
126 test
{EXPIRES
after AOF reload
(without rewrite
)} {
128 r config
set appendonly yes
131 r setex y
2000 somevalue
133 r expireat z
[expr {[clock seconds
]+3000}]
135 # Milliseconds variants
138 r psetex py
2000000 somevalue
140 r pexpireat pz
[expr {([clock seconds
]+3000)*1000}]
143 waitForBgrewriteaof r
144 # We need to wait two seconds to avoid false positives here, otherwise
145 # the DEBUG LOADAOF command may read a partial file.
146 # Another solution would be to set the fsync policy to no, since this
147 # prevents write() to be delayed by the completion of fsync().
151 assert
{$ttl > 900 && $ttl <= 1000}
153 assert
{$ttl > 1900 && $ttl <= 2000}
155 assert
{$ttl > 2900 && $ttl <= 3000}
157 assert
{$ttl > 900 && $ttl <= 1000}
159 assert
{$ttl > 1900 && $ttl <= 2000}
161 assert
{$ttl > 2900 && $ttl <= 3000}
162 r config
set appendonly no
166 test
{PIPELINING stresser
(also a regression
for the old epoll bug
)} {
167 set fd2
[socket $::host $::port]
168 fconfigure $fd2 -encoding binary -translation binary
169 puts -nonewline $fd2 "SELECT 9\r\n"
173 for {set i
0} {$i < 100000} {incr i
} {
175 set val
"0000${i}0000"
176 append q
"SET key:$i $val\r\n"
177 puts -nonewline $fd2 $q
179 append q
"GET key:$i\r\n"
180 puts -nonewline $fd2 $q
184 for {set i
0} {$i < 100000} {incr i
} {
187 set count
[string range
$count 1 end
]
188 set val
[read $fd2 $count]
196 test
{MUTLI
/ EXEC basics
} {
202 set v1
[r
lrange mylist
0 -1]
206 } {QUEUED QUEUED
{{a b c
} PONG
}}
214 set v1
[r del mylist
]
216 set v3
[r
lrange mylist
0 -1]
218 } {QUEUED OK
{a b c
}}
220 test
{Nested MULTI are not allowed
} {
223 catch {[r multi
]} err
228 test
{MULTI where commands alter argc
/argv
} {
232 list [r
exec] [r exists myset
]
235 test
{WATCH inside MULTI is not allowed
} {
238 catch {[r watch x
]} err
243 test
{APPEND basics
} {
244 list [r
append foo bar
] [r get foo
] \
245 [r
append foo
100] [r get foo
]
248 test
{APPEND basics
, integer encoded values
} {
253 lappend res
[r get foo
]
256 lappend res
[r get foo
]
259 test
{APPEND fuzzing
} {
261 foreach type
{binary alpha compr
} {
264 for {set i
0} {$i < 1000} {incr i
} {
265 set bin
[randstring
0 10 $type]
269 if {$buf != [r get x
]} {
270 set err
"Expected '$buf' found '[r get x]'"
277 # Leave the user with a clean DB before to exit
282 lappend aux
[r dbsize
]
285 lappend aux
[r dbsize
]
288 test
{Perform a final SAVE to leave a clean DB on disk
} {