1 proc randstring
{min max
{type
binary}} {
2 set len
[expr {$min+int
(rand
()*($max-$min+1))}]
4 if {$type eq
{binary}} {
7 } elseif
{$type eq
{alpha
}} {
10 } elseif
{$type eq
{compr
}} {
15 append output
[format "%c" [expr {$minval+int
(rand
()*($maxval-$minval+1))}]]
21 # Useful for some test
22 proc zlistAlikeSort
{a b
} {
23 if {[lindex $a 0] > [lindex $b 0]} {return 1}
24 if {[lindex $a 0] < [lindex $b 0]} {return -1}
25 string compare
[lindex $a 1] [lindex $b 1]
28 # Return value for INFO property
29 proc status
{r property
} {
30 if {[regexp "\r\n$property:(.*?)\r\n" [$r info] _ value
]} {
35 proc waitForBgsave r
{
37 if {[status r bgsave_in_progress
] eq
1} {
38 puts -nonewline "\nWaiting for background save to finish... "
47 proc waitForBgrewriteaof r
{
49 if {[status r bgrewriteaof_in_progress
] eq
1} {
50 puts -nonewline "\nWaiting for background AOF rewrite to finish... "
59 proc wait_for_sync r
{
61 if {[status r master_link_status
] eq
"down"} {
69 proc randomInt
{max
} {
70 expr {int
(rand
()*$max)}
74 set path
[expr {int
(rand
()*[llength $args])}]
75 uplevel 1 [lindex $args $path]
80 # Small enough to likely collide
83 # 32 bit compressible signed/unsigned
84 randpath
{randomInt
2000000000} {randomInt
4000000000}
87 randpath
{randomInt
1000000000000}
90 randpath
{randstring
0 256 alpha
} \
91 {randstring
0 256 compr
} \
92 {randstring
0 256 binary}
98 # Small enough to likely collide
101 # 32 bit compressible signed/unsigned
102 randpath
{randomInt
2000000000} {randomInt
4000000000}
105 randpath
{randomInt
1000000000000}
108 randpath
{randstring
1 256 alpha
} \
109 {randstring
1 256 compr
}
113 proc createComplexDataset
{r ops
} {
114 for {set j
0} {$j < $ops} {incr j
} {
119 set d
[expr {rand
()}]
121 set d
[expr {rand
()}]
123 set d
[expr {rand
()}]
125 set d
[expr {rand
()}]
127 set d
[expr {rand
()}]
129 randpath
{set d
+inf
} {set d
-inf}
153 randpath
{$r lpush
$k $v} \
160 randpath
{$r sadd
$k $v} \
164 randpath
{$r zadd
$k $d $v} \
168 randpath
{$r hset
$k $f $v} \