test: Use timeout_factor for drain timeout in check_slow_read_throttle #36450

Manually merged
maflcko merged 1 commit from 2610-test-check_slow_read_throttle-http-timeout-fix into master 2026-10-08 15:24:55 +00:00 AGit
maflcko commented 2026-10-07 09:44:00 +00:00 (Migrated from github.com)

The check_slow_read_throttle functional test may intermittently fail on slow build configs (like sanitizers+debug+no-opt). This is fine, but it would be nice if it passed.

To reproduce the failure, add a long sleep for the big json requests:

diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 0c25ebbba5..42c54c2cdf 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -614,2 +614,3 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte>
     bool send_buffer_was_empty{false};
+    bool send_buffer_over_limit{false};
     // Fill the send buffer with the complete serialized response headers + body
@@ -634,2 +635,4 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte>
         if (!send_buffer_was_empty) m_send_ready = true;
+
+        send_buffer_over_limit = m_send_buffer.size() > MAX_BODY_SIZE;
     }
@@ -652,2 +655,11 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte>
 
+    // TEST-ONLY: Widen the interval between queueing a throttling-sized response
+    // and allowing the next pipelined request to be dispatched. This reproduces
+    // the slow-worker scheduling window exercised by interface_http.py.
+    if (send_buffer_over_limit) {
+    // The functional test waits twice for five seconds before it starts
+    // its own ten-second recv() timeout, so this must cover both phases.
+    std::this_thread::sleep_for(30s);
+    }
+
     // Signal to the I/O loop that we are ready to handle the next request.

Then, on master (or on this pull with --timeout-factor=1), it will fail and with --timeout-factor=3 it will pass:

./bld-cmake/test/functional/interface_http.py --test_methods check_slow_read_throttle --loglevel=DEBUG --timeout-factor 3
The `check_slow_read_throttle` functional test may intermittently fail on slow build configs (like sanitizers+debug+no-opt). This is fine, but it would be nice if it passed. To reproduce the failure, add a long sleep for the big json requests: ```diff diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 0c25ebbba5..42c54c2cdf 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -614,2 +614,3 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte> bool send_buffer_was_empty{false}; + bool send_buffer_over_limit{false}; // Fill the send buffer with the complete serialized response headers + body @@ -634,2 +635,4 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte> if (!send_buffer_was_empty) m_send_ready = true; + + send_buffer_over_limit = m_send_buffer.size() > MAX_BODY_SIZE; } @@ -652,2 +655,11 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte> + // TEST-ONLY: Widen the interval between queueing a throttling-sized response + // and allowing the next pipelined request to be dispatched. This reproduces + // the slow-worker scheduling window exercised by interface_http.py. + if (send_buffer_over_limit) { + // The functional test waits twice for five seconds before it starts + // its own ten-second recv() timeout, so this must cover both phases. + std::this_thread::sleep_for(30s); + } + // Signal to the I/O loop that we are ready to handle the next request. ``` Then, on master (or on this pull with `--timeout-factor=1`), it will fail and with `--timeout-factor=3` it will pass: ``` ./bld-cmake/test/functional/interface_http.py --test_methods check_slow_read_throttle --loglevel=DEBUG --timeout-factor 3 ```
DrahtBot commented 2026-10-07 09:44:09 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK pinheadmz, l0rinc

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36450 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36450.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36450#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [pinheadmz](https://github.com/bitcoin/bitcoin/pull/36450#issuecomment-6039665804), [l0rinc](https://github.com/bitcoin/bitcoin/pull/36450#issuecomment-6049869904) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 14a328f75df8193d762f421998b859a30aac1f3f
Head: fa845f76d5c6d9c4aba46e03eb9b77a6e1f5ddce

I found no actionable issues in this static review.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `14a328f75df8193d762f421998b859a30aac1f3f` Head: `fa845f76d5c6d9c4aba46e03eb9b77a6e1f5ddce` I found no actionable issues in this static review. [Full review report](<https://review.fish.foo/traces/36450-fa845f76d5c6d9c4aba46e03eb9b77a6e1f5ddce-521-1.html>)
pinheadmz commented 2026-10-07 14:05:02 +00:00 (Migrated from github.com)

untested, LGTM ACK fa845f76d5

untested, LGTM ACK fa845f76d5c6d9c4aba46e03eb9b77a6e1f5ddce
l0rinc commented 2026-10-08 00:50:43 +00:00 (Migrated from github.com)

code review ACK fa845f76d5

code review ACK fa845f76d5c6d9c4aba46e03eb9b77a6e1f5ddce
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36450
No description provided.