LCOV - code coverage report
Current view: top level - compute_tools/src/http/routes - failpoints.rs (source / functions) Coverage Total Hit
Test: 727bdccc1d7d53837da843959afb612f56da4e79.info Lines: 0.0 % 20 0
Test Date: 2025-01-30 15:18:43 Functions: 0.0 % 2 0

            Line data    Source code
       1              : use axum::response::{IntoResponse, Response};
       2              : use http::StatusCode;
       3              : use tracing::info;
       4              : use utils::failpoint_support::{apply_failpoint, ConfigureFailpointsRequest};
       5              : 
       6              : use crate::http::{extract::Json, JsonResponse};
       7              : 
       8              : /// Configure failpoints for testing purposes.
       9            0 : pub(in crate::http) async fn configure_failpoints(
      10            0 :     failpoints: Json<ConfigureFailpointsRequest>,
      11            0 : ) -> Response {
      12            0 :     if !fail::has_failpoints() {
      13            0 :         return JsonResponse::error(
      14            0 :             StatusCode::PRECONDITION_FAILED,
      15            0 :             "Cannot manage failpoints because neon was compiled without failpoints support",
      16            0 :         );
      17            0 :     }
      18              : 
      19            0 :     for fp in &*failpoints {
      20            0 :         info!("cfg failpoint: {} {}", fp.name, fp.actions);
      21              : 
      22              :         // We recognize one extra "action" that's not natively recognized
      23              :         // by the failpoints crate: exit, to immediately kill the process
      24            0 :         let cfg_result = apply_failpoint(&fp.name, &fp.actions);
      25              : 
      26            0 :         if let Err(e) = cfg_result {
      27            0 :             return JsonResponse::error(
      28            0 :                 StatusCode::BAD_REQUEST,
      29            0 :                 format!("failed to configure failpoints: {e}"),
      30            0 :             );
      31            0 :         }
      32              :     }
      33              : 
      34            0 :     StatusCode::OK.into_response()
      35            0 : }
        

Generated by: LCOV version 2.1-beta