From: Yeonggi Kim Date: Tue, 6 Oct 2026 11:29:11 +0000 (+0900) Subject: REGTESTS: cli: test a command line of exactly tune.bufsize bytes X-Git-Tag: v3.5-dev9~105 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=1b6473962f7e68142713a61cab1769f762ae725c;p=haproxy.git REGTESTS: cli: test a command line of exactly tune.bufsize bytes This test covers the bug fixed by the previous commit: BUG/MEDIUM: cli: fix the last command detection on a full command line With "tune.bufsize 1024", two clients each send a line of exactly 1024 bytes: one command padded with spaces, then two pipelined commands. The commands change the global rate limits and produce no output, so "expect_close" only has to skip the empty lines sent after each command before the connection is closed. On an unpatched build, it fails on the first "Unknown command" error. With DEBUG_STRICT=2, haproxy dies instead, and the test times out on the following "show info", which checks that each command was executed. This must be backported wherever the fix above is backported. --- diff --git a/reg-tests/cli/cmdline_full_buffer.vtc b/reg-tests/cli/cmdline_full_buffer.vtc new file mode 100644 index 000000000..febcfdb03 --- /dev/null +++ b/reg-tests/cli/cmdline_full_buffer.vtc @@ -0,0 +1,53 @@ +varnishtest "Test a CLI command line which fills the whole buffer" + +# A command line of exactly tune.bufsize bytes, including its final LF, +# fills the chunk it is copied into. The last command of such a line was +# not detected, so once it was executed, the CLI parsed the remains of +# the line again and sent "Unknown command" errors in loop until the +# client closed. +# +# Each client below sends one such line, made of commands which produce +# no output, padded with spaces. A non-interactive CLI then only sends an +# empty line after each command, and closes. "expect_close" skips these +# LFs and fails on anything else, such as the first "Unknown command" +# error. The effect of the commands is checked afterwards, to be sure +# they were executed. + +feature ignore_unknown_macro + +haproxy h1 -conf { + global + .if feature(THREAD) + thread-groups 1 + .endif + tune.bufsize 1024 +} -start + +# one command: 38 + 985 + 1 = 1024 bytes +client c1 -connect ${h1_cli_sock} { + send "set rate-limit connections global 1234" + send_n 985 " " + send "\n" + expect_close +} -run + +haproxy h1 -cli { + send "show info" + expect ~ "\nConnRateLimit: 1234\n" +} + +# two pipelined commands: 39 + 35 + 949 + 1 = 1024 bytes +client c2 -connect ${h1_cli_sock} { + send "set rate-limit connections global 1111;" + send "set rate-limit sessions global 2222" + send_n 949 " " + send "\n" + expect_close +} -run + +haproxy h1 -cli { + send "show info" + expect ~ "\nConnRateLimit: 1111\n" + send "show info" + expect ~ "\nSessRateLimit: 2222\n" +}