Skip to content

Commit ba60204

Browse files
committed
tests: internal: Add a test case for custom alias map
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent a712322 commit ba60204

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/internal/plugin_alias.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929

3030
#include "flb_tests_internal.h"
3131

32+
static struct flb_plugin_alias_entry custom_aliases[] = {
33+
{ FLB_PLUGIN_INPUT, "tailing", "tail" },
34+
{ FLB_PLUGIN_FILTER, "grepper", "grep" },
35+
{ FLB_PLUGIN_PROCESSOR, "countering", "content_modifier" },
36+
{ FLB_PLUGIN_OUTPUT, "elasticsearch", "es_custom" },
37+
{ 0, NULL, NULL }
38+
};
39+
3240
void plugin_alias_lookup_test()
3341
{
3442
const char *alias_target;
@@ -45,6 +53,35 @@ void plugin_alias_lookup_test()
4553
}
4654
}
4755

56+
void plugin_alias_custom_map_test()
57+
{
58+
const char *alias_target;
59+
60+
flb_plugin_alias_set_custom_entries(custom_aliases);
61+
62+
alias_target = flb_plugin_alias_get(FLB_PLUGIN_INPUT, "tailing",
63+
strlen("tailing"));
64+
TEST_CHECK(alias_target != NULL);
65+
TEST_CHECK(strcmp(alias_target, "tail") == 0);
66+
67+
alias_target = flb_plugin_alias_get(FLB_PLUGIN_FILTER, "grepper",
68+
strlen("grepper"));
69+
TEST_CHECK(alias_target != NULL);
70+
TEST_CHECK(strcmp(alias_target, "grep") == 0);
71+
72+
alias_target = flb_plugin_alias_get(FLB_PLUGIN_OUTPUT, "elasticsearch",
73+
strlen("elasticsearch"));
74+
TEST_CHECK(alias_target != NULL);
75+
TEST_CHECK(strcmp(alias_target, "es_custom") == 0);
76+
77+
flb_plugin_alias_reset_custom_entries();
78+
79+
alias_target = flb_plugin_alias_get(FLB_PLUGIN_OUTPUT, "elasticsearch",
80+
strlen("elasticsearch"));
81+
TEST_CHECK(alias_target != NULL);
82+
TEST_CHECK(strcmp(alias_target, "es") == 0);
83+
}
84+
4885
void plugin_alias_rewrite_test()
4986
{
5087
char *rewritten_name;
@@ -123,6 +160,7 @@ void output_alias_instantiation_test()
123160

124161
TEST_LIST = {
125162
{ "plugin_alias_lookup_test", plugin_alias_lookup_test },
163+
{ "plugin_alias_custom_map_test", plugin_alias_custom_map_test },
126164
{ "plugin_alias_rewrite_test", plugin_alias_rewrite_test },
127165
{ "network_alias_address_parse_test", network_alias_address_parse_test },
128166
{ "output_alias_instantiation_test", output_alias_instantiation_test },

0 commit comments

Comments
 (0)