@@ -180,6 +180,61 @@ static void flb_test_matched()
180
180
filter_test_destroy (ctx );
181
181
}
182
182
183
+ /*
184
+ * Original tag: rewrite
185
+ * Rewritten tag: updated
186
+ */
187
+ static void flb_test_ring_buffer ()
188
+ {
189
+ struct flb_lib_out_cb cb_data ;
190
+ struct filter_test * ctx ;
191
+ int ret ;
192
+ int not_used = 0 ;
193
+ int bytes ;
194
+ int got ;
195
+ char * p = "[0, {\"key\":\"rewrite\"}]" ;
196
+
197
+ /* Prepare output callback with expected result */
198
+ cb_data .cb = cb_count_msgpack ;
199
+ cb_data .data = & not_used ;
200
+
201
+ /* Create test context */
202
+ ctx = filter_test_create ((void * ) & cb_data );
203
+ if (!ctx ) {
204
+ exit (EXIT_FAILURE );
205
+ }
206
+ clear_output_num ();
207
+ /* Configure filter */
208
+ ret = flb_filter_set (ctx -> flb , ctx -> f_ffd ,
209
+ "emitter_ring_buffer_size" , "128" ,
210
+ "Rule" , "$key ^(rewrite)$ updated false" ,
211
+ NULL );
212
+ TEST_CHECK (ret == 0 );
213
+
214
+ /* Configure output */
215
+ ret = flb_output_set (ctx -> flb , ctx -> o_ffd ,
216
+ "Match" , "updated" ,
217
+ NULL );
218
+ TEST_CHECK (ret == 0 );
219
+
220
+ /* Start the engine */
221
+ ret = flb_start (ctx -> flb );
222
+ TEST_CHECK (ret == 0 );
223
+
224
+ /* ingest record */
225
+ bytes = flb_lib_push (ctx -> flb , ctx -> i_ffd , p , strlen (p ));
226
+ TEST_CHECK (bytes == strlen (p ));
227
+
228
+ flb_time_msleep (1500 ); /* waiting flush */
229
+ got = get_output_num ();
230
+
231
+ if (!TEST_CHECK (got != 0 )) {
232
+ TEST_MSG ("expect: %d got: %d" , 1 , got );
233
+ }
234
+
235
+ filter_test_destroy (ctx );
236
+ }
237
+
183
238
/*
184
239
* Original tag: rewrite
185
240
* Rewritten tag: updated
@@ -556,6 +611,7 @@ TEST_LIST = {
556
611
{"matched" , flb_test_matched },
557
612
{"not_matched" , flb_test_not_matched },
558
613
{"keep_true" , flb_test_keep_true },
614
+ {"ring_buffer" , flb_test_ring_buffer },
559
615
{"heavy_input_pause_emitter" , flb_test_heavy_input_pause_emitter },
560
616
{"issue_4518" , flb_test_issue_4518 },
561
617
{"issue_4793" , flb_test_issue_4793 },
0 commit comments