Skip to content

tests: runtime: out_http: out_chronicle: fix output runtime test races#12154

Open
cosmo0920 wants to merge 3 commits into
masterfrom
cosmo0920-fix-output-runtime-test-races
Open

tests: runtime: out_http: out_chronicle: fix output runtime test races#12154
cosmo0920 wants to merge 3 commits into
masterfrom
cosmo0920-fix-output-runtime-test-races

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixed in:

  • out_http.c: callbacks now publish mutex-protected results; assertions occur after engine stop/join.
  • out_chronicle.c: same ownership model, including safe handling of the expected null-output case.

Current branch commits:

  • 49be100e0tests: runtime: out_http: Prevent resource races on checking results
  • e913d782ftests: runtime: out_chronicle: Prevent resource races on checking results

Verification:

  • build/bin/flb-rt-out_http — 15/15 passed
  • TSAN_OPTIONS='halt_on_error=1:exitcode=66' build_tsan/bin/flb-rt-out_http — 15/15 passed, no TSAN warnings
  • build/bin/flb-rt-out_chronicle — 8/8 passed
  • TSAN_OPTIONS='halt_on_error=1:exitcode=66' build_tsan/bin/flb-rt-out_chronicle — 8/8 passed, no TSAN warnings
  • tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/out_http/tests/test_out_http_001.py -q — 11 passed
  • Full PR-range commit-prefix lint — passed
  • Relevant tracked files have no uncommitted changes

Valgrind verification could not run because Valgrind is not installed on this macOS host (command -v valgrind returned no executable).


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests
    • Improved runtime output/formatter callback validation by capturing callback failures asynchronously and reporting them during test teardown.
    • Added thread-safe tracking of callback/output invocation counts to support concurrent execution.
    • Standardized context stop-and-check behavior, including expected invocation counts and stored callback error checks.
    • Strengthened validations for formatted records, metadata changes, string list outputs, and MessagePack key/value expectations.

…ults

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a1d1c6d-2fc0-44ab-b1c6-c3541f3f9941

📥 Commits

Reviewing files that changed from the base of the PR and between 49be100 and 3cefa09.

📒 Files selected for processing (1)
  • tests/runtime/out_http.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/runtime/out_http.c

📝 Walkthrough

Walkthrough

Runtime Chronicle and HTTP output tests now use mutex-protected invocation counters and deferred callback error reporting. Chronicle tests centralize stopping and validation, while HTTP callbacks validate formatter output and aggregate MessagePack matches safely.

Changes

Runtime callback validation

Layer / File(s) Summary
Chronicle callback state and teardown
tests/runtime/out_chronicle.c
Adds shared callback state and replaces repeated stop, destroy, and invocation assertions with stop_and_check.
Chronicle formatter callback checks
tests/runtime/out_chronicle.c
Callbacks record formatter and JSON validation failures, safely count invocations, and validate metadata-dependent output.
HTTP callback state and string checks
tests/runtime/out_http.c
Adds mutex-protected counters and callback error reporting for string-list callbacks, with teardown validation.
HTTP MessagePack callback counting
tests/runtime/out_http.c
Validates MessagePack records through deferred errors, aggregates matches locally, and updates shared counters through helpers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: edsiper

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing race conditions in out_http and out_chronicle runtime tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-fix-output-runtime-test-races

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cosmo0920 cosmo0920 added this to the Fluent Bit v5.1 milestone Jul 24, 2026
@cosmo0920 cosmo0920 changed the title tests: runtime: out_http: out_chronile: fix output runtime test races tests: runtime: out_http: out_chronicle: fix output runtime test races Jul 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/runtime/out_http.c`:
- Line 258: After the MessagePack unpack loop, validate the final result before
calling add_output_num(matches): fail for MSGPACK_UNPACK_PARSE_ERROR and
MSGPACK_UNPACK_NOMEM_ERROR, allow MSGPACK_UNPACK_CONTINUE only when the input is
empty, and reject every other result. Keep matches unpublished unless this
validation succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 930a382e-5516-4568-83c0-57d966e4f0eb

📥 Commits

Reviewing files that changed from the base of the PR and between cb7256c and 49be100.

📒 Files selected for processing (2)
  • tests/runtime/out_chronicle.c
  • tests/runtime/out_http.c

Comment thread tests/runtime/out_http.c Outdated
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant