From 75398fbcae19a52ea21c518f5f0fd1e6668edcd3 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 29 Apr 2009 19:49:19 +0200 Subject: [PATCH] fuzz stresser implemented in redis-test --- Changelog | 6 ++++++ test-redis.tcl | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Changelog b/Changelog index ee11a10a..8014317c 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +2009-04-29 fixed for HT resize check 32bits overflow +2009-04-29 Check for fork() failure in background saving +2009-04-29 fix for the LZF off-by-one bug added +2009-04-28 print bytes used at exit on SHUTDOWN +2009-04-28 SMOVE test added +2009-04-28 SMOVE command implemented 2009-04-28 less CPU usage in command parsing, case insensitive config directives 2009-04-28 GETSET command doc added 2009-04-28 GETSET tests diff --git a/test-redis.tcl b/test-redis.tcl index 449e1d87..6eb1468c 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -18,6 +18,26 @@ proc test {name code okpattern} { } } +proc randstring {min max {type binary}} { + set len [expr {$min+int(rand()*($max-$min+1))}] + set output {} + if {$type eq {binary}} { + set minval 0 + set maxval 255 + } elseif {$type eq {alpha}} { + set minval 48 + set maxval 122 + } elseif {$type eq {compr}} { + set minval 48 + set maxval 52 + } + while {$len} { + append output [format "%c" [expr {$minval+int(rand()*($maxval-$minval+1))}]] + incr len -1 + } + return $output +} + proc main {server port} { set r [redis $server $port] set err "" @@ -690,6 +710,22 @@ proc main {server port} { format $err } {ERR*} + foreach fuzztype {binary alpha compr} { + test "FUZZ stresser with data model $fuzztype" { + set err 0 + for {set i 0} {$i < 1000} {incr i} { + set fuzz [randstring 0 512 $fuzztype] + $r set foo $fuzz + set got [$r get foo] + if {$got ne $fuzz} { + incr err + break + } + } + format $err + } {0} + } + # Leave the user with a clean DB before to exit test {FLUSHALL} { $r flushall -- 2.45.2