|
| 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