From 7c9f41b52b3a664c07581c83f9256fbedb798dfe Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Tue, 30 Jan 2024 14:32:38 +0200 Subject: [PATCH] fix dict rehash tests introduced by #12802 broken by #12819 (#13009) tests consistently fail on timeout (sleep that's too short). it now takes more time because in #12819 we iterate on all dicts, not just non-empty ones. it passed the PR's CI because it skips the `slow` tag, which might have been misplaced, but now it is probably required. with the fix, the tests take quite a lot of time: ``` [ok]: Redis can trigger resizing (1860 ms) [ok]: Redis can rewind and trigger smaller slot resizing (744 ms) ``` before #12819: ``` [ok]: Redis can trigger resizing (309 ms) [ok]: Redis can rewind and trigger smaller slot resizing (295 ms) ``` failure: https://github.com/redis/redis/actions/runs/7704158180/job/20995931735 ``` *** [err]: expire scan should skip dictionaries with lot's of empty buckets in tests/unit/expire.tcl scan didn't handle slot skipping logic. *** [err]: Redis can trigger resizing in tests/unit/other.tcl Expected '[Dictionary HT] Hash table 0 stats (main hash table): table size: 128 number of elements: 5 [Expires HT] Hash table 0 stats (main hash table): No stats available for empty dictionaries ' to match '*table size: 8*' (context: type eval line 29 cmd {assert_match "*table size: 8*" [r debug HTSTATS 0]} proc ::test) *** [err]: Redis can rewind and trigger smaller slot resizing in tests/unit/other.tcl Expected '[Dictionary HT] Hash table 0 stats (main hash table): table size: 256 number of elements: 10 [Expires HT] Hash table 0 stats (main hash table): No stats available for empty dictionaries ' to match '*table size: 16*' (context: type eval line 27 cmd {assert_match "*table size: 16*" [r debug HTSTATS 0]} proc ::test) ``` --- tests/unit/other.tcl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/unit/other.tcl b/tests/unit/other.tcl index 18a54d4e8..3fe808f56 100644 --- a/tests/unit/other.tcl +++ b/tests/unit/other.tcl @@ -429,6 +429,7 @@ start_server {tags {"other external:skip"}} { } start_cluster 1 0 {tags {"other external:skip cluster slow"}} { + r config set dynamic-hz no hz 500 test "Redis can trigger resizing" { r flushall # hashslot(foo) is 12182 @@ -456,8 +457,13 @@ start_cluster 1 0 {tags {"other external:skip cluster slow"}} { fail "bgsave did not stop in time." } - after 200;# waiting for serverCron - assert_match "*table size: 8*" [r debug HTSTATS 0] + # waiting for serverCron to resize the tables + wait_for_condition 1000 10 { + [string match {*table size: 8*} [r debug HTSTATS 0]] + } else { + puts [r debug HTSTATS 0] + fail "hash tables weren't resize." + } } {} {needs:debug} test "Redis can rewind and trigger smaller slot resizing" { @@ -485,8 +491,13 @@ start_cluster 1 0 {tags {"other external:skip cluster slow"}} { fail "bgsave did not stop in time." } - after 200;# waiting for serverCron - assert_match "*table size: 16*" [r debug HTSTATS 0] + # waiting for serverCron to resize the tables + wait_for_condition 1000 10 { + [string match {*table size: 16*} [r debug HTSTATS 0]] + } else { + puts [r debug HTSTATS 0] + fail "hash tables weren't resize." + } } {} {needs:debug} }