LCOV - code coverage report
Current view: top level - pageserver/pagebench/src/util/cli - targets.rs (source / functions) Coverage Total Hit
Test: b9d67f908f91f00e353a27440ba89f642a869959.info Lines: 0.0 % 18 0
Test Date: 2024-11-19 21:44:13 Functions: 0.0 % 2 0

            Line data    Source code
       1              : use std::sync::Arc;
       2              : 
       3              : use pageserver_client::mgmt_api;
       4              : use tracing::info;
       5              : use utils::id::TenantTimelineId;
       6              : 
       7              : pub(crate) struct Spec {
       8              :     pub(crate) limit_to_first_n_targets: Option<usize>,
       9              :     pub(crate) targets: Option<Vec<TenantTimelineId>>,
      10              : }
      11              : 
      12            0 : pub(crate) async fn discover(
      13            0 :     api_client: &Arc<mgmt_api::Client>,
      14            0 :     spec: Spec,
      15            0 : ) -> anyhow::Result<Vec<TenantTimelineId>> {
      16            0 :     let mut timelines = if let Some(targets) = spec.targets {
      17            0 :         targets
      18              :     } else {
      19            0 :         mgmt_api::util::get_pageserver_tenant_timelines_unsharded(api_client).await?
      20              :     };
      21              : 
      22            0 :     if let Some(limit) = spec.limit_to_first_n_targets {
      23            0 :         timelines.sort(); // for determinism
      24            0 :         timelines.truncate(limit);
      25            0 :         if timelines.len() < limit {
      26            0 :             anyhow::bail!("pageserver has less than limit_to_first_n_targets={limit} tenants");
      27            0 :         }
      28            0 :     }
      29              : 
      30            0 :     info!("timelines:\n{:?}", timelines);
      31            0 :     info!("number of timelines:\n{:?}", timelines.len());
      32              : 
      33            0 :     Ok(timelines)
      34            0 : }
        

Generated by: LCOV version 2.1-beta