@@ -549,6 +549,70 @@ void flb_test_selector_substring_exclude(void)
549
549
flb_destroy (ctx );
550
550
}
551
551
552
+ void flb_test_selector_can_modify_output (void )
553
+ {
554
+ int ret ;
555
+ flb_ctx_t * ctx ;
556
+ int in_ffd ;
557
+ int out_ffd ;
558
+ struct flb_processor * proc ;
559
+ struct flb_processor_unit * pu ;
560
+ struct cfl_variant var = {
561
+ .type = CFL_VARIANT_STRING ,
562
+ .data .as_string = "/kubernetes/" ,
563
+ };
564
+ struct cfl_variant action = {
565
+ .type = CFL_VARIANT_STRING ,
566
+ .data .as_string = "include" ,
567
+ };
568
+
569
+ ctx = flb_create ();
570
+ flb_service_set (ctx ,
571
+ "Flush" , "0.200000000" ,
572
+ "Grace" , "2" ,
573
+ NULL );
574
+
575
+ proc = flb_processor_create (ctx -> config , "unit_test" , NULL , 0 );
576
+ TEST_CHECK (proc != NULL );
577
+
578
+ pu = flb_processor_unit_create (proc , FLB_PROCESSOR_METRICS , "metrics_selector" );
579
+ TEST_CHECK (pu != NULL );
580
+ ret = flb_processor_unit_set_property (pu , "metric_name" , & var );
581
+ TEST_CHECK (ret == 0 );
582
+ ret = flb_processor_unit_set_property (pu , "action" , & action );
583
+ TEST_CHECK (ret == 0 );
584
+
585
+ /* Input */
586
+ in_ffd = flb_input (ctx , (char * ) "event_type" , NULL );
587
+ TEST_CHECK (in_ffd >= 0 );
588
+ ret = flb_input_set (ctx , in_ffd , "tag" , "test" , NULL );
589
+ TEST_CHECK (ret == 0 );
590
+ ret = flb_input_set (ctx , in_ffd , "type" , "metrics" , NULL );
591
+ TEST_CHECK (ret == 0 );
592
+ ret = flb_input_set (ctx , in_ffd , "interval_sec" , "1" , NULL );
593
+ TEST_CHECK (ret == 0 );
594
+
595
+ out_ffd = flb_output (ctx , (char * ) "stdout" , NULL );
596
+ TEST_CHECK (out_ffd >= 0 );
597
+ ret = flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
598
+ TEST_CHECK (ret == 0 );
599
+ ret = flb_output_set (ctx , out_ffd , "format" , "msgpack" , NULL );
600
+ TEST_CHECK (ret == 0 );
601
+
602
+ /* set up processor */
603
+ ret = flb_output_set_processor (ctx , out_ffd , proc );
604
+ TEST_CHECK (ret == 0 );
605
+
606
+ clear_output_num ();
607
+
608
+ ret = flb_start (ctx );
609
+ TEST_CHECK (ret == 0 );
610
+
611
+ flb_time_msleep (1500 ); /* waiting flush */
612
+
613
+ flb_stop (ctx );
614
+ flb_destroy (ctx );
615
+ }
552
616
#endif
553
617
554
618
/* Test list */
@@ -560,6 +624,7 @@ TEST_LIST = {
560
624
{"prefix_exclude" , flb_test_selector_prefix_exclude },
561
625
{"substring_include" , flb_test_selector_substring_include },
562
626
{"substring_exclude" , flb_test_selector_substring_exclude },
627
+ {"can_modify_output" , flb_test_selector_can_modify_output },
563
628
#endif
564
629
{NULL , NULL }
565
630
};
0 commit comments