From da9e04a8a15cd596b1948a561cfbd7768350056c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Sat, 17 Oct 2026 14:41:19 -0600 Subject: [PATCH] tests: runtime: out_http: push JSON format records together The JSON format cases pushed their two records separately. When a flush ran between the pushes, the records went to separate chunks, so each formatter call held a single record and the check for both records failed. Push both records at once, so they are appended to the same chunk. Signed-off-by: Eduardo Silva --- tests/runtime/out_http.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/runtime/out_http.c b/tests/runtime/out_http.c index 615c3f9b427..0762672c5f5 100644 --- a/tests/runtime/out_http.c +++ b/tests/runtime/out_http.c @@ -389,10 +389,13 @@ void flb_test_format_json() int ret; int num; - char *buf1 = "[1, {\"msg\":\"hello world\"}]"; + /* + * Both records in one push: in_lib appends them together, so a flush + * cannot split them across formatter calls. + */ + char *buf1 = "[1, {\"msg\":\"hello world\"}]" + "[2, {\"msg\":\"hello world\"}]"; size_t size1 = strlen(buf1); - char *buf2 = "[2, {\"msg\":\"hello world\"}]"; - size_t size2 = strlen(buf2); char *expected_strs[] = {"[{\"date\":1.0,\"msg\":\"hello world\"},{\"date\":2.0,\"msg\":\"hello world\"}]"}; struct str_list expected = { @@ -426,8 +429,6 @@ void flb_test_format_json() /* Ingest data sample */ ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf1, size1); TEST_CHECK(ret >= 0); - ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf2, size2); - TEST_CHECK(ret >= 0); /* waiting to flush */ flb_time_msleep(500); @@ -446,10 +447,13 @@ void flb_test_format_json_stream() int ret; int num; - char *buf1 = "[1, {\"msg\":\"hello world\"}]"; + /* + * Both records in one push: in_lib appends them together, so a flush + * cannot split them across formatter calls. + */ + char *buf1 = "[1, {\"msg\":\"hello world\"}]" + "[2, {\"msg\":\"hello world\"}]"; size_t size1 = strlen(buf1); - char *buf2 = "[2, {\"msg\":\"hello world\"}]"; - size_t size2 = strlen(buf2); char *expected_strs[] = {"{\"date\":1.0,\"msg\":\"hello world\"}{\"date\":2.0,\"msg\":\"hello world\"}"}; struct str_list expected = { @@ -483,8 +487,6 @@ void flb_test_format_json_stream() /* Ingest data sample */ ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf1, size1); TEST_CHECK(ret >= 0); - ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf2, size2); - TEST_CHECK(ret >= 0); /* waiting to flush */ flb_time_msleep(500); @@ -503,10 +505,13 @@ void flb_test_format_json_lines() int ret; int num; - char *buf1 = "[1, {\"msg\":\"hello world\"}]"; + /* + * Both records in one push: in_lib appends them together, so a flush + * cannot split them across formatter calls. + */ + char *buf1 = "[1, {\"msg\":\"hello world\"}]" + "[2, {\"msg\":\"hello world\"}]"; size_t size1 = strlen(buf1); - char *buf2 = "[2, {\"msg\":\"hello world\"}]"; - size_t size2 = strlen(buf2); char *expected_strs[] = {"{\"date\":1.0,\"msg\":\"hello world\"}\n{\"date\":2.0,\"msg\":\"hello world\"}"}; struct str_list expected = { @@ -540,8 +545,6 @@ void flb_test_format_json_lines() /* Ingest data sample */ ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf1, size1); TEST_CHECK(ret >= 0); - ret = flb_lib_push(ctx->flb, ctx->i_ffd, (char *) buf2, size2); - TEST_CHECK(ret >= 0); /* waiting to flush */ flb_time_msleep(500);