@@ -284,12 +284,52 @@ static struct http_monitor_test_stats_event s_test_rw_above_events[] = {
284284 .expected_throughput = 1000 ,
285285 },
286286};
287+
288+ struct observer_cb_data {
289+ bool invoked ;
290+ size_t nonce ;
291+ size_t number_of_stats ;
292+ struct aws_crt_statistics_socket socket_stats ;
293+ struct aws_crt_statistics_http1_channel http_stats ;
294+ };
295+ static void s_observer_cb (size_t connection_nonce , const struct aws_array_list * stats , void * user_data ) {
296+ struct observer_cb_data * cb_data = user_data ;
297+ cb_data -> invoked = true;
298+ cb_data -> nonce = connection_nonce ;
299+ cb_data -> number_of_stats = aws_array_list_length (stats );
300+
301+ for (size_t i = 0 ; i < cb_data -> number_of_stats ; ++ i ) {
302+ struct aws_crt_statistics_base * base_ptr = NULL ;
303+ aws_array_list_get_at (stats , (void * * )& base_ptr , i );
304+
305+ if (base_ptr -> category == AWSCRT_STAT_CAT_SOCKET ) {
306+ cb_data -> socket_stats = * (struct aws_crt_statistics_socket * )base_ptr ;
307+ }
308+
309+ if (base_ptr -> category == AWSCRT_STAT_CAT_HTTP1_CHANNEL ) {
310+ cb_data -> http_stats = * (struct aws_crt_statistics_http1_channel * )base_ptr ;
311+ }
312+ }
313+ }
287314static int s_test_http_connection_monitor_rw_above (struct aws_allocator * allocator , void * ctx ) {
288315 (void )ctx ;
289316
317+ struct observer_cb_data cb_data ;
318+ AWS_ZERO_STRUCT (cb_data );
319+ s_test_options .statistics_observer_fn = s_observer_cb ;
320+ s_test_options .statistics_observer_user_data = & cb_data ;
290321 int result = s_do_http_monitoring_test (
291322 allocator , & s_test_options , s_test_rw_above_events , AWS_ARRAY_SIZE (s_test_rw_above_events ));
292323 ASSERT_TRUE (result == AWS_OP_SUCCESS );
324+ ASSERT_TRUE (cb_data .invoked );
325+ ASSERT_TRUE (cb_data .nonce > 0 );
326+ ASSERT_UINT_EQUALS (2U , cb_data .number_of_stats );
327+ ASSERT_UINT_EQUALS (s_test_rw_above_events [0 ].socket_stats .bytes_written , cb_data .socket_stats .bytes_written );
328+ ASSERT_UINT_EQUALS (s_test_rw_above_events [0 ].socket_stats .bytes_read , cb_data .socket_stats .bytes_read );
329+ ASSERT_UINT_EQUALS (
330+ s_test_rw_above_events [0 ].http_stats .current_outgoing_stream_id , cb_data .http_stats .current_outgoing_stream_id );
331+ ASSERT_UINT_EQUALS (
332+ s_test_rw_above_events [0 ].http_stats .current_incoming_stream_id , cb_data .http_stats .current_incoming_stream_id );
293333
294334 return AWS_OP_SUCCESS ;
295335}
0 commit comments