Move test_purge_huge test (#23587)
* ignore test_purge_huge tests it is expensive. * move test_purge to integration tests
This commit is contained in:
parent
ddd9d5a5a5
commit
83f5f8bfc3
|
@ -4387,6 +4387,99 @@ pub fn make_many_slot_entries(
|
|||
(shreds, entries)
|
||||
}
|
||||
|
||||
// test-only: check that all columns are either empty or start at `min_slot`
|
||||
pub fn test_all_empty_or_min(blockstore: &Blockstore, min_slot: Slot) {
|
||||
let condition_met = blockstore
|
||||
.db
|
||||
.iter::<cf::SlotMeta>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Root>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ShredData>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ShredCode>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::DeadSlots>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::DuplicateSlots>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ErasureMeta>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Orphans>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Index>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::TransactionStatus>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((primary_index, _, slot), _)| {
|
||||
slot >= min_slot || (primary_index == 2 && slot == 0)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::AddressSignatures>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((primary_index, _, slot, _), _)| {
|
||||
slot >= min_slot || (primary_index == 2 && slot == 0)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Rewards>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true);
|
||||
assert!(condition_met);
|
||||
}
|
||||
|
||||
// used for tests only
|
||||
// Create `num_shreds` shreds for [start_slot, start_slot + num_slot) slots
|
||||
pub fn make_many_slot_shreds(
|
||||
|
|
|
@ -426,99 +426,6 @@ pub mod tests {
|
|||
},
|
||||
};
|
||||
|
||||
// check that all columns are either empty or start at `min_slot`
|
||||
fn test_all_empty_or_min(blockstore: &Blockstore, min_slot: Slot) {
|
||||
let condition_met = blockstore
|
||||
.db
|
||||
.iter::<cf::SlotMeta>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Root>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ShredData>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ShredCode>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::DeadSlots>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::DuplicateSlots>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::ErasureMeta>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((slot, _), _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Orphans>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Index>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::TransactionStatus>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((primary_index, _, slot), _)| {
|
||||
slot >= min_slot || (primary_index == 2 && slot == 0)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::AddressSignatures>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|((primary_index, _, slot, _), _)| {
|
||||
slot >= min_slot || (primary_index == 2 && slot == 0)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
& blockstore
|
||||
.db
|
||||
.iter::<cf::Rewards>(IteratorMode::Start)
|
||||
.unwrap()
|
||||
.next()
|
||||
.map(|(slot, _)| slot >= min_slot)
|
||||
.unwrap_or(true);
|
||||
assert!(condition_met);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_purge_slots() {
|
||||
let ledger_path = get_tmp_ledger_path_auto_delete!();
|
||||
|
@ -545,18 +452,6 @@ pub mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_purge_huge() {
|
||||
let ledger_path = get_tmp_ledger_path_auto_delete!();
|
||||
let blockstore = Blockstore::open(ledger_path.path()).unwrap();
|
||||
|
||||
let (shreds, _) = make_many_slot_entries(0, 5000, 10);
|
||||
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||
|
||||
blockstore.purge_and_compact_slots(0, 4999);
|
||||
test_all_empty_or_min(&blockstore, 5000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_purge_front_of_ledger() {
|
||||
let ledger_path = get_tmp_ledger_path_auto_delete!();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
solana_entry::entry,
|
||||
solana_ledger::{
|
||||
blockstore::{self, Blockstore},
|
||||
blockstore::{self, make_many_slot_entries, test_all_empty_or_min, Blockstore},
|
||||
get_tmp_ledger_path_auto_delete,
|
||||
},
|
||||
solana_sdk::hash::Hash,
|
||||
|
@ -46,3 +46,15 @@ fn test_multiple_threads_insert_shred() {
|
|||
blockstore.purge_and_compact_slots(0, num_threads + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_purge_huge() {
|
||||
let ledger_path = get_tmp_ledger_path_auto_delete!();
|
||||
let blockstore = Blockstore::open(ledger_path.path()).unwrap();
|
||||
|
||||
let (shreds, _) = make_many_slot_entries(0, 5000, 10);
|
||||
blockstore.insert_shreds(shreds, None, false).unwrap();
|
||||
|
||||
blockstore.purge_and_compact_slots(0, 4999);
|
||||
test_all_empty_or_min(&blockstore, 5000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue