@@ -215,12 +215,54 @@ static void suppress_interval_shorter_than_cache_timeout()
215215 check_suppress_interval (3 , 1 , 2 , FLB_FALSE );
216216}
217217
218+ static void suppress_interval_preserved_during_cache_replacement ()
219+ {
220+ int ret ;
221+ struct flb_worker worker = {0 };
222+ struct flb_worker * previous_worker ;
223+ struct flb_log_cache_entry * entry ;
224+
225+ worker .log_cache = flb_log_cache_create (1 , 2 );
226+ TEST_CHECK (worker .log_cache != NULL );
227+ if (!worker .log_cache ) {
228+ return ;
229+ }
230+
231+ previous_worker = flb_worker_get ();
232+ FLB_TLS_SET (flb_worker_ctx , & worker );
233+
234+ ret = flb_log_suppress_check (3 , TEST_RECORD_01 );
235+ TEST_CHECK (ret == FLB_FALSE );
236+
237+ entry = flb_log_cache_exists (worker .log_cache ,
238+ TEST_RECORD_01 , TEST_RECORD_01_SIZE );
239+ TEST_CHECK (entry != NULL );
240+ if (entry ) {
241+ entry -> timestamp = time (NULL ) - 2 ;
242+ }
243+
244+ ret = flb_log_suppress_check (3 , TEST_RECORD_02 );
245+ TEST_CHECK (ret == FLB_FALSE );
246+
247+ entry = flb_log_cache_exists (worker .log_cache ,
248+ TEST_RECORD_02 , TEST_RECORD_02_SIZE );
249+ TEST_CHECK (entry != NULL );
250+
251+ ret = flb_log_suppress_check (3 , TEST_RECORD_01 );
252+ TEST_CHECK (ret == FLB_TRUE );
253+
254+ FLB_TLS_SET (flb_worker_ctx , previous_worker );
255+ flb_log_cache_destroy (worker .log_cache );
256+ }
257+
218258TEST_LIST = {
219259 { "cache_basic_timeout" , cache_basic_timeout },
220260 { "cache_one_slot" , cache_one_slot },
221261 { "suppress_interval_longer_than_cache_timeout" ,
222262 suppress_interval_longer_than_cache_timeout },
223263 { "suppress_interval_shorter_than_cache_timeout" ,
224264 suppress_interval_shorter_than_cache_timeout },
265+ { "suppress_interval_preserved_during_cache_replacement" ,
266+ suppress_interval_preserved_during_cache_replacement },
225267 { 0 }
226268};
0 commit comments