Skip to content

test: Fix flaky L0_http test_large_string_in_json#8819

Merged
Vinya567 merged 4 commits into
mainfrom
vinyak/tri-1378-fix-ci-test-l0_http-base
Jun 5, 2026
Merged

test: Fix flaky L0_http test_large_string_in_json#8819
Vinya567 merged 4 commits into
mainfrom
vinyak/tri-1378-fix-ci-test-l0_http-base

Conversation

@Vinya567

@Vinya567 Vinya567 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What does the PR do?

Fixes a deterministic failure in qa/L0_http/http_input_size_limit_test.py::test_large_string_in_json.

The test built a ~2 GiB JSON body to exercise the server's --http-max-input-size guard, but that body produces a Content-Length header beyond INT32_MAX. After the recent std::atoistd::stoi change in Content-Length parsing (#8794), the server now rejects the request at the header-parse step (with an INT32 range error) before ever reaching the JSON-size check the test asserts on, so the test fails on every nightly.

The fix shrinks the request body to byte-precise boundaries around the JSON-size limit, so the test actually exercises the guard it claims to.

Checklist

  • PR title reflects the change and is of format <type>: <description>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

  • test

Related PRs:

Where should the reviewer start?

qa/L0_http/http_input_size_limit_test.py — the change is contained to one file. Look at the new _build_payload_of_json_size helper and the rewritten test_large_string_in_json.

Test plan:

Verified locally in a triton-devel container against main:

  • InferSizeLimitTest.test_large_string_in_json — 10/10 pass
  • Full qa/L0_http/test.sh — passes, no other regressions

The new test asserts both sides of the boundary:

  • Body of exactly DEFAULT_LIMIT_BYTES (64 MiB) → must succeed (200)
  • Body of DEFAULT_LIMIT_BYTES + 1 → must fail with the JSON-size error

Body length is asserted byte-exact in the helper via assertEqual(len(json.dumps(payload)), target_size) before being posted with requests.post(json=payload), so the boundary is byte-precise and not skewed by JSON wrapper overhead.

test_chunked_infer_over_max_chunks_reject_with_bounded_rss_growth (in qa/L0_http/http_request_many_chunks.py) also occasionally fails in nightly runs with intermittent RSS-growth assertions (4.2 MiB > 1 MiB). That failure is intermittent, unrelated to this fix, and should be tracked separately.

Background

test_large_string_in_json was added to verify the server's --http-max-input-size JSON-body limit. The original test built a body large enough to clearly exceed the default 64 MiB limit, but also large enough that the resulting Content-Length header overflows a signed 32-bit integer (Content-Length: 2147483796 vs INT32_MAX = 2147483647).

Before #8794, Content-Length was parsed with std::atoi, which silently returned an undefined-but-non-throwing value on overflow, so the body still reached the JSON-size check. After #8794 switched to std::stoi, that parse now throws std::out_of_range and the server returns 400 with:

Unable to parse Content-Length, value is out of range [ -2147483648, 2147483647 ], got: 2147483796

which doesn't match the JSON-size error the test expects. The fix keeps the test focused on the JSON-size guard by constructing a body just at and just above the limit (well below INT32 Content-Length).

Related Issues:

Vinya567 added 2 commits June 4, 2026 20:17
Use a payload just over the 64MB default limit instead of ~2GB so the
server returns the expected JSON size error rather than rejecting the
request at INT32 Content-Length parsing.
Per Yingge's review feedback on the initial fix:
- Use byte-precise +1 boundary instead of OFFSET_ELEMENTS (32 bytes).
- Add complementary "exactly at limit succeeds" case so the test guards
  both sides of the boundary, matching the pattern used by
  test_default_limit_raw_binary.

Body is constructed manually with json.dumps and posted with data=
so the total HTTP body length is exact (no wrapper-overhead drift).
@Vinya567 Vinya567 requested a review from yinggeh June 5, 2026 03:22
@Vinya567 Vinya567 self-assigned this Jun 5, 2026
@yinggeh yinggeh requested review from pskiran1 and whoisj June 5, 2026 05:11
Comment thread qa/L0_http/http_input_size_limit_test.py Outdated
Comment thread qa/L0_http/http_input_size_limit_test.py Outdated
@yinggeh

yinggeh commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

If you are using agent generating PR description, make sure tell it to use https://github.com/triton-inference-server/server/blob/main/.github/PULL_REQUEST_TEMPLATE/pull_request_template_internal_contrib.md as the template.

@yinggeh

yinggeh commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Again, do not put linear tickets in public PRs.

@Vinya567 Vinya567 changed the title test: Fix flaky L0_http test_large_string_in_json (TRI-1378) test: Fix flaky L0_http test_large_string_in_json Jun 5, 2026
- Rename _build_string_body_of_size -> _build_json_string_body_of_size
  (more specific name, JSON is the operative format)
- Drop PR-specific commentary from the test docstring and inline
  comments; keep only documentation that's useful when reading the
  test itself

Per review on #8819.
@Vinya567 Vinya567 requested a review from yinggeh June 5, 2026 06:21
@Vinya567

Vinya567 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Both addressed:

  • PR description rewritten to use pull_request_template_internal_contrib.md all template sections filled out.
  • Scrubbed all Linear / internal references (description, title, etc.).

Sorry for the slip ,added both rules to my onboarding checklist so they don't happen again. Thanks for the catches!

whoisj
whoisj previously approved these changes Jun 5, 2026
pskiran1
pskiran1 previously approved these changes Jun 5, 2026

@pskiran1 pskiran1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread qa/L0_http/http_input_size_limit_test.py Outdated
Comment thread qa/L0_http/http_input_size_limit_test.py Outdated
@yinggeh yinggeh self-requested a review June 5, 2026 22:37

@yinggeh yinggeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

Comment thread qa/L0_http/http_input_size_limit_test.py Outdated
@yinggeh yinggeh self-requested a review June 5, 2026 22:39
…helper

Apply review feedback on test_large_string_in_json:
- Replace bare assert with self.assertGreaterEqual / self.assertEqual so
  failures surface through unittest's reporting.
- Build the request via requests.post(json=payload) instead of dumping the
  body and passing data=, which is more explicit about the content type and
  lets requests handle the Content-Type header.
- Rename helper to _build_payload_of_json_size since it now returns the
  payload dict instead of a serialized body.
@Vinya567 Vinya567 dismissed stale reviews from pskiran1 and whoisj via f9b4e0b June 5, 2026 22:47

@yinggeh yinggeh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yinggeh yinggeh added the PR: test Adding missing tests or correcting existing test label Jun 5, 2026
@Vinya567 Vinya567 merged commit 8f90112 into main Jun 5, 2026
3 checks passed
@Vinya567 Vinya567 deleted the vinyak/tri-1378-fix-ci-test-l0_http-base branch June 5, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: test Adding missing tests or correcting existing test

Development

Successfully merging this pull request may close these issues.

4 participants