From 691f3c719a06639cff4e411ed20ee00be2cda619 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Fri, 16 Dec 2022 13:01:54 -0300 Subject: [PATCH 1/4] tests: fix unit tests for parsers and calyptia custom. Signed-off-by: Phillip Whelan --- tests/internal/parser_json.c | 10 +++++----- tests/internal/parser_logfmt.c | 8 ++++---- tests/internal/parser_ltsv.c | 10 +++++----- tests/internal/parser_regex.c | 10 +++++----- tests/runtime/custom_calyptia_test.c | 8 ++++---- tests/runtime/filter_parser.c | 19 ++++++++++++++----- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/tests/internal/parser_json.c b/tests/internal/parser_json.c index 5e13562ebba..ea2ad6bd2b8 100644 --- a/tests/internal/parser_json.c +++ b/tests/internal/parser_json.c @@ -171,7 +171,7 @@ void test_basic() } parser = flb_parser_create("json", "json", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -223,7 +223,7 @@ void test_time_key() } parser = flb_parser_create("json", "json", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -284,7 +284,7 @@ void test_time_keep() } parser = flb_parser_create("json", "json", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_TRUE /*time_keep */, FLB_FALSE, + FLB_TRUE /*time_keep */, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -365,7 +365,7 @@ void test_types_is_not_supported() types->type = FLB_PARSER_TYPE_HEX; parser = flb_parser_create("json", "json", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, types, 1, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -450,7 +450,7 @@ void test_decode_field_json() } parser = flb_parser_create("json", "json", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, decoder, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); diff --git a/tests/internal/parser_logfmt.c b/tests/internal/parser_logfmt.c index ccb68140109..ea363c53ab2 100644 --- a/tests/internal/parser_logfmt.c +++ b/tests/internal/parser_logfmt.c @@ -171,7 +171,7 @@ void test_basic() } parser = flb_parser_create("logfmt", "logfmt", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -223,7 +223,7 @@ void test_time_key() } parser = flb_parser_create("logfmt", "logfmt", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -284,7 +284,7 @@ void test_time_keep() } parser = flb_parser_create("logfmt", "logfmt", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_TRUE /*time_keep */, FLB_FALSE, + FLB_TRUE /*time_keep */, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -361,7 +361,7 @@ void test_types() types->type = FLB_PARSER_TYPE_HEX; parser = flb_parser_create("logfmt", "logfmt", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, types, 1, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); diff --git a/tests/internal/parser_ltsv.c b/tests/internal/parser_ltsv.c index 81facb55821..3f9170518aa 100644 --- a/tests/internal/parser_ltsv.c +++ b/tests/internal/parser_ltsv.c @@ -171,7 +171,7 @@ void test_basic() } parser = flb_parser_create("ltsv", "ltsv", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -223,7 +223,7 @@ void test_time_key() } parser = flb_parser_create("ltsv", "ltsv", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -284,7 +284,7 @@ void test_time_keep() } parser = flb_parser_create("ltsv", "ltsv", NULL, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_TRUE /*time_keep */, FLB_FALSE, + FLB_TRUE /*time_keep */, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -361,7 +361,7 @@ void test_types() types->type = FLB_PARSER_TYPE_HEX; parser = flb_parser_create("ltsv", "ltsv", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, types, 1, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -446,7 +446,7 @@ void test_decode_field_json() } parser = flb_parser_create("ltsv", "ltsv", NULL, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, decoder, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); diff --git a/tests/internal/parser_regex.c b/tests/internal/parser_regex.c index 08133accc57..2283231ce57 100644 --- a/tests/internal/parser_regex.c +++ b/tests/internal/parser_regex.c @@ -172,7 +172,7 @@ void test_basic() } parser = flb_parser_create("regex", "regex", regex, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -225,7 +225,7 @@ void test_time_key() } parser = flb_parser_create("regex", "regex", regex, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -287,7 +287,7 @@ void test_time_keep() } parser = flb_parser_create("regex", "regex", regex, FLB_FALSE, "%Y-%m-%dT%H:%M:%S.%L", "time", NULL, - FLB_TRUE /*time_keep */, FLB_FALSE, + FLB_TRUE /*time_keep */, FLB_FALSE, FLB_FALSE, NULL, 0, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -365,7 +365,7 @@ void test_types() types->type = FLB_PARSER_TYPE_HEX; parser = flb_parser_create("regex", "regex", regex, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, types, 1, NULL, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); @@ -451,7 +451,7 @@ void test_decode_field_json() } parser = flb_parser_create("regex", "regex", regex, FLB_FALSE, NULL, NULL, NULL, - FLB_FALSE, FLB_FALSE, + FLB_FALSE, FLB_FALSE, FLB_FALSE, NULL, 0, decoder, config); if (!TEST_CHECK(parser != NULL)) { TEST_MSG("flb_parser_create failed"); diff --git a/tests/runtime/custom_calyptia_test.c b/tests/runtime/custom_calyptia_test.c index 27cc911ca2b..83cd23f18ca 100644 --- a/tests/runtime/custom_calyptia_test.c +++ b/tests/runtime/custom_calyptia_test.c @@ -8,9 +8,9 @@ flb_sds_t custom_calyptia_pipeline_config_get(struct flb_config *ctx); void flb_custom_calyptia_pipeline_config_get_test() { - const char *cfg_str = "[INPUT]\n name cpu.0\n[INPUT]\n name fluentbit_metrics.1\n tag _calyptia_cloud\n scrape_on_start true\n scrape_interval 30\n\n\n[OUTPUT]\n name stdout.0\n match *\n retry_limit 1\n\n"; + const char *cfg_str = "[INPUT]\n name dummy.0\n[INPUT]\n name fluentbit_metrics.1\n tag _calyptia_cloud\n scrape_on_start true\n scrape_interval 30\n\n\n[OUTPUT]\n name stdout.0\n match *\n retry_limit 1\n\n"; flb_ctx_t *ctx; - int in_ffd_cpu; + int in_ffd_dummy; int in_ffd_metrics; int out_ffd; struct flb_custom_instance *calyptia; @@ -18,8 +18,8 @@ void flb_custom_calyptia_pipeline_config_get_test() ctx = flb_create(); - in_ffd_cpu = flb_input(ctx, (char *) "cpu", NULL); - TEST_CHECK(in_ffd_cpu >= 0); + in_ffd_dummy = flb_input(ctx, (char *) "dummy", NULL); + TEST_CHECK(in_ffd_dummy >= 0); in_ffd_metrics = flb_input(ctx, (char *) "fluentbit_metrics", NULL); TEST_CHECK(in_ffd_metrics >= 0); diff --git a/tests/runtime/filter_parser.c b/tests/runtime/filter_parser.c index f79e7e0350b..973ef2192f7 100644 --- a/tests/runtime/filter_parser.c +++ b/tests/runtime/filter_parser.c @@ -413,11 +413,20 @@ void flb_test_filter_parser_handle_time_key_with_time_zone() NULL); /* Parser */ - parser = flb_parser_create("timestamp", "regex", "^(?