From 6ad009dfef3349d93f6182f1e4ad5fbceacfe038 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 26 Aug 2024 12:25:32 -0600 Subject: [PATCH] tests: prometheus_parser: add issue flb 9267 Signed-off-by: Eduardo Silva --- tests/data/issue_fluent_bit_9267.txt | 1 + tests/prometheus_parser.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/data/issue_fluent_bit_9267.txt diff --git a/tests/data/issue_fluent_bit_9267.txt b/tests/data/issue_fluent_bit_9267.txt new file mode 100644 index 0000000..979183b --- /dev/null +++ b/tests/data/issue_fluent_bit_9267.txt @@ -0,0 +1 @@ +_bu_nn 0 171798732 \ No newline at end of file diff --git a/tests/prometheus_parser.c b/tests/prometheus_parser.c index 8cdef46..8be8bdd 100644 --- a/tests/prometheus_parser.c +++ b/tests/prometheus_parser.c @@ -261,7 +261,7 @@ void test_escape_sequences() } void test_metric_without_labels() -{ +{ cfl_sds_t result; const char expected[] = @@ -776,7 +776,7 @@ void test_issue_fluent_bit_5541() "http_request_duration_seconds_bucket{le=\"0.25\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"0.5\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"0.75\"} 2 0\n" - "http_request_duration_seconds_bucket{le=\"1.0\"} 2 0\n" + "http_request_duration_seconds_bucket{le=\"1.0\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"2.5\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"5.0\"} 2 0\n" "http_request_duration_seconds_bucket{le=\"7.5\"} 2 0\n" @@ -1665,6 +1665,29 @@ void test_issue_fluent_bit_6534() cmt_decode_prometheus_destroy(cmt); } +void test_issue_fluent_bit_9267() +{ + char errbuf[256]; + int status; + cfl_sds_t result = NULL; + struct cmt *cmt; + struct cmt_decode_prometheus_parse_opts opts; + memset(&opts, 0, sizeof(opts)); + opts.errbuf = errbuf; + opts.errbuf_size = sizeof(errbuf); + cfl_sds_t in_buf = read_file(CMT_TESTS_DATA_PATH "/issue_fluent_bit_9267.txt"); + size_t in_size = cfl_sds_len(in_buf); + + status = cmt_decode_prometheus_create(&cmt, in_buf, in_size, &opts); + TEST_CHECK(status == 0); + if (status) { + fprintf(stderr, "PARSE ERROR:\n======\n%s\n======\n", errbuf); + } + + cmt_decode_prometheus_destroy(cmt); + cfl_sds_destroy(in_buf); +} + TEST_LIST = { {"header_help", test_header_help}, {"header_type", test_header_type}, @@ -1697,5 +1720,6 @@ TEST_LIST = { {"pr_168", test_pr_168}, {"histogram_different_label_count", test_histogram_different_label_count}, {"issue_fluent_bit_6534", test_issue_fluent_bit_6534}, + {"issue_fluent_bit_9267", test_issue_fluent_bit_9267}, { 0 } };