Pause cron to prevent premature shrinking in querybuf test (#12126)

Tests occasionally fail since #12000:
```
*** [err]: query buffer resized correctly when not idle in tests/unit/querybuf.tcl
Expected 0 > 32768 (context: type eval line 11 cmd {assert {$orig_test_client_qbuf > 32768}} proc ::test)

*** [err]: query buffer resized correctly with fat argv in tests/unit/querybuf.tcl
query buffer should not be resized when client idle time smaller than 2s
```

The reason may be because we set hz to 100, querybuf shrinks before we count
client_query_buffer. We avoid this problem by setting pause-cron to 1.
This commit is contained in:
Binbin 2023-05-04 18:02:08 +08:00 committed by GitHub
parent 857c09b04d
commit e49c2a5292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -5,7 +5,7 @@ proc client_idle_sec {name} {
return $idle
}
# Calculate query buffer memory of slave
# Calculate query buffer memory of client
proc client_query_buffer {name} {
set clients [split [r client list] "\r\n"]
set c [lsearch -inline $clients *name=$name*]
@ -20,6 +20,7 @@ proc client_query_buffer {name} {
start_server {tags {"querybuf slow"}} {
# increase the execution frequency of clientsCron
r config set hz 100
# The test will run at least 2s to check if client query
# buffer will be resized when client idle 2s.
test "query buffer resized correctly" {
@ -40,6 +41,9 @@ start_server {tags {"querybuf slow"}} {
}
test "query buffer resized correctly when not idle" {
# Pause cron to prevent premature shrinking (timing issue).
r debug pause-cron 1
# Memory will increase by more than 32k due to client query buffer.
set rd [redis_client]
$rd client setname test_client
@ -51,6 +55,8 @@ start_server {tags {"querybuf slow"}} {
set orig_test_client_qbuf [client_query_buffer test_client]
assert {$orig_test_client_qbuf > 32768}
r debug pause-cron 0
# Wait for qbuf to shrink due to lower peak
set t [clock milliseconds]
while true {
@ -64,7 +70,7 @@ start_server {tags {"querybuf slow"}} {
# Validate qbuf shrunk but isn't 0 since we maintain room based on latest peak
assert {[client_query_buffer test_client] > 0 && [client_query_buffer test_client] < $orig_test_client_qbuf}
$rd close
}
} {0} {needs:debug}
test "query buffer resized correctly with fat argv" {
set rd [redis_client]