summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2023-05-09 19:14:22 +0800
committerGitHub <noreply@github.com>2023-05-09 14:14:22 +0300
commit6ab2174d37185cd20280ff3e0f7f287ebefd4c92 (patch)
tree3d0b32fb58ab0a13370df336ba80d2582f32a8b2
parent9b53cb28d6a100ec5a389e69a83f89165159d0c3 (diff)
downloadredis-6ab2174d37185cd20280ff3e0f7f287ebefd4c92.tar.gz
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.
-rw-r--r--tests/unit/expire.tcl14
1 files 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