@@ -46,6 +46,52 @@ void flb_test_cloudwatch_success(void)
4646 flb_destroy (ctx );
4747}
4848
49+ /* It writes a json/emf formatted metrics */
50+ void flb_test_cloudwatch_success_with_metrics (void )
51+ {
52+ int ret ;
53+ flb_ctx_t * ctx ;
54+ int in_ffd ;
55+ int out_ffd ;
56+
57+ /* mocks calls- signals that we are in test mode */
58+ setenv ("FLB_CLOUDWATCH_PLUGIN_UNDER_TEST" , "true" , 1 );
59+
60+ ctx = flb_create ();
61+ flb_service_set (ctx ,
62+ "Flush" , "0.200000000" ,
63+ "Grace" , "1" ,
64+ NULL );
65+
66+ /* Input */
67+ in_ffd = flb_input (ctx , (char * ) "fluentbit_metrics" , NULL );
68+ TEST_CHECK (in_ffd >= 0 );
69+ ret = flb_input_set (ctx , in_ffd , "tag" , "test" , NULL );
70+ TEST_CHECK (ret == 0 );
71+ ret = flb_input_set (ctx , in_ffd , "scrape_on_start" , "true" , NULL );
72+ TEST_CHECK (ret == 0 );
73+ ret = flb_input_set (ctx , in_ffd , "scrape_interval" , "1" , NULL );
74+ TEST_CHECK (ret == 0 );
75+
76+ out_ffd = flb_output (ctx , (char * ) "cloudwatch_logs" , NULL );
77+ TEST_CHECK (out_ffd >= 0 );
78+ flb_output_set (ctx , out_ffd ,"match" , "test" , NULL );
79+ flb_output_set (ctx , out_ffd ,"region" , "us-west-2" , NULL );
80+ flb_output_set (ctx , out_ffd ,"log_format" , "json_emf" , NULL );
81+ flb_output_set (ctx , out_ffd ,"log_group_name" , "fluent-health" , NULL );
82+ flb_output_set (ctx , out_ffd ,"log_stream_prefix" , "from-cmetrics-" , NULL );
83+ flb_output_set (ctx , out_ffd ,"auto_create_group" , "On" , NULL );
84+ flb_output_set (ctx , out_ffd ,"net.keepalive" , "Off" , NULL );
85+ flb_output_set (ctx , out_ffd ,"Retry_Limit" , "1" , NULL );
86+
87+ ret = flb_start (ctx );
88+ TEST_CHECK (ret == 0 );
89+
90+ sleep (2 );
91+ flb_stop (ctx );
92+ flb_destroy (ctx );
93+ }
94+
4995void flb_test_cloudwatch_already_exists_create_group (void )
5096{
5197 int ret ;
@@ -350,6 +396,7 @@ void flb_test_cloudwatch_error_put_retention_policy(void)
350396/* Test list */
351397TEST_LIST = {
352398 {"success" , flb_test_cloudwatch_success },
399+ {"success_with_metrics" , flb_test_cloudwatch_success_with_metrics },
353400 {"group_already_exists" , flb_test_cloudwatch_already_exists_create_group },
354401 {"stream_already_exists" , flb_test_cloudwatch_already_exists_create_stream },
355402 {"create_group_error" , flb_test_cloudwatch_error_create_group },
0 commit comments