summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorguybe7 <guy.benoish@redislabs.com>2021-12-27 11:31:24 +0100
committerGitHub <noreply@github.com>2021-12-27 12:31:24 +0200
commit0f15e025e63a33a3e28b08a83264c56f0550074b (patch)
tree6312d54093b879c286a95dd7b17624c1f51513a4 /tests/unit
parente84ccc3f566f78344b098c3eef6e371653bc311b (diff)
downloadredis-0f15e025e63a33a3e28b08a83264c56f0550074b.tar.gz
Fix race in propagation test (#10012)
There's a race between testing DBSIZE and the thread starting. If the thread hadn't started by the time we checked DBISZE, no keys will have been evicted. The correct way is to check the evicted_keys stat.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/moduleapi/propagate.tcl9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/unit/moduleapi/propagate.tcl b/tests/unit/moduleapi/propagate.tcl
index 95dc527f5..6d9b5bdde 100644
--- a/tests/unit/moduleapi/propagate.tcl
+++ b/tests/unit/moduleapi/propagate.tcl
@@ -157,11 +157,12 @@ tags "modules" {
# Please note we use volatile eviction to prevent the loop described in the test above.
# "notifications" is not volatile so it always remains
+ $master config resetstat
$master config set maxmemory-policy volatile-ttl
$master config set maxmemory 1
wait_for_condition 500 10 {
- [$replica dbsize] eq 1
+ [s evicted_keys] eq 3
} else {
fail "Not all keys have been evicted"
}
@@ -207,14 +208,14 @@ tags "modules" {
test {module propagation with timer and CONFIG SET maxmemory} {
set repl [attach_to_replication_stream]
+ $master config resetstat
$master config set maxmemory-policy volatile-random
$master propagate-test.timer-maxmemory
- # The replica will have two keys: "notifications" and "timer-maxmemory-middle"
- # which are not volatile
+ # Wait until the volatile keys are evicted
wait_for_condition 500 10 {
- [$replica dbsize] eq 2
+ [s evicted_keys] eq 2
} else {
fail "Not all keys have been evicted"
}