Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix unit tests for parsers and calyptia custom. #6569

Merged
merged 4 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/internal/parser_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions tests/internal/parser_logfmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions tests/internal/parser_ltsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions tests/internal/parser_regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
14 changes: 8 additions & 6 deletions tests/runtime/custom_calyptia_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ 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;
flb_sds_t cfg;

ctx = flb_create();
flb_service_set(ctx, "flush", "1", "grace", "1", NULL);

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);
Expand All @@ -41,11 +42,12 @@ void flb_custom_calyptia_pipeline_config_get_test()
flb_custom_set_property(calyptia, "add_label", "pipeline_id 7DDD2941-3ED6-4B8C-9F84-DD04C4A018A4");
flb_custom_set_property(calyptia, "calyptia_host", "cloud-api.calyptia.com");
flb_custom_set_property(calyptia, "calyptia_port", "443");
flb_custom_set_property(calyptia, "tls", "on");
flb_custom_set_property(calyptia, "tls_verify", "on");

cfg = custom_calyptia_pipeline_config_get(ctx->config);
TEST_CHECK(strcmp(cfg, cfg_str) == 0);

// fix a thread local storage bug on macos
flb_output_prepare();
flb_sds_destroy(cfg);
flb_destroy(ctx);
}
Expand Down
19 changes: 14 additions & 5 deletions tests/runtime/filter_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,20 @@ void flb_test_filter_parser_handle_time_key_with_time_zone()
NULL);

/* Parser */
parser = flb_parser_create("timestamp", "regex", "^(?<time>.*)$", FLB_TRUE,
"%Y-%m-%dT%H:%M:%S.%L %z",
"time",
NULL, MK_FALSE, MK_TRUE,
NULL, 0, NULL, ctx->config);
parser = flb_parser_create("timestamp", // name
"regex", // format
"^(?<time>.*)$", // regex
FLB_TRUE, // skip_empty
"%Y-%m-%dT%H:%M:%S.%L %z", // time_fmt
"time", // time_key
NULL, // time_offset
MK_FALSE, // time_keep
MK_TRUE, // time_strict
MK_FALSE, // logfmt_no_bare_keys
NULL, // types
0, // types_len
NULL, // decoders
ctx->config); // config
TEST_CHECK(parser != NULL);

/* Filter */
Expand Down