2024-03-21 09:30:47 -04:00
|
|
|
# SPDX-FileCopyrightText: 2024 Redict Contributors
|
|
|
|
# SPDX-FileCopyrightText: 2024 Salvatore Sanfilippo <antirez at gmail dot com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2024-03-21 15:11:44 -04:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
2024-03-21 09:30:47 -04:00
|
|
|
|
2022-02-22 04:19:38 -05:00
|
|
|
proc get_reply_buffer_size {cname} {
|
|
|
|
|
|
|
|
set clients [split [string trim [r client list]] "\r\n"]
|
|
|
|
set c [lsearch -inline $clients *name=$cname*]
|
|
|
|
if {![regexp rbs=(\[a-zA-Z0-9-\]+) $c - rbufsize]} {
|
2022-03-01 07:40:29 -05:00
|
|
|
error "field rbs not found in $c"
|
2022-02-22 04:19:38 -05:00
|
|
|
}
|
|
|
|
return $rbufsize
|
|
|
|
}
|
|
|
|
|
|
|
|
start_server {tags {"replybufsize"}} {
|
|
|
|
|
|
|
|
test {verify reply buffer limits} {
|
|
|
|
# In order to reduce test time we can set the peak reset time very low
|
2022-03-01 07:40:29 -05:00
|
|
|
r debug replybuffer peak-reset-time 100
|
2022-02-22 04:19:38 -05:00
|
|
|
|
|
|
|
# Create a simple idle test client
|
2024-03-21 05:56:59 -04:00
|
|
|
variable tc [redict_client]
|
2022-02-22 04:19:38 -05:00
|
|
|
$tc client setname test_client
|
|
|
|
|
|
|
|
# make sure the client is idle for 1 seconds to make it shrink the reply buffer
|
|
|
|
wait_for_condition 10 100 {
|
|
|
|
[get_reply_buffer_size test_client] >= 1024 && [get_reply_buffer_size test_client] < 2046
|
|
|
|
} else {
|
|
|
|
set rbs [get_reply_buffer_size test_client]
|
|
|
|
fail "reply buffer of idle client is $rbs after 1 seconds"
|
|
|
|
}
|
|
|
|
|
|
|
|
r set bigval [string repeat x 32768]
|
|
|
|
|
|
|
|
# In order to reduce test time we can set the peak reset time very low
|
2022-03-01 07:40:29 -05:00
|
|
|
r debug replybuffer peak-reset-time never
|
2022-02-22 04:19:38 -05:00
|
|
|
|
|
|
|
wait_for_condition 10 100 {
|
|
|
|
[$tc get bigval ; get_reply_buffer_size test_client] >= 16384 && [get_reply_buffer_size test_client] < 32768
|
|
|
|
} else {
|
|
|
|
set rbs [get_reply_buffer_size test_client]
|
|
|
|
fail "reply buffer of busy client is $rbs after 1 seconds"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Restore the peak reset time to default
|
2022-03-01 07:40:29 -05:00
|
|
|
r debug replybuffer peak-reset-time reset
|
2022-02-22 04:19:38 -05:00
|
|
|
|
|
|
|
$tc close
|
|
|
|
} {0} {needs:debug}
|
|
|
|
}
|
|
|
|
|