From f166bb1d500dcecb14bff13312a4e7d2a76356c7 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 20 May 2010 13:58:58 +0200 Subject: [PATCH] code to enable running tests with the vm enabled --- tests/assets/default.conf | 10 +++------- tests/support/server.tcl | 7 ++++--- tests/test_helper.tcl | 24 ++++++++++++++++++++---- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/tests/assets/default.conf b/tests/assets/default.conf index c6ae1078e..15d70ffbd 100644 --- a/tests/assets/default.conf +++ b/tests/assets/default.conf @@ -220,7 +220,7 @@ vm-enabled no # *** WARNING *** if you are using a shared hosting the default of putting # the swap file under /tmp is not secure. Create a dir with access granted # only to Redis user and configure Redis to create the swap file there. -vm-swap-file /tmp/redis.swap +vm-swap-file redis.swap # vm-max-memory configures the VM to use at max the specified amount of # RAM. Everything that deos not fit will be swapped on disk *if* possible, that @@ -249,12 +249,8 @@ vm-page-size 32 # # The total swap size is vm-page-size * vm-pages # -# With the default of 32-bytes memory pages and 134217728 pages Redis will -# use a 4 GB swap file, that will use 16 MB of RAM for the page table. -# -# It's better to use the smallest acceptable value for your application, -# but the default is large in order to work in most conditions. -vm-pages 134217728 +# 32M swap should be enough for testing. +vm-pages 1048576 # Max number of VM I/O threads running at the same time. # This threads are used to read/write data from/to swap file, since they diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 8664b9a43..18728f912 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -26,7 +26,7 @@ proc kill_server config { if {[incr wait 10] % 1000 == 0} { puts "Waiting for process $pid to exit..." } - exec kill $pid + catch {exec kill $pid} after 10 } } @@ -40,6 +40,7 @@ proc is_alive config { } } +set ::global_overrides {} proc start_server {filename overrides {code undefined}} { set data [split [exec cat "tests/assets/$filename"] "\n"] set config {} @@ -58,8 +59,8 @@ proc start_server {filename overrides {code undefined}} { # start every server on a different port dict set config port [incr ::port] - # apply overrides from arguments - foreach override $overrides { + # apply overrides from global space and arguments + foreach override [concat $::global_overrides $overrides] { set directive [lrange $override 0 0] set arguments [lrange $override 1 end] dict set config $directive $arguments diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index e5f2ed77c..86286cdbd 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -49,7 +49,13 @@ proc s {args} { status [srv $level "client"] [lindex $args 0] } +proc cleanup {} { + exec rm -rf {*}[glob tests/tmp/redis.conf.*] + exec rm -rf {*}[glob tests/tmp/server.*] +} + proc main {} { + cleanup execute_tests "unit/auth" execute_tests "unit/protocol" execute_tests "unit/basic" @@ -62,15 +68,25 @@ proc main {} { execute_tests "unit/other" execute_tests "integration/replication" execute_tests "integration/aof" + + # run tests with VM enabled + set ::global_overrides [list [list vm-enabled yes]] + execute_tests "unit/protocol" + execute_tests "unit/basic" + execute_tests "unit/type/list" + execute_tests "unit/type/set" + execute_tests "unit/type/zset" + execute_tests "unit/type/hash" + execute_tests "unit/sort" + execute_tests "unit/expire" + execute_tests "unit/other" puts "\n[expr $::passed+$::failed] tests, $::passed passed, $::failed failed" if {$::failed > 0} { puts "\n*** WARNING!!! $::failed FAILED TESTS ***\n" } - - # clean up tmp - exec rm -rf {*}[glob tests/tmp/redis.conf.*] - exec rm -rf {*}[glob tests/tmp/server.*] + + cleanup } main