@@ -637,6 +637,70 @@ void flb_test_helloworld(void)
637637 flb_destroy (ctx );
638638}
639639
640+ void flb_test_dummy_flush_on_startup (void )
641+ {
642+ int ret ;
643+ flb_ctx_t * ctx ;
644+ int in_ffd ;
645+ int out_ffd ;
646+ int filter_ffd ;
647+ char * result ;
648+ struct flb_lib_out_cb cb_data ;
649+
650+ char * script_body = ""
651+ "function lua_main(tag, timestamp, record)\n"
652+ " record[\"check\"] = \"checkval\"\n"
653+ " return 2, timestamp, record\n"
654+ "end\n" ;
655+
656+ clear_output ();
657+
658+ ctx = flb_create ();
659+ flb_service_set (ctx , "flush" , FLUSH_INTERVAL , "grace" , "1" , NULL );
660+
661+ cb_data .cb = callback_test ;
662+ cb_data .data = NULL ;
663+
664+ ret = create_script (script_body , strlen (script_body ));
665+ TEST_CHECK (ret == 0 );
666+
667+ filter_ffd = flb_filter (ctx , (char * ) "lua" , NULL );
668+ TEST_CHECK (filter_ffd >= 0 );
669+ ret = flb_filter_set (ctx , filter_ffd ,
670+ "Match" , "*" ,
671+ "call" , "lua_main" ,
672+ "script" , TMP_LUA_PATH ,
673+ NULL );
674+ TEST_CHECK (ret == 0 );
675+
676+ in_ffd = flb_input (ctx , (char * ) "dummy" , NULL );
677+ TEST_CHECK (in_ffd >= 0 );
678+ flb_input_set (ctx , in_ffd , "tag" , "test" , NULL );
679+ flb_input_set (ctx , in_ffd , "flush_on_startup" , "true" , NULL );
680+ flb_input_set (ctx , in_ffd , "samples" , "1" , NULL );
681+
682+ out_ffd = flb_output (ctx , (char * ) "lib" , (void * ) & cb_data );
683+ TEST_CHECK (out_ffd >= 0 );
684+ flb_output_set (ctx , out_ffd ,
685+ "match" , "test" ,
686+ "format" , "json" ,
687+ NULL );
688+
689+ ret = flb_start (ctx );
690+ TEST_CHECK (ret == 0 );
691+
692+ wait_with_timeout (2000 , & output );
693+ TEST_CHECK (output != NULL );
694+ result = strstr (output , "\"check\":\"checkval\"" );
695+ TEST_CHECK (result != NULL );
696+
697+ flb_lib_free (output );
698+ delete_script ();
699+
700+ flb_stop (ctx );
701+ flb_destroy (ctx );
702+ }
703+
640704// https://github.com/fluent/fluent-bit/issues/3343
641705void flb_test_type_array_key (void )
642706{
@@ -1614,6 +1678,7 @@ void flb_test_group_lua_drop(void)
16141678
16151679TEST_LIST = {
16161680 {"hello_world" , flb_test_helloworld },
1681+ {"dummy_flush_on_startup" , flb_test_dummy_flush_on_startup },
16171682 {"append_tag" , flb_test_append_tag },
16181683 {"type_int_key" , flb_test_type_int_key },
16191684 {"type_int_key_multi" , flb_test_type_int_key_multi },
0 commit comments