LCOV - code coverage report
Current view: top level - pageserver/ctl/src - index_part.rs (source / functions) Coverage Total Hit
Test: 32f4a56327bc9da697706839ed4836b2a00a408f.info Lines: 94.1 % 17 16
Test Date: 2024-02-07 07:37:29 Functions: 41.7 % 12 5

            Line data    Source code
       1              : use std::collections::HashMap;
       2              : 
       3              : use anyhow::Context;
       4              : use camino::Utf8PathBuf;
       5              : use pageserver::tenant::remote_timeline_client::index::IndexLayerMetadata;
       6              : use pageserver::tenant::storage_layer::LayerFileName;
       7              : use pageserver::tenant::{metadata::TimelineMetadata, IndexPart};
       8              : use utils::lsn::Lsn;
       9              : 
      10           12 : #[derive(clap::Subcommand)]
      11              : pub(crate) enum IndexPartCmd {
      12            0 :     Dump { path: Utf8PathBuf },
      13              : }
      14              : 
      15            6 : pub(crate) async fn main(cmd: &IndexPartCmd) -> anyhow::Result<()> {
      16            6 :     match cmd {
      17            6 :         IndexPartCmd::Dump { path } => {
      18            6 :             let bytes = tokio::fs::read(path).await.context("read file")?;
      19            6 :             let des: IndexPart = IndexPart::from_s3_bytes(&bytes).context("deserialize")?;
      20            6 :             #[derive(serde::Serialize)]
      21              :             struct Output<'a> {
      22              :                 layer_metadata: &'a HashMap<LayerFileName, IndexLayerMetadata>,
      23              :                 disk_consistent_lsn: Lsn,
      24              :                 timeline_metadata: &'a TimelineMetadata,
      25              :             }
      26              : 
      27            6 :             let output = Output {
      28            6 :                 layer_metadata: &des.layer_metadata,
      29            6 :                 disk_consistent_lsn: des.get_disk_consistent_lsn(),
      30            6 :                 timeline_metadata: &des.metadata,
      31            6 :             };
      32              : 
      33            6 :             let output = serde_json::to_string_pretty(&output).context("serialize output")?;
      34            6 :             println!("{output}");
      35            6 :             Ok(())
      36              :         }
      37              :     }
      38            6 : }
        

Generated by: LCOV version 2.1-beta