Skip to content

tests: runtime: wait for tail truncate output#11810

Merged
edsiper merged 1 commit into
masterfrom
tail-truncate-runtime-test-fix
May 16, 2026
Merged

tests: runtime: wait for tail truncate output#11810
edsiper merged 1 commit into
masterfrom
tail-truncate-runtime-test-fix

Conversation

@edsiper
Copy link
Copy Markdown
Member

@edsiper edsiper commented May 16, 2026


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

  • Tests
    • Added a new timeout polling helper function for tail input tests to validate expected output count.
    • Updated the tail truncation long lines test to use the new helper instead of generic timeout handling.
    • Reorganized test setup variable declarations.

Review Change Stack

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR adds a new test polling utility wait_expected_num_with_timeout() that waits for the output count to reach a specific expected value, and updates the truncation test to use it with explicit expected counts. Variable declarations in the test setup were adjusted to support this more precise waiting mechanism.

Changes

Test utility enhancement for truncation test reliability

Layer / File(s) Summary
Polling utility and truncation test updates
tests/runtime/in_tail.c
New wait_expected_num_with_timeout() helper (lines 343–371) polls output count with timeout until reaching an expected threshold. Updated test variable declarations (lines 1098–1101) and replaced generic wait call with the new helper passing nExpected (line 1157).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • fluent/fluent-bit#11059: The main PR's updates to tests/runtime/in_tail.c directly refine the long-line truncation tests introduced by the in_tail truncation implementation.

Suggested reviewers

  • cosmo0920
  • fujimotos

Poem

A rabbit hops through tests with glee,
Polling helpers wait with precision spree,
Expected counts now match the flow,
Truncation tests can trusting go! 🐰✨

🚥 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 and specifically describes the main change: adding a wait mechanism for tail truncate output in 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 tail-truncate-runtime-test-fix

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/runtime/in_tail.c (1)

343-370: ⚡ Quick win

Consider consolidating the wait helper functions.

There are now three nearly identical wait functions (wait_with_timeout, wait_num_with_timeout, and wait_expected_num_with_timeout) that differ only in their exit conditions. The shared timeout polling logic could be extracted into a common helper or parameterized to reduce duplication.

♻️ Example consolidation approach

One approach is to add a callback parameter for the exit condition:

typedef int (*wait_condition_fn)(void *data);

void wait_with_timeout_generic(uint32_t timeout_ms, wait_condition_fn should_stop, void *data)
{
    struct flb_time start_time;
    struct flb_time end_time;
    struct flb_time diff_time;
    uint64_t elapsed_time_flb = 0;

    flb_time_get(&start_time);

    while (true) {
        if (should_stop(data)) {
            break;
        }

        flb_time_msleep(100);
        flb_time_get(&end_time);
        flb_time_diff(&end_time, &start_time, &diff_time);
        elapsed_time_flb = flb_time_to_nanosec(&diff_time) / 1000000;

        if (elapsed_time_flb > timeout_ms) {
            flb_warn("[timeout] elapsed_time: %ld", elapsed_time_flb);
            break;
        }
    }
}

Then each specific wait function would become a thin wrapper that provides the appropriate condition callback.

🤖 Prompt for 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.

In `@tests/runtime/in_tail.c` around lines 343 - 370, The three near-duplicate
functions wait_with_timeout, wait_num_with_timeout, and
wait_expected_num_with_timeout repeat the same polling/timeout logic; extract
that common logic into a single generic helper (e.g., wait_with_timeout_generic)
that accepts a callback typedef (e.g., wait_condition_fn or similar) and a void*
data pointer for the condition, then rewrite wait_with_timeout,
wait_num_with_timeout, and wait_expected_num_with_timeout as thin wrappers that
pass their specific stop-condition functions (and data) into the generic helper;
ensure the generic helper preserves the existing timing, sleep, elapsed logging
(flb_time_get/ flb_time_msleep/ flb_time_diff/ flb_time_to_nanosec and flb_warn)
so behavior remains identical.
🤖 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.

Nitpick comments:
In `@tests/runtime/in_tail.c`:
- Around line 343-370: The three near-duplicate functions wait_with_timeout,
wait_num_with_timeout, and wait_expected_num_with_timeout repeat the same
polling/timeout logic; extract that common logic into a single generic helper
(e.g., wait_with_timeout_generic) that accepts a callback typedef (e.g.,
wait_condition_fn or similar) and a void* data pointer for the condition, then
rewrite wait_with_timeout, wait_num_with_timeout, and
wait_expected_num_with_timeout as thin wrappers that pass their specific
stop-condition functions (and data) into the generic helper; ensure the generic
helper preserves the existing timing, sleep, elapsed logging (flb_time_get/
flb_time_msleep/ flb_time_diff/ flb_time_to_nanosec and flb_warn) so behavior
remains identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dbe1538e-fcdd-44bb-8072-26c44c150087

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee8687 and 339a6b8.

📒 Files selected for processing (1)
  • tests/runtime/in_tail.c

@edsiper edsiper merged commit 1352cd7 into master May 16, 2026
76 of 79 checks passed
@edsiper edsiper deleted the tail-truncate-runtime-test-fix branch May 16, 2026 12:24
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