@@ -167,7 +167,7 @@ static void cb_check_id_key(void *ctx, int ffd,
167167 flb_free (res_data );
168168}
169169
170- static void cb_check_target_index (void * ctx , int ffd ,
170+ static void cb_check_index_ra (void * ctx , int ffd ,
171171 int res_ret , void * res_data , size_t res_size ,
172172 void * data )
173173{
@@ -180,22 +180,6 @@ static void cb_check_target_index(void *ctx, int ffd,
180180 flb_free (res_data );
181181}
182182
183- static void cb_check_target_index_default (void * ctx , int ffd ,
184- int res_ret , void * res_data , size_t res_size ,
185- void * data )
186- {
187- char * p ;
188- char * out_js = res_data ;
189- char * index_line = "{\"create\":{\"_index\":\"default\",\"_type\":\"_doc\"}" ;
190-
191- p = strstr (out_js , index_line );
192- TEST_CHECK (p != NULL );
193- if (!TEST_CHECK (p != NULL )) {
194- TEST_MSG ("Got: %s" , out_js );
195- }
196- flb_free (res_data );
197- }
198-
199183void flb_test_write_operation_index ()
200184{
201185 int ret ;
@@ -828,51 +812,7 @@ void flb_test_logstash_prefix_separator()
828812 flb_destroy (ctx );
829813}
830814
831- void flb_test_target_index ()
832- {
833- int ret ;
834- int size = sizeof (JSON_ES ) - 1 ;
835- flb_ctx_t * ctx ;
836- int in_ffd ;
837- int out_ffd ;
838-
839- /* Create context, flush every second (some checks omitted here) */
840- ctx = flb_create ();
841- flb_service_set (ctx , "flush" , "1" , "grace" , "1" , NULL );
842-
843- /* Lib input mode */
844- in_ffd = flb_input (ctx , (char * ) "lib" , NULL );
845- flb_input_set (ctx , in_ffd , "tag" , "test" , NULL );
846-
847- /* Elasticsearch output */
848- out_ffd = flb_output (ctx , (char * ) "es" , NULL );
849- flb_output_set (ctx , out_ffd ,
850- "match" , "test" ,
851- NULL );
852-
853- /* Override defaults of index and type */
854- flb_output_set (ctx , out_ffd ,
855- "target_index" , "aaa-$END_KEY" ,
856- NULL );
857-
858- /* Enable test mode */
859- ret = flb_output_set_test (ctx , out_ffd , "formatter" ,
860- cb_check_target_index ,
861- NULL , NULL );
862-
863- /* Start */
864- ret = flb_start (ctx );
865- TEST_CHECK (ret == 0 );
866-
867- /* Ingest data sample */
868- flb_lib_push (ctx , in_ffd , (char * ) JSON_ES , size );
869-
870- sleep (2 );
871- flb_stop (ctx );
872- flb_destroy (ctx );
873- }
874-
875- void flb_test_target_index_default ()
815+ void flb_test_index_ra ()
876816{
877817 int ret ;
878818 int size = sizeof (JSON_ES ) - 1 ;
@@ -896,13 +836,12 @@ void flb_test_target_index_default()
896836
897837 /* Override defaults of index and type */
898838 flb_output_set (ctx , out_ffd ,
899- "target_index" , "aaa-$not_found_key" ,
900- "index" , "default" ,
839+ "index" , "aaa-$END_KEY" ,
901840 NULL );
902841
903842 /* Enable test mode */
904843 ret = flb_output_set_test (ctx , out_ffd , "formatter" ,
905- cb_check_target_index_default ,
844+ cb_check_index_ra ,
906845 NULL , NULL );
907846
908847 /* Start */
@@ -926,13 +865,12 @@ TEST_LIST = {
926865 {"write_operation_update" , flb_test_write_operation_update },
927866 {"write_operation_upsert" , flb_test_write_operation_upsert },
928867 {"index_type" , flb_test_index_type },
868+ {"index_ra" , flb_test_index_ra },
929869 {"logstash_format" , flb_test_logstash_format },
930870 {"logstash_format_nanos" , flb_test_logstash_format_nanos },
931871 {"tag_key" , flb_test_tag_key },
932872 {"replace_dots" , flb_test_replace_dots },
933873 {"id_key" , flb_test_id_key },
934874 {"logstash_prefix_separator" , flb_test_logstash_prefix_separator },
935- {"target_index" , flb_test_target_index },
936- {"target_index_default" , flb_test_target_index_default },
937875 {NULL , NULL }
938876};
0 commit comments