@@ -676,9 +676,9 @@ void flb_test_in_tail_skip_long_lines()
676676 unlink (path );
677677}
678678
679- /*
679+ /*
680680 * test case for https://github.com/fluent/fluent-bit/issues/3943
681- *
681+ *
682682 * test to read the lines "CRLF + empty_line + LF"
683683 */
684684void flb_test_in_tail_issue_3943 ()
@@ -1312,6 +1312,76 @@ void flb_test_ignore_older()
13121312 }
13131313}
13141314
1315+ void flb_test_in_tail_ignore_active_older_files ()
1316+ {
1317+ struct flb_lib_out_cb cb_data ;
1318+ struct test_tail_ctx * ctx ;
1319+ char * file [] = {"source_file.log" };
1320+ char * path = "source_file.log" ;
1321+ char * msg = "TEST LINE" ;
1322+ const int expected = 1 ;
1323+ int ret ;
1324+ int num ;
1325+ int unused ;
1326+
1327+ clear_output_num ();
1328+
1329+ cb_data .cb = cb_count_msgpack ;
1330+ cb_data .data = & unused ;
1331+
1332+ ctx = test_tail_ctx_create (& cb_data , & file [0 ], sizeof (file )/sizeof (char * ), FLB_TRUE );
1333+ if (!TEST_CHECK (ctx != NULL )) {
1334+ TEST_MSG ("test_ctx_create failed" );
1335+ return ;
1336+ }
1337+
1338+ ret = flb_input_set (ctx -> flb , ctx -> o_ffd ,
1339+ "path" , path ,
1340+ "ignore_older" , "2s" ,
1341+ "read_from_head" , "on" ,
1342+ "ignore_active_older_files" , "on" ,
1343+ NULL );
1344+ TEST_CHECK (ret == 0 );
1345+
1346+ /* Start the engine */
1347+ ret = flb_start (ctx -> flb );
1348+
1349+ if (!TEST_CHECK (ret == 0 )) {
1350+ test_tail_ctx_destroy (ctx );
1351+
1352+ return ;
1353+ }
1354+
1355+ ret = write_msg (ctx , msg , strlen (msg ));
1356+
1357+ if (!TEST_CHECK (ret > 0 )) {
1358+ test_tail_ctx_destroy (ctx );
1359+
1360+ return ;
1361+ }
1362+
1363+ /* waiting to flush */
1364+ flb_time_msleep (6000 );
1365+
1366+ ret = write_msg (ctx , msg , strlen (msg ));
1367+
1368+ if (!TEST_CHECK (ret > 0 )) {
1369+ test_tail_ctx_destroy (ctx );
1370+
1371+ return ;
1372+ }
1373+
1374+ /* waiting to flush */
1375+ flb_time_msleep (1500 );
1376+
1377+ num = get_output_num ();
1378+ if (!TEST_CHECK (num == expected )) {
1379+ TEST_MSG ("output num error. expect=%d got=%d" , expected , num );
1380+ }
1381+
1382+ test_tail_ctx_destroy (ctx );
1383+ }
1384+
13151385void flb_test_inotify_watcher_false ()
13161386{
13171387 struct flb_lib_out_cb cb_data ;
@@ -1695,7 +1765,7 @@ void flb_test_db_delete_stale_file()
16951765
16961766 /*
16971767 * Changing the file name from 'test_db_stale.log' to
1698- * 'test_db_stale_new.log.' In this scenario, it is assumed that the
1768+ * 'test_db_stale_new.log.' In this scenario, it is assumed that the
16991769 * file was deleted after the FluentBit was terminated. However, since
17001770 * the FluentBit was shutdown, the inode remains in the database.
17011771 * The reason for renaming is to preserve the existing file for later use.
@@ -1792,7 +1862,7 @@ void flb_test_db_delete_stale_file()
17921862
17931863 num = get_output_num ();
17941864 if (!TEST_CHECK (num == 3 )) {
1795- /* 3 =
1865+ /* 3 =
17961866 * test_db.log : "hello db end"
17971867 * test_db_stale.log : "msg_init" + "hello db end"
17981868 */
@@ -1963,6 +2033,7 @@ TEST_LIST = {
19632033 {"skip_empty_lines" , flb_test_skip_empty_lines },
19642034 {"skip_empty_lines_crlf" , flb_test_skip_empty_lines_crlf },
19652035 {"ignore_older" , flb_test_ignore_older },
2036+ {"ignore_active_older_files" , flb_test_in_tail_ignore_active_older_files },
19662037#ifdef FLB_HAVE_INOTIFY
19672038 {"inotify_watcher_false" , flb_test_inotify_watcher_false },
19682039#endif /* FLB_HAVE_INOTIFY */
0 commit comments