Cleanup snapshot integration tests (#26390)
This commit is contained in:
parent
95ae82e074
commit
9ec38a3191
|
@ -4981,6 +4981,7 @@ dependencies = [
|
||||||
"sysctl",
|
"sysctl",
|
||||||
"systemstat",
|
"systemstat",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"test-case",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"trees",
|
"trees",
|
||||||
|
@ -6810,6 +6811,28 @@ version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
|
checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "196e8a70562e252cc51eaaaee3ecddc39803d9b7fd4a772b7c7dae7cdf42a859"
|
||||||
|
dependencies = [
|
||||||
|
"test-case-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case-macros"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8dd461f47ade621665c9f4e44b20449341769911c253275dc5cb03726cbb852c"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2 1.0.38",
|
||||||
|
"quote 1.0.18",
|
||||||
|
"syn 1.0.93",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
|
|
@ -74,6 +74,7 @@ solana-program-runtime = { path = "../program-runtime", version = "=1.11.2" }
|
||||||
solana-stake-program = { path = "../programs/stake", version = "=1.11.2" }
|
solana-stake-program = { path = "../programs/stake", version = "=1.11.2" }
|
||||||
static_assertions = "1.1.0"
|
static_assertions = "1.1.0"
|
||||||
systemstat = "0.1.11"
|
systemstat = "0.1.11"
|
||||||
|
test-case = "2.1.0"
|
||||||
|
|
||||||
[target."cfg(unix)".dependencies]
|
[target."cfg(unix)".dependencies]
|
||||||
sysctl = "0.4.4"
|
sysctl = "0.4.4"
|
||||||
|
|
|
@ -1,50 +1,5 @@
|
||||||
// Long-running bank_forks tests
|
|
||||||
#![allow(clippy::integer_arithmetic)]
|
#![allow(clippy::integer_arithmetic)]
|
||||||
|
|
||||||
macro_rules! DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS {
|
|
||||||
($x:ident, $y:ident, $z:ident) => {
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
mod $z {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
const SNAPSHOT_VERSION: SnapshotVersion = SnapshotVersion::$x;
|
|
||||||
const CLUSTER_TYPE: ClusterType = ClusterType::$y;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_bank_forks_status_cache_snapshot_n() {
|
|
||||||
run_test_bank_forks_status_cache_snapshot_n(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_bank_forks_snapshot_n() {
|
|
||||||
run_test_bank_forks_snapshot_n(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_concurrent_snapshot_packaging() {
|
|
||||||
run_test_concurrent_snapshot_packaging(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_slots_to_snapshot() {
|
|
||||||
run_test_slots_to_snapshot(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_bank_forks_incremental_snapshot_n() {
|
|
||||||
run_test_bank_forks_incremental_snapshot_n(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_snapshots_with_background_services() {
|
|
||||||
run_test_snapshots_with_background_services(SNAPSHOT_VERSION, CLUSTER_TYPE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use {
|
use {
|
||||||
bincode::serialize_into,
|
bincode::serialize_into,
|
||||||
crossbeam_channel::unbounded,
|
crossbeam_channel::unbounded,
|
||||||
|
@ -58,8 +13,7 @@ mod tests {
|
||||||
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
|
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts_background_service::{
|
accounts_background_service::{
|
||||||
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService,
|
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
|
||||||
SnapshotRequestHandler,
|
|
||||||
},
|
},
|
||||||
accounts_db::{self, ACCOUNTS_DB_CONFIG_FOR_TESTING},
|
accounts_db::{self, ACCOUNTS_DB_CONFIG_FOR_TESTING},
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes,
|
||||||
|
@ -72,12 +26,18 @@ mod tests {
|
||||||
AccountsPackage, PendingAccountsPackage, PendingSnapshotPackage, SnapshotPackage,
|
AccountsPackage, PendingAccountsPackage, PendingSnapshotPackage, SnapshotPackage,
|
||||||
SnapshotType,
|
SnapshotType,
|
||||||
},
|
},
|
||||||
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
|
snapshot_utils::{
|
||||||
|
self, ArchiveFormat,
|
||||||
|
SnapshotVersion::{self, V1_2_0},
|
||||||
|
},
|
||||||
status_cache::MAX_CACHE_ENTRIES,
|
status_cache::MAX_CACHE_ENTRIES,
|
||||||
},
|
},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
clock::Slot,
|
clock::Slot,
|
||||||
genesis_config::{ClusterType, GenesisConfig},
|
genesis_config::{
|
||||||
|
ClusterType::{self, Development, Devnet, MainnetBeta, Testnet},
|
||||||
|
GenesisConfig,
|
||||||
|
},
|
||||||
hash::{hashv, Hash},
|
hash::{hashv, Hash},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
|
@ -97,13 +57,9 @@ mod tests {
|
||||||
time::Duration,
|
time::Duration,
|
||||||
},
|
},
|
||||||
tempfile::TempDir,
|
tempfile::TempDir,
|
||||||
|
test_case::test_case,
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Development, V1_2_0_Development);
|
|
||||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Devnet, V1_2_0_Devnet);
|
|
||||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Testnet, V1_2_0_Testnet);
|
|
||||||
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, MainnetBeta, V1_2_0_MainnetBeta);
|
|
||||||
|
|
||||||
struct SnapshotTestConfig {
|
struct SnapshotTestConfig {
|
||||||
accounts_dir: TempDir,
|
accounts_dir: TempDir,
|
||||||
bank_snapshots_dir: TempDir,
|
bank_snapshots_dir: TempDir,
|
||||||
|
@ -278,8 +234,7 @@ mod tests {
|
||||||
let last_bank = bank_forks.get(last_slot).unwrap();
|
let last_bank = bank_forks.get(last_slot).unwrap();
|
||||||
let snapshot_config = &snapshot_test_config.snapshot_config;
|
let snapshot_config = &snapshot_test_config.snapshot_config;
|
||||||
let bank_snapshots_dir = &snapshot_config.bank_snapshots_dir;
|
let bank_snapshots_dir = &snapshot_config.bank_snapshots_dir;
|
||||||
let last_bank_snapshot_info =
|
let last_bank_snapshot_info = snapshot_utils::get_highest_bank_snapshot_pre(bank_snapshots_dir)
|
||||||
snapshot_utils::get_highest_bank_snapshot_pre(bank_snapshots_dir)
|
|
||||||
.expect("no bank snapshots found in path");
|
.expect("no bank snapshots found in path");
|
||||||
let slot_deltas = last_bank.status_cache.read().unwrap().root_slot_deltas();
|
let slot_deltas = last_bank.status_cache.read().unwrap().root_slot_deltas();
|
||||||
let accounts_package = AccountsPackage::new(
|
let accounts_package = AccountsPackage::new(
|
||||||
|
@ -301,8 +256,7 @@ mod tests {
|
||||||
accounts_package.slot,
|
accounts_package.slot,
|
||||||
&last_bank.get_accounts_hash(),
|
&last_bank.get_accounts_hash(),
|
||||||
);
|
);
|
||||||
let snapshot_package =
|
let snapshot_package = SnapshotPackage::new(accounts_package, last_bank.get_accounts_hash());
|
||||||
SnapshotPackage::new(accounts_package, last_bank.get_accounts_hash());
|
|
||||||
snapshot_utils::archive_snapshot_package(
|
snapshot_utils::archive_snapshot_package(
|
||||||
&snapshot_package,
|
&snapshot_package,
|
||||||
&snapshot_config.full_snapshot_archives_dir,
|
&snapshot_config.full_snapshot_archives_dir,
|
||||||
|
@ -318,10 +272,11 @@ mod tests {
|
||||||
restore_from_snapshot(bank_forks, last_slot, genesis_config, account_paths);
|
restore_from_snapshot(bank_forks, last_slot, genesis_config, account_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test_bank_forks_snapshot_n(
|
#[test_case(V1_2_0, Development)]
|
||||||
snapshot_version: SnapshotVersion,
|
#[test_case(V1_2_0, Devnet)]
|
||||||
cluster_type: ClusterType,
|
#[test_case(V1_2_0, Testnet)]
|
||||||
) {
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_bank_forks_snapshot(snapshot_version: SnapshotVersion, cluster_type: ClusterType) {
|
||||||
// create banks up to slot 4 and create 1 new account in each bank. test that bank 4 snapshots
|
// create banks up to slot 4 and create 1 new account in each bank. test that bank 4 snapshots
|
||||||
// and restores correctly
|
// and restores correctly
|
||||||
run_bank_forks_snapshot_n(
|
run_bank_forks_snapshot_n(
|
||||||
|
@ -330,13 +285,11 @@ mod tests {
|
||||||
4,
|
4,
|
||||||
|bank, mint_keypair| {
|
|bank, mint_keypair| {
|
||||||
let key1 = Keypair::new().pubkey();
|
let key1 = Keypair::new().pubkey();
|
||||||
let tx =
|
let tx = system_transaction::transfer(mint_keypair, &key1, 1, bank.last_blockhash());
|
||||||
system_transaction::transfer(mint_keypair, &key1, 1, bank.last_blockhash());
|
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
|
|
||||||
let key2 = Keypair::new().pubkey();
|
let key2 = Keypair::new().pubkey();
|
||||||
let tx =
|
let tx = system_transaction::transfer(mint_keypair, &key2, 0, bank.last_blockhash());
|
||||||
system_transaction::transfer(mint_keypair, &key2, 0, bank.last_blockhash());
|
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
|
|
||||||
bank.freeze();
|
bank.freeze();
|
||||||
|
@ -357,7 +310,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test_concurrent_snapshot_packaging(
|
#[test_case(V1_2_0, Development)]
|
||||||
|
#[test_case(V1_2_0, Devnet)]
|
||||||
|
#[test_case(V1_2_0, Testnet)]
|
||||||
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_concurrent_snapshot_packaging(
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
cluster_type: ClusterType,
|
cluster_type: ClusterType,
|
||||||
) {
|
) {
|
||||||
|
@ -587,7 +544,11 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test_slots_to_snapshot(snapshot_version: SnapshotVersion, cluster_type: ClusterType) {
|
#[test_case(V1_2_0, Development)]
|
||||||
|
#[test_case(V1_2_0, Devnet)]
|
||||||
|
#[test_case(V1_2_0, Testnet)]
|
||||||
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_slots_to_snapshot(snapshot_version: SnapshotVersion, cluster_type: ClusterType) {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let num_set_roots = MAX_CACHE_ENTRIES * 2;
|
let num_set_roots = MAX_CACHE_ENTRIES * 2;
|
||||||
|
|
||||||
|
@ -606,16 +567,13 @@ mod tests {
|
||||||
for _ in 0..num_set_roots {
|
for _ in 0..num_set_roots {
|
||||||
for _ in 0..*add_root_interval {
|
for _ in 0..*add_root_interval {
|
||||||
let new_slot = current_bank.slot() + 1;
|
let new_slot = current_bank.slot() + 1;
|
||||||
let new_bank =
|
let new_bank = Bank::new_from_parent(¤t_bank, &Pubkey::default(), new_slot);
|
||||||
Bank::new_from_parent(¤t_bank, &Pubkey::default(), new_slot);
|
|
||||||
snapshot_test_config.bank_forks.insert(new_bank);
|
snapshot_test_config.bank_forks.insert(new_bank);
|
||||||
current_bank = snapshot_test_config.bank_forks[new_slot].clone();
|
current_bank = snapshot_test_config.bank_forks[new_slot].clone();
|
||||||
}
|
}
|
||||||
snapshot_test_config.bank_forks.set_root(
|
snapshot_test_config
|
||||||
current_bank.slot(),
|
.bank_forks
|
||||||
&request_sender,
|
.set_root(current_bank.slot(), &request_sender, None);
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let num_old_slots = num_set_roots * *add_root_interval - MAX_CACHE_ENTRIES + 1;
|
let num_old_slots = num_set_roots * *add_root_interval - MAX_CACHE_ENTRIES + 1;
|
||||||
|
@ -637,7 +595,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test_bank_forks_status_cache_snapshot_n(
|
#[test_case(V1_2_0, Development)]
|
||||||
|
#[test_case(V1_2_0, Devnet)]
|
||||||
|
#[test_case(V1_2_0, Testnet)]
|
||||||
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_bank_forks_status_cache_snapshot(
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
cluster_type: ClusterType,
|
cluster_type: ClusterType,
|
||||||
) {
|
) {
|
||||||
|
@ -674,7 +636,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test_bank_forks_incremental_snapshot_n(
|
#[test_case(V1_2_0, Development)]
|
||||||
|
#[test_case(V1_2_0, Devnet)]
|
||||||
|
#[test_case(V1_2_0, Testnet)]
|
||||||
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_bank_forks_incremental_snapshot(
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
cluster_type: ClusterType,
|
cluster_type: ClusterType,
|
||||||
) {
|
) {
|
||||||
|
@ -748,8 +714,7 @@ mod tests {
|
||||||
|
|
||||||
// Since AccountsBackgroundService isn't running, manually make a full snapshot archive
|
// Since AccountsBackgroundService isn't running, manually make a full snapshot archive
|
||||||
// at the right interval
|
// at the right interval
|
||||||
if snapshot_utils::should_take_full_snapshot(slot, FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS)
|
if snapshot_utils::should_take_full_snapshot(slot, FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS) {
|
||||||
{
|
|
||||||
make_full_snapshot_archive(&bank, &snapshot_test_config.snapshot_config).unwrap();
|
make_full_snapshot_archive(&bank, &snapshot_test_config.snapshot_config).unwrap();
|
||||||
}
|
}
|
||||||
// Similarly, make an incremental snapshot archive at the right interval, but only if
|
// Similarly, make an incremental snapshot archive at the right interval, but only if
|
||||||
|
@ -882,7 +847,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spin up the background services fully and test taking snapshots
|
/// Spin up the background services fully and test taking snapshots
|
||||||
fn run_test_snapshots_with_background_services(
|
#[test_case(V1_2_0, Development)]
|
||||||
|
#[test_case(V1_2_0, Devnet)]
|
||||||
|
#[test_case(V1_2_0, Testnet)]
|
||||||
|
#[test_case(V1_2_0, MainnetBeta)]
|
||||||
|
fn test_snapshots_with_background_services(
|
||||||
snapshot_version: SnapshotVersion,
|
snapshot_version: SnapshotVersion,
|
||||||
cluster_type: ClusterType,
|
cluster_type: ClusterType,
|
||||||
) {
|
) {
|
||||||
|
@ -893,8 +862,8 @@ mod tests {
|
||||||
const INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS: Slot = BANK_SNAPSHOT_INTERVAL_SLOTS * 3;
|
const INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS: Slot = BANK_SNAPSHOT_INTERVAL_SLOTS * 3;
|
||||||
const FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS: Slot =
|
const FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS: Slot =
|
||||||
INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 5;
|
INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 5;
|
||||||
const LAST_SLOT: Slot = FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 3
|
const LAST_SLOT: Slot =
|
||||||
+ INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 2;
|
FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 3 + INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS * 2;
|
||||||
|
|
||||||
info!("Running snapshots with background services test...");
|
info!("Running snapshots with background services test...");
|
||||||
trace!(
|
trace!(
|
||||||
|
@ -1030,7 +999,9 @@ mod tests {
|
||||||
// NOTE: The 5 seconds of sleeping is arbitrary. This should be plenty of time since the
|
// NOTE: The 5 seconds of sleeping is arbitrary. This should be plenty of time since the
|
||||||
// snapshots should be quite small. If this test fails at `unwrap()` or because the bank
|
// snapshots should be quite small. If this test fails at `unwrap()` or because the bank
|
||||||
// slots do not match, increase this sleep duration.
|
// slots do not match, increase this sleep duration.
|
||||||
info!("Sleeping for 5 seconds to give background services time to process snapshot archives...");
|
info!(
|
||||||
|
"Sleeping for 5 seconds to give background services time to process snapshot archives..."
|
||||||
|
);
|
||||||
std::thread::sleep(Duration::from_secs(5));
|
std::thread::sleep(Duration::from_secs(5));
|
||||||
info!("Awake! Rebuilding bank from latest snapshot archives...");
|
info!("Awake! Rebuilding bank from latest snapshot archives...");
|
||||||
|
|
||||||
|
@ -1076,4 +1047,3 @@ mod tests {
|
||||||
accounts_hash_verifier.join().unwrap();
|
accounts_hash_verifier.join().unwrap();
|
||||||
snapshot_packager_service.join().unwrap();
|
snapshot_packager_service.join().unwrap();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue