Skip to content

Commit

Permalink
random tested mode for test-redis.tcl, minor other stuff, version swi…
Browse files Browse the repository at this point in the history
…tched to 0.8
  • Loading branch information
antirez committed Mar 23, 2009
1 parent cf3f0c0 commit 5a6948f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ redis-server
redis-benchmark
doc-tools
mkrelease.sh
release
33 changes: 2 additions & 31 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
BETA 8 TODO
- Protocol changes as discussed in the Redis group
- keys expire
- sunion ssub
- write integers in a special way on disk (and on memory?)
- compact types for disk storing of short strings (no 4 bytes overhead!)
- network layer stresser in test in demo
- maxclients directive
- check 'server.dirty' everywere
- replication tests
- command line client. If the last argument of a bulk command is missing get it from stdin. Example:
$ echo "bar" | redis-client SET foo
$ redis-client SET foo bar
$ redis-client GET foo
bar
$
- Make Redis aware of the memory it is using thanks to getrusage() and report this info with the INFO command.
- INFO command: clients, slave/master, requests/second in the last N seconds, memory usage, uptime, dirty, lastsave

FUTURE

ROLLBACK command:

ROLLBACK UNSET x
SET x 10
EXPIRE x 3600
COMMIT

(multiple rollbacks are allowed)

or alternatively

TRANSACTION SET x 1000
TRANSACTION EXPIRE x 1000
COMMIT

but this sucks since there is no way to check the error message.

- Prevent the client to issue SYNC or MONITOR multiple times
- replication automated tests
2 changes: 1 addition & 1 deletion redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#define REDIS_VERSION "0.07"
#define REDIS_VERSION "0.08"

#include <stdio.h>
#include <stdlib.h>
Expand Down
43 changes: 35 additions & 8 deletions test-redis.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -784,37 +784,37 @@ proc redis_sismember {fd key val} {
}

proc redis_sinter {fd args} {
redis_writenl $fd "sinter [join $args]\r\n"
redis_writenl $fd "sinter [join $args]"
redis_multi_bulk_read $fd
}

proc redis_sinterstore {fd args} {
redis_writenl $fd "sinterstore [join $args]\r\n"
redis_writenl $fd "sinterstore [join $args]"
redis_read_retcode $fd
}

proc redis_smembers {fd key} {
redis_writenl $fd "smembers $key\r\n"
redis_writenl $fd "smembers $key"
redis_multi_bulk_read $fd
}

proc redis_echo {fd str} {
redis_writenl $fd "echo [string length $str]\r\n$str\r\n"
redis_writenl $fd "smembers $key\r\n"
redis_writenl $fd "echo [string length $str]\r\n$str"
redis_writenl $fd "smembers $key"
}

proc redis_save {fd} {
redis_writenl $fd "save\r\n"
redis_writenl $fd "save"
redis_read_retcode $fd
}

proc redis_flushall {fd} {
redis_writenl $fd "flushall\r\n"
redis_writenl $fd "flushall"
redis_read_retcode $fd
}

proc redis_flushdb {fd} {
redis_writenl $fd "flushdb\r\n"
redis_writenl $fd "flushdb"
redis_read_retcode $fd
}

Expand All @@ -823,8 +823,35 @@ proc redis_lrem {fd key count val} {
redis_read_integer $fd
}

proc stress {} {
set fd [socket 127.0.0.1 6379]
fconfigure $fd -translation binary
redis_flushall $fd
while 1 {
set randkey [expr int(rand()*10000)]
set randval [expr int(rand()*10000)]
set randidx0 [expr int(rand()*10)]
set randidx1 [expr int(rand()*10)]
set cmd [expr int(rand()*10)]
if {$cmd == 0} {redis_set $fd $randkey $randval}
if {$cmd == 1} {redis_get $fd $randkey}
if {$cmd == 2} {redis_incr $fd $randkey}
if {$cmd == 3} {redis_lpush $fd $randkey $randval}
if {$cmd == 4} {redis_rpop $fd $randkey}
if {$cmd == 5} {redis_del $fd $randkey}
if {$cmd == 6} {redis_lrange $fd $randkey $randidx0 $randidx1}
if {$cmd == 7} {redis_ltrim $fd $randkey $randidx0 $randidx1}
if {$cmd == 8} {redis_lindex $fd $randkey $randidx0}
if {$cmd == 9} {redis_lset $fd $randkey $randidx0 $randval}
flush stdout
}
close $fd
}

if {[llength $argv] == 0} {
main 127.0.0.1 6379
} elseif {[llength $argv] == 1 && [lindex $argv 0] eq {stress}} {
stress
} else {
main [lindex $argv 0] [lindex $argv 1]
}

0 comments on commit 5a6948f

Please sign in to comment.