summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2018-08-27 13:19:31 +0200
committerGitHub <noreply@github.com>2018-08-27 13:19:31 +0200
commit5b4bec9d336655889641b134791dfdd2adc864cf (patch)
tree52a4c28f3c639dab58be017fe45cce7662d076d9
parent5941022b524bd8b7017af3811083ed42a85de000 (diff)
parentc8452ab0059877ac4a055e74e604d00244b06053 (diff)
downloadredis-5b4bec9d336655889641b134791dfdd2adc864cf.tar.gz
Merge pull request #5265 from oranagra/stabilize_tests
Fix unstable tests on slow machines.
-rw-r--r--tests/unit/dump.tcl4
-rw-r--r--tests/unit/maxmemory.tcl34
-rw-r--r--tests/unit/memefficiency.tcl2
3 files changed, 23 insertions, 17 deletions
diff --git a/tests/unit/dump.tcl b/tests/unit/dump.tcl
index 91a4df09e..fa4f53b3b 100644
--- a/tests/unit/dump.tcl
+++ b/tests/unit/dump.tcl
@@ -33,7 +33,7 @@ start_server {tags {"dump"}} {
set now [clock milliseconds]
r restore foo [expr $now+3000] $encoded absttl
set ttl [r pttl foo]
- assert {$ttl >= 2998 && $ttl <= 3000}
+ assert {$ttl >= 2990 && $ttl <= 3000}
r get foo
} {bar}
@@ -44,7 +44,7 @@ start_server {tags {"dump"}} {
r config set maxmemory-policy allkeys-lru
r restore foo 0 $encoded idletime 1000
set idle [r object idletime foo]
- assert {$idle >= 1000 && $idle <= 1002}
+ assert {$idle >= 1000 && $idle <= 1010}
r get foo
} {bar}
diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl
index 7629fe05e..f6d596ca2 100644
--- a/tests/unit/maxmemory.tcl
+++ b/tests/unit/maxmemory.tcl
@@ -143,9 +143,11 @@ start_server {tags {"maxmemory"}} {
}
}
-proc test_slave_buffers {cmd_count payload_len limit_memory pipeline} {
+proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} {
start_server {tags {"maxmemory"}} {
start_server {} {
+ set slave_pid [s process_id]
+ test "$test_name" {
set slave [srv 0 client]
set slave_host [srv 0 host]
set slave_port [srv 0 port]
@@ -158,8 +160,10 @@ proc test_slave_buffers {cmd_count payload_len limit_memory pipeline} {
$master setrange "key:$j" 100000 asdf
}
+ # make sure master doesn't disconnect slave because of timeout
+ $master config set repl-timeout 300 ;# 5 minutes
$master config set maxmemory-policy allkeys-random
- $master config set client-output-buffer-limit "slave 100000000 100000000 60"
+ $master config set client-output-buffer-limit "slave 100000000 100000000 300"
$master config set repl-backlog-size [expr {10*1024}]
$slave slaveof $master_host $master_port
@@ -182,9 +186,9 @@ proc test_slave_buffers {cmd_count payload_len limit_memory pipeline} {
# put the slave to sleep
set rd_slave [redis_deferring_client]
- $rd_slave debug sleep 300
+ exec kill -SIGSTOP $slave_pid
- # send some 10mb woth of commands that don't increase the memory usage
+ # send some 10mb worth of commands that don't increase the memory usage
if {$pipeline == 1} {
set rd_master [redis_deferring_client -1]
for {set k 0} {$k < $cmd_count} {incr k} {
@@ -218,19 +222,21 @@ proc test_slave_buffers {cmd_count payload_len limit_memory pipeline} {
set delta_no_repl [expr {$killed_used_no_repl - $used_no_repl}]
assert {$killed_slave_buf == 0}
assert {$delta_no_repl > -50*1024 && $delta_no_repl < 50*1024} ;# 1 byte unaccounted for, with 1M commands will consume some 1MB
+
+ }
+ # unfreeze slave process (after the 'test' succeeded or failed, but before we attempt to terminate the server
+ exec kill -SIGCONT $slave_pid
}
}
}
-test {slave buffer are counted correctly} {
- # we wanna use many small commands, and we don't wanna wait long
- # so we need to use a pipeline (redis_deferring_client)
- # that may cause query buffer to fill and induce eviction, so we disable it
- test_slave_buffers 1000000 10 0 1
-}
+# test that slave buffer are counted correctly
+# we wanna use many small commands, and we don't wanna wait long
+# so we need to use a pipeline (redis_deferring_client)
+# that may cause query buffer to fill and induce eviction, so we disable it
+test_slave_buffers {slave buffer are counted correctly} 1000000 10 0 1
-test {slave buffer don't induce eviction} {
- # test again with fewer (and bigger) commands without pipeline, but with eviction
- test_slave_buffers 100000 100 1 0
-}
+# test that slave buffer don't induce eviction
+# test again with fewer (and bigger) commands without pipeline, but with eviction
+test_slave_buffers "slave buffer don't induce eviction" 100000 100 1 0
diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl
index ec71a36b1..8972d577a 100644
--- a/tests/unit/memefficiency.tcl
+++ b/tests/unit/memefficiency.tcl
@@ -201,7 +201,7 @@ start_server {tags {"defrag"}} {
assert {$frag < 1.1}
# due to high fragmentation, 10hz, and active-defrag-cycle-max set to 75,
# we expect max latency to be not much higher than 75ms
- assert {$max_latency <= 80}
+ assert {$max_latency <= 120}
}
# verify the data isn't corrupted or changed
set newdigest [r debug digest]