Skip to content

Commit 578f46a

Browse files
cosmo0920edsiper
andcommitted
ml: tests: Process truncated case and follow the interface change
This commit updates the expected output for the 'container_mix' unit test. Previously, the multiline engine could incorrectly merge pending messages when the log stream switched between different parser types (e.g., from `docker` to `cri`). The test's original expectations were written to match this buggy behavior. Recent fixes have made the engine's state handling more robust and precise. It now correctly flushes a pending message when the parser context changes, preventing improper merges. This change aligns the test case with the new, correct logic. Signed-off-by: Hiroshi Hatake <[email protected]> Co-authored-by: Eduardo Silva <[email protected]>
1 parent a2804ec commit 578f46a

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

tests/internal/multiline.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,11 @@ struct record_check container_mix_output[] = {
111111
{"a1\n"},
112112
{"a2\n"},
113113
{"ddee\n"},
114-
{"bbcc"},
114+
{"bbccdd-out\n"},
115+
{"dd-err\n"},
115116
{"single full"},
116117
{"1a. some multiline log"},
117118
{"1b. some multiline log"},
118-
{"dd-out\n"},
119-
{"dd-err\n"},
120119
};
121120

122121
/* Java stacktrace detection */
@@ -393,6 +392,10 @@ static int flush_callback(struct flb_ml_parser *parser,
393392
fprintf(stdout, "%s----------- EOF -----------%s\n",
394393
ANSI_YELLOW, ANSI_RESET);
395394

395+
if (!res) {
396+
return 0;
397+
}
398+
396399
/* Validate content */
397400
msgpack_unpacked_init(&result);
398401
off = 0;
@@ -1457,6 +1460,36 @@ static void test_issue_5504()
14571460
#endif
14581461
}
14591462

1463+
static void test_buffer_limit_truncation()
1464+
{
1465+
int ret;
1466+
uint64_t stream_id;
1467+
struct flb_config *config;
1468+
struct flb_ml *ml;
1469+
struct flb_ml_parser_ins *mlp_i;
1470+
struct flb_time tm;
1471+
1472+
config = flb_config_init();
1473+
config->multiline_buffer_limit = 32;
1474+
1475+
ml = flb_ml_create(config, "limit-test");
1476+
TEST_CHECK(ml != NULL);
1477+
1478+
mlp_i = flb_ml_parser_instance_create(ml, "docker");
1479+
TEST_CHECK(mlp_i != NULL);
1480+
1481+
ret = flb_ml_stream_create(ml, "test", -1, flush_callback, NULL, &stream_id);
1482+
TEST_CHECK(ret == 0);
1483+
1484+
flb_time_get(&tm);
1485+
ret = flb_ml_append_text(ml, stream_id, &tm,
1486+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 36);
1487+
TEST_CHECK(ret == FLB_MULTILINE_TRUNCATED);
1488+
1489+
flb_ml_destroy(ml);
1490+
flb_config_exit(config);
1491+
}
1492+
14601493
TEST_LIST = {
14611494
/* Normal features tests */
14621495
{ "parser_docker", test_parser_docker},
@@ -1474,5 +1507,6 @@ TEST_LIST = {
14741507
{ "issue_4034" , test_issue_4034},
14751508
{ "issue_4949" , test_issue_4949},
14761509
{ "issue_5504" , test_issue_5504},
1510+
{ "buffer_limit_truncation", test_buffer_limit_truncation},
14771511
{ 0 }
14781512
};

0 commit comments

Comments
 (0)