Skip to content

Commit

Permalink
If the computer running the Redis test is slow, we revert to --client…
Browse files Browse the repository at this point in the history
…s 1 to avoid false positives.
  • Loading branch information
antirez committed May 11, 2012
1 parent ea66be6 commit 2773796
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_helper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,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"
Expand All @@ -413,6 +425,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
Expand Down

0 comments on commit 2773796

Please sign in to comment.