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}]
145 assert
{$ttl > 900 && $ttl <= 1000}
147 assert
{$ttl > 1900 && $ttl <= 2000}
149 assert
{$ttl > 2900 && $ttl <= 3000}
151 assert
{$ttl > 900 && $ttl <= 1000}
153 assert
{$ttl > 1900 && $ttl <= 2000}
155 assert
{$ttl > 2900 && $ttl <= 3000}
156 r config
set appendonly no
160 test
{PIPELINING stresser
(also a regression
for the old epoll bug
)} {
161 set fd2
[socket $::host $::port]
162 fconfigure $fd2 -encoding binary -translation binary
163 puts -nonewline $fd2 "SELECT 9\r\n"
167 for {set i
0} {$i < 100000} {incr i
} {
169 set val
"0000${i}0000"
170 append q
"SET key:$i $val\r\n"
171 puts -nonewline $fd2 $q
173 append q
"GET key:$i\r\n"
174 puts -nonewline $fd2 $q
178 for {set i
0} {$i < 100000} {incr i
} {
181 set count
[string range
$count 1 end
]
182 set val
[read $fd2 $count]
190 test
{MUTLI
/ EXEC basics
} {
196 set v1
[r
lrange mylist
0 -1]
200 } {QUEUED QUEUED
{{a b c
} PONG
}}
208 set v1
[r del mylist
]
210 set v3
[r
lrange mylist
0 -1]
212 } {QUEUED OK
{a b c
}}
214 test
{Nested MULTI are not allowed
} {
217 catch {[r multi
]} err
222 test
{MULTI where commands alter argc
/argv
} {
226 list [r
exec] [r exists myset
]
229 test
{WATCH inside MULTI is not allowed
} {
232 catch {[r watch x
]} err
237 test
{APPEND basics
} {
238 list [r
append foo bar
] [r get foo
] \
239 [r
append foo
100] [r get foo
]
242 test
{APPEND basics
, integer encoded values
} {
247 lappend res
[r get foo
]
250 lappend res
[r get foo
]
253 test
{APPEND fuzzing
} {
255 foreach type
{binary alpha compr
} {
258 for {set i
0} {$i < 1000} {incr i
} {
259 set bin
[randstring
0 10 $type]
263 if {$buf != [r get x
]} {
264 set err
"Expected '$buf' found '[r get x]'"
271 # Leave the user with a clean DB before to exit
276 lappend aux
[r dbsize
]
279 lappend aux
[r dbsize
]
282 test
{Perform a final SAVE to leave a clean DB on disk
} {