LCOV - code coverage report
Current view: top level - pageserver/ctl/src - index_part.rs (source / functions) Coverage Total Hit
Test: 691a4c28fe7169edd60b367c52d448a0a6605f1f.info Lines: 0.0 % 16 0
Test Date: 2024-05-10 13:18:37 Functions: 0.0 % 11 0

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

Generated by: LCOV version 2.1-beta