Skip to content

Commit a5b565f

Browse files
nokute78edsiper
authored andcommitted
tests: runtime: filter_record_modifier: add test
Signed-off-by: Takahiro Yamashita <[email protected]>
1 parent dfdb9d0 commit a5b565f

File tree

2 files changed

+80
-8
lines changed

2 files changed

+80
-8
lines changed

tests/runtime/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ endif()
3333

3434
# Filter Plugins
3535
if(FLB_IN_LIB AND FLB_OUT_LIB)
36-
FLB_RT_TEST(FLB_FILTER_STDOUT "filter_stdout.c")
37-
FLB_RT_TEST(FLB_FILTER_GREP "filter_grep.c")
38-
FLB_RT_TEST(FLB_FILTER_THROTTLE "filter_throttle.c")
36+
FLB_RT_TEST(FLB_FILTER_STDOUT "filter_stdout.c")
37+
FLB_RT_TEST(FLB_FILTER_GREP "filter_grep.c")
38+
FLB_RT_TEST(FLB_FILTER_THROTTLE "filter_throttle.c")
3939
FLB_RT_TEST(FLB_FILTER_THROTTLE_SIZE "filter_throttle_size.c")
40-
FLB_RT_TEST(FLB_FILTER_NEST "filter_nest.c")
41-
FLB_RT_TEST(FLB_FILTER_KUBERNETES "filter_kubernetes.c")
42-
FLB_RT_TEST(FLB_FILTER_PARSER "filter_parser.c")
43-
FLB_RT_TEST(FLB_FILTER_MODIFY "filter_modify.c")
44-
FLB_RT_TEST(FLB_FILTER_LUA "filter_lua.c")
40+
FLB_RT_TEST(FLB_FILTER_NEST "filter_nest.c")
41+
FLB_RT_TEST(FLB_FILTER_KUBERNETES "filter_kubernetes.c")
42+
FLB_RT_TEST(FLB_FILTER_PARSER "filter_parser.c")
43+
FLB_RT_TEST(FLB_FILTER_MODIFY "filter_modify.c")
44+
FLB_RT_TEST(FLB_FILTER_LUA "filter_lua.c")
45+
FLB_RT_TEST(FLB_FILTER_RECORD_MODIFIER "filter_record_modifier.c")
4546
endif()
4647

4748

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Fluent Bit
4+
* ==========
5+
* Copyright (C) 2019-2021 The Fluent Bit Authors
6+
* Copyright (C) 2015-2018 Treasure Data Inc.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
#include <fluent-bit.h>
22+
#include <fluent-bit/flb_time.h>
23+
#include "flb_tests_runtime.h"
24+
#include "data/common/json_long.h" /* JSON_LONG */
25+
26+
/* https://github.com/fluent/fluent-bit/issues/3968 */
27+
void flb_test_json_long()
28+
{
29+
int ret;
30+
int size = sizeof(JSON_LONG) - 1;
31+
flb_ctx_t *ctx;
32+
int in_ffd;
33+
int out_ffd;
34+
int filter_ffd;
35+
36+
/* Create context, flush every second (some checks omitted here) */
37+
ctx = flb_create();
38+
flb_service_set(ctx, "flush", "1", "grace", "1",
39+
"log_level", "error",
40+
NULL);
41+
42+
/* Lib input mode */
43+
in_ffd = flb_input(ctx, (char *) "lib", NULL);
44+
flb_input_set(ctx, in_ffd, "tag", "test", NULL);
45+
TEST_CHECK(in_ffd >= 0);
46+
47+
out_ffd = flb_output(ctx, (char *) "null", NULL);
48+
TEST_CHECK(out_ffd >= 0);
49+
flb_output_set(ctx, out_ffd, "match", "test", NULL);
50+
51+
filter_ffd = flb_filter(ctx, (char *) "record_modifier", NULL);
52+
TEST_CHECK(filter_ffd >= 0);
53+
flb_filter_set(ctx, filter_ffd, "match", "test", NULL);
54+
55+
/* Start */
56+
ret = flb_start(ctx);
57+
TEST_CHECK(ret == 0);
58+
59+
/* Ingest data sample */
60+
flb_lib_push(ctx, in_ffd, (char *) JSON_LONG, size);
61+
62+
flb_time_msleep(1500); /* waiting flush */
63+
flb_stop(ctx);
64+
flb_destroy(ctx);
65+
}
66+
67+
/* test list */
68+
TEST_LIST = {
69+
{"json_long" , flb_test_json_long },
70+
{NULL, NULL}
71+
};

0 commit comments

Comments
 (0)