X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/38b957d8ba22fa8760e88fd5500c9bdc2d6fd3da..37d978d9b46c0572d0aa0a3ae72fa684c0eccd0a:/tests/test_helper.tcl diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 4c30b3c6..38fb1f53 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -23,16 +23,25 @@ set ::all_tests { unit/sort unit/expire unit/other - unit/cas + unit/multi unit/quit + unit/aofrw integration/replication integration/replication-2 integration/replication-3 + integration/replication-4 integration/aof + integration/rdb + integration/convert-zipmap-hash-on-load unit/pubsub unit/slowlog unit/scripting unit/maxmemory + unit/introspection + unit/limits + unit/obuf-limits + unit/dump + unit/bitops } # Index to the next test to run in the ::all_tests list. set ::next_test 0 @@ -113,7 +122,7 @@ proc reconnect {args} { } # re-set $srv in the servers list - set ::servers [lreplace $::servers end+$level 1 $srv] + lset ::servers end+$level $srv } proc redis_deferring_client {args} { @@ -153,9 +162,9 @@ proc cleanup {} { proc find_available_port start { for {set j $start} {$j < $start+1024} {incr j} { if {[catch { - set fd [socket 127.0.0.1 $start] + set fd [socket 127.0.0.1 $j] }]} { - return $start + return $j } else { close $fd } @@ -338,6 +347,7 @@ proc print_help_screen {} { "--quiet Don't show individual tests." "--single Just execute the specified unit (see next option)." "--list-tests List all the available test units." + "--clients Number of test clients (16)." "--force-failure Force the execution of a test that always fails." "--help Print this help screen." } "\n"] @@ -383,6 +393,9 @@ for {set j 0} {$j < [llength $argv]} {incr j} { set ::client 1 set ::test_server_port $arg incr j + } elseif {$opt eq {--clients}} { + set ::numclients $arg + incr j } elseif {$opt eq {--help}} { print_help_screen exit 0 @@ -392,6 +405,18 @@ for {set j 0} {$j < [llength $argv]} {incr j} { } } +# With the parallel test running multiple Redis instances at the same time +# we need a fast enough computer, otherwise a lot of tests may generate +# false positives. +# If the computer is too slow we revert the sequetial test without any +# parallelism, that is, clients == 1. +proc is_a_slow_computer {} { + set start [clock milliseconds] + for {set j 0} {$j < 1000000} {incr j} {} + set elapsed [expr [clock milliseconds]-$start] + expr {$elapsed > 200} +} + if {$::client} { if {[catch { test_client_main $::test_server_port } err]} { set estr "Executing test client: $err.\n$::errorInfo" @@ -401,6 +426,11 @@ if {$::client} { exit 1 } } else { + if {[is_a_slow_computer]} { + puts "** SLOW COMPUTER ** Using a single client to avoid false positives." + set ::numclients 1 + } + if {[catch { test_server_main } err]} { if {[string length $err] > 0} { # only display error when not generated by the test suite