From 0f15e025e63a33a3e28b08a83264c56f0550074b Mon Sep 17 00:00:00 2001 From: guybe7 Date: Mon, 27 Dec 2021 11:31:24 +0100 Subject: [PATCH] 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. --- tests/unit/moduleapi/propagate.tcl | 9 +++++---- 1 file 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" }