From 6ab2174d37185cd20280ff3e0f7f287ebefd4c92 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 9 May 2023 19:14:22 +0800 Subject: [PATCH] EXPIRE precision test more attempts and more tolerant (#12150) The test failed on MacOS: ``` *** [err]: EXPIRE precision is now the millisecond in tests/unit/expire.tcl Expected 'somevalue {}' to equal or match '{} {}' ``` `set a [r get x]`, even though we tried 10 times, sometimes we still get {}, this is a time-sensitive test. In this PR, we add the following changes: 1. More attempts, change it from 10 to 30. 2. More tolerant, change the `after 900` to `after 800`. In addition, we judging $a in advance and changing `after 1100` to `after 300`, this will save us some times. --- tests/unit/expire.tcl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 5ee4488b3..ec9d73cc2 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -76,20 +76,22 @@ start_server {tags {"expire"}} { # This test is very likely to do a false positive if the # server is under pressure, so if it does not work give it a few more # chances. - for {set j 0} {$j < 10} {incr j} { + for {set j 0} {$j < 30} {incr j} { r del x r setex x 1 somevalue - after 900 + after 800 set a [r get x] - after 1100 + if {$a ne {somevalue}} continue + after 300 set b [r get x] - if {$a eq {somevalue} && $b eq {}} break + if {$b eq {}} break } if {$::verbose} { puts "millisecond expire test attempts: $j" } - list $a $b - } {somevalue {}} + assert_equal $a {somevalue} + assert_equal $b {} + } test "PSETEX can set sub-second expires" { # This test is very likely to do a false positive if the server is