TEST(Outputs, json_es) {
    int ret;
    int size = sizeof(JSON_ES) - 1;
    flb_ctx_t *ctx;
    flb_input_t *input;
    flb_output_t *output;

    ctx = flb_create();
    EXPECT_TRUE(ctx != NULL);

    input = flb_input(ctx, (char *) "lib", NULL);
    EXPECT_TRUE(input != NULL);
    flb_input_set(input, "tag", "test");

    output = flb_output(ctx, (char *) "es", NULL);
    EXPECT_TRUE(output != NULL);
    flb_output_set(output, "tag", "test");

    ret = flb_start(ctx);
    EXPECT_EQ(ret, 0);

    flb_lib_push(input, (char *) JSON_ES, size);

    flb_stop(ctx);
    flb_destroy(ctx);
}
TEST(Outputs, json_invalid) {
    int i;
    int ret;
    int total;
    int bytes;
    char *p = (char *) JSON_INVALID;
    flb_ctx_t *ctx;
    flb_input_t *input;
    flb_output_t *output;

    ctx = flb_create();

    input = flb_input(ctx, (char *) "lib", NULL);
    EXPECT_TRUE(input != NULL);
    flb_input_set(input, "tag", "test");

    output = flb_output(ctx, (char *) "stdout", NULL);
    EXPECT_TRUE(output != NULL);
    flb_output_set(output, "tag", "test");

    ret = flb_start(ctx);
    EXPECT_EQ(ret, 0);

    total = 0;
    for (i = 0; i < (int) sizeof(JSON_INVALID) - 1; i++) {
        bytes = flb_lib_push(input, p + i, 1);
        EXPECT_EQ(bytes, 1);
        total++;
    }

    flb_stop(ctx);
    flb_destroy(ctx);
}
Example #3
0
/* It writes a big JSON message (> 3.5MB) */
TEST(TD, json_long) {
    int ret;
    struct flb_lib_ctx *ctx;

    ctx = flb_lib_init(NULL, (char *) "td", NULL);
    EXPECT_TRUE(ctx != NULL);

    flb_config_verbose(FLB_TRUE);
    ret = flb_lib_config_file(ctx, (char *) "/tmp/td.conf");

    ret = flb_lib_start(ctx);
    EXPECT_EQ(ret, 0);

    flb_lib_push(ctx, (char *) JSON_TD , (int) sizeof(JSON_TD) - 1);
    flb_lib_stop(ctx);
    flb_lib_exit(ctx);
}