Add snapshot compression option (#9276)

This commit is contained in:
sakridge
2020-04-03 13:13:49 -07:00
committed by GitHub
parent 175ffd9054
commit 9493de4443
14 changed files with 228 additions and 70 deletions

View File

@ -170,6 +170,7 @@ mod tests {
use super::*;
use crate::cluster_info::make_accounts_hashes_message;
use crate::contact_info::ContactInfo;
use solana_ledger::bank_forks::CompressionType;
use solana_sdk::{
hash::hash,
signature::{Keypair, Signer},
@ -231,6 +232,7 @@ mod tests {
snapshot_links,
tar_output_file: PathBuf::from("."),
storages: vec![],
compression: CompressionType::Bzip2,
};
AccountsHashVerifier::process_snapshot(

View File

@ -43,8 +43,10 @@ impl RpcRequestMiddleware {
pub fn new(ledger_path: PathBuf, snapshot_config: Option<SnapshotConfig>) -> Self {
Self {
ledger_path,
snapshot_archive_path_regex: Regex::new(r"/snapshot-\d+-[[:alnum:]]+\.tar\.bz2$")
.unwrap(),
snapshot_archive_path_regex: Regex::new(
r"/snapshot-\d+-[[:alnum:]]+\.tar\.(bz2|zst|gz)$",
)
.unwrap(),
snapshot_config,
}
}
@ -249,6 +251,7 @@ impl JsonRpcService {
mod tests {
use super::*;
use crate::{contact_info::ContactInfo, rpc::tests::create_validator_exit};
use solana_ledger::bank_forks::CompressionType;
use solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
@ -319,6 +322,7 @@ mod tests {
snapshot_interval_slots: 0,
snapshot_package_output_path: PathBuf::from("/"),
snapshot_path: PathBuf::from("/"),
compression: CompressionType::Bzip2,
}),
);

View File

@ -84,6 +84,7 @@ impl SnapshotPackagerService {
mod tests {
use super::*;
use bincode::serialize_into;
use solana_ledger::bank_forks::CompressionType;
use solana_ledger::{
snapshot_package::SnapshotPackage,
snapshot_utils::{self, SNAPSHOT_STATUS_CACHE_FILE_NAME},
@ -169,6 +170,7 @@ mod tests {
let output_tar_path = snapshot_utils::get_snapshot_archive_path(
&snapshot_package_output_path,
&(42, Hash::default()),
&CompressionType::Bzip2,
);
let snapshot_package = SnapshotPackage::new(
5,
@ -177,6 +179,7 @@ mod tests {
vec![storage_entries],
output_tar_path.clone(),
Hash::default(),
CompressionType::Bzip2,
);
// Make tarball from packageable snapshot
@ -197,6 +200,11 @@ mod tests {
.unwrap();
// Check archive is correct
snapshot_utils::verify_snapshot_archive(output_tar_path, snapshots_dir, accounts_dir);
snapshot_utils::verify_snapshot_archive(
output_tar_path,
snapshots_dir,
accounts_dir,
CompressionType::Bzip2,
);
}
}

View File

@ -8,6 +8,7 @@ mod tests {
use solana_core::cluster_info::ClusterInfo;
use solana_core::contact_info::ContactInfo;
use solana_core::snapshot_packager_service::SnapshotPackagerService;
use solana_ledger::bank_forks::CompressionType;
use solana_ledger::{
bank_forks::{BankForks, SnapshotConfig},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
@ -54,6 +55,7 @@ mod tests {
snapshot_interval_slots,
snapshot_package_output_path: PathBuf::from(snapshot_output_path.path()),
snapshot_path: PathBuf::from(snapshot_dir.path()),
compression: CompressionType::Bzip2,
};
bank_forks.set_snapshot_config(Some(snapshot_config.clone()));
SnapshotTestConfig {
@ -90,7 +92,9 @@ mod tests {
snapshot_utils::get_snapshot_archive_path(
snapshot_package_output_path,
&(old_last_bank.slot(), old_last_bank.get_accounts_hash()),
&CompressionType::Bzip2,
),
CompressionType::Bzip2,
)
.unwrap();
@ -152,6 +156,7 @@ mod tests {
&last_bank.src.roots(),
&snapshot_config.snapshot_package_output_path,
storages,
CompressionType::Bzip2,
)
.unwrap();
@ -290,6 +295,7 @@ mod tests {
saved_archive_path = Some(snapshot_utils::get_snapshot_archive_path(
&snapshot_config.snapshot_package_output_path,
&(slot, accounts_hash),
&CompressionType::Bzip2,
));
}
}
@ -352,6 +358,7 @@ mod tests {
saved_accounts_dir
.path()
.join(accounts_dir.path().file_name().unwrap()),
CompressionType::Bzip2,
);
}