Skip to content

Commit d670042

Browse files
committed
tests: internal: Add a test case for list format of parsers
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 71043cc commit d670042

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

tests/internal/config_format_yaml.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define FLB_004 FLB_TESTS_CONF_PATH "/stream_processor.yaml"
3333
#define FLB_005 FLB_TESTS_CONF_PATH "/plugins.yaml"
3434
#define FLB_006 FLB_TESTS_CONF_PATH "/upstream.yaml"
35+
#define FLB_PARSERS_LIST FLB_TESTS_CONF_PATH "/parsers/parsers-list.yaml"
3536

3637
#define FLB_000_WIN FLB_TESTS_CONF_PATH "\\fluent-bit-windows.yaml"
3738
#define FLB_BROKEN_PLUGIN_VARIANT FLB_TESTS_CONF_PATH "/broken_plugin_variant.yaml"
@@ -322,6 +323,42 @@ static void test_parser_conf()
322323
flb_config_exit(config);
323324
}
324325

326+
static void test_parser_conf_list(void)
327+
{
328+
struct flb_cf *cf;
329+
struct flb_config *config;
330+
int ret;
331+
int cnt;
332+
333+
cf = flb_cf_yaml_create(NULL, FLB_PARSERS_LIST, NULL, 0);
334+
TEST_CHECK(cf != NULL);
335+
if (!cf) {
336+
exit(EXIT_FAILURE);
337+
}
338+
339+
config = flb_config_init();
340+
TEST_CHECK(config != NULL);
341+
config->conf_path = flb_strdup(FLB_TESTS_CONF_PATH "/parsers/");
342+
343+
/* Count the parsers registered automatically by fluent-bit */
344+
cnt = mk_list_size(&config->parsers);
345+
346+
ret = flb_config_load_config_format(config, cf);
347+
if (ret != 0) {
348+
exit(EXIT_FAILURE);
349+
}
350+
351+
if (!TEST_CHECK(mk_list_size(&config->parsers) == cnt + 2)) {
352+
TEST_MSG("Section number error. Got=%d expect=%d",
353+
mk_list_size(&config->parsers),
354+
cnt + 2);
355+
}
356+
357+
flb_cf_dump(cf);
358+
flb_cf_destroy(cf);
359+
flb_config_exit(config);
360+
}
361+
325362
static inline int check_camel_to_snake(char *input, char *output)
326363
{
327364
int len;
@@ -880,6 +917,7 @@ TEST_LIST = {
880917
{ "slist odd", test_slist_odd},
881918
{ "slist even", test_slist_even},
882919
{ "parsers file conf", test_parser_conf},
920+
{ "parsers file conf list", test_parser_conf_list},
883921
{ "camel_case_key", test_camel_case_key},
884922
{ "processors", test_processors},
885923
{ "parsers_and_multiline_parsers", test_parsers_and_multiline_parsers},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[PARSER]
2+
Name extra
3+
Format regex
4+
Regex ^(?<message>.*)$
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
service:
2+
parsers_file:
3+
- parsers.conf
4+
- parsers-extra.conf

0 commit comments

Comments
 (0)