Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3081 from input-output-hk/reorganize_voting_load_…
…tests [Tests] Reorganize voting load tests
- Loading branch information
Showing
10 changed files
with
732 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
193 changes: 2 additions & 191 deletions
193
testing/jormungandr-integration-tests/src/non_functional/voting/private/load.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,197 +1,8 @@ | ||
use crate::common::jormungandr::{ConfigurationBuilder, Starter}; | ||
use crate::non_functional::voting::config::PrivateVotingLoadTestConfig; | ||
use assert_fs::TempDir; | ||
use chain_core::property::BlockDate; | ||
use chain_impl_mockchain::testing::data::CommitteeMembersManager; | ||
use chain_impl_mockchain::{ | ||
certificate::{VoteAction, VoteTallyPayload}, | ||
ledger::governance::TreasuryGovernanceAction, | ||
testing::decrypt_tally, | ||
value::Value, | ||
}; | ||
use jormungandr_lib::interfaces::BlockDate as BlockDateLib; | ||
use jormungandr_testing_utils::testing::VoteCastsGenerator; | ||
use jormungandr_testing_utils::testing::{ | ||
benchmark_consumption, FragmentStatusProvider, VotePlanBuilder, | ||
}; | ||
use jormungandr_testing_utils::{ | ||
testing::{ | ||
node::time::{wait_for_date, wait_for_epoch}, | ||
vote_plan_cert, FragmentSender, FragmentSenderSetup, | ||
}, | ||
wallet::Wallet, | ||
}; | ||
use jortestkit::{load, measurement::Status}; | ||
use rand::rngs::OsRng; | ||
use crate::non_functional::voting::private::private_vote_load_scenario; | ||
use crate::non_functional::voting::private::PrivateVotingLoadTestConfig; | ||
|
||
#[test] | ||
pub fn private_vote_load_quick_test() { | ||
let quick_config = PrivateVotingLoadTestConfig::quick(); | ||
private_vote_load_scenario(quick_config) | ||
} | ||
|
||
#[test] | ||
pub fn private_vote_load_long_test() { | ||
let quick_config = PrivateVotingLoadTestConfig::long(); | ||
private_vote_load_scenario(quick_config) | ||
} | ||
|
||
pub fn private_vote_load_scenario(quick_config: PrivateVotingLoadTestConfig) { | ||
let temp_dir = TempDir::new().unwrap().into_persistent(); | ||
let mut rng = OsRng; | ||
let members = CommitteeMembersManager::new( | ||
&mut rng, | ||
quick_config.tally_threshold(), | ||
quick_config.members_count(), | ||
); | ||
|
||
let committee_keys = members | ||
.members() | ||
.iter() | ||
.map(|committee_member| committee_member.public_key()) | ||
.collect::<Vec<_>>(); | ||
|
||
let voters: Vec<Wallet> = std::iter::from_fn(|| Some(Wallet::new_account(&mut rng))) | ||
.take(quick_config.wallets_count()) | ||
.collect(); | ||
|
||
let mut rng = OsRng; | ||
let mut committee = Wallet::new_account(&mut rng); | ||
|
||
let vote_plan = VotePlanBuilder::new() | ||
.proposals_count(quick_config.proposals_count()) | ||
.action_type(VoteAction::Treasury { | ||
action: TreasuryGovernanceAction::TransferToRewards { | ||
value: Value(quick_config.rewards_increase()), | ||
}, | ||
}) | ||
.with_vote_start(BlockDate::from_epoch_slot_id( | ||
quick_config.voting_timing()[0].into(), | ||
0, | ||
)) | ||
.with_tally_start(BlockDate::from_epoch_slot_id( | ||
quick_config.voting_timing()[1].into(), | ||
0, | ||
)) | ||
.with_tally_end(BlockDate::from_epoch_slot_id( | ||
quick_config.voting_timing()[2].into(), | ||
0, | ||
)) | ||
.private() | ||
.member_public_keys(committee_keys) | ||
.build(); | ||
|
||
let vote_plan_cert = vote_plan_cert(&committee, &vote_plan).into(); | ||
|
||
let config = ConfigurationBuilder::new() | ||
.with_fund(committee.to_initial_fund(quick_config.initial_fund_per_wallet())) | ||
.with_funds_split_if_needed( | ||
voters | ||
.iter() | ||
.map(|x| x.to_initial_fund(quick_config.initial_fund_per_wallet())) | ||
.collect(), | ||
) | ||
.with_committees(&[&committee.clone()]) | ||
.with_slots_per_epoch(quick_config.slots_in_epoch()) | ||
.with_certs(vec![vote_plan_cert]) | ||
.with_explorer() | ||
.with_slot_duration(quick_config.slot_duration()) | ||
.with_block_content_max_size(quick_config.block_content_max_size()) | ||
.with_treasury(1_000.into()) | ||
.build(&temp_dir); | ||
|
||
let jormungandr = Starter::new().config(config.clone()).start().unwrap(); | ||
|
||
let transaction_sender = FragmentSender::new( | ||
jormungandr.genesis_block_hash(), | ||
jormungandr.fees(), | ||
FragmentSenderSetup::no_verify(), | ||
); | ||
|
||
let benchmark_consumption_monitor = benchmark_consumption(&quick_config.measurement_name()) | ||
.target(quick_config.target_resources_usage()) | ||
.for_process("Node", jormungandr.pid() as usize) | ||
.start_async(std::time::Duration::from_secs(30)); | ||
|
||
let votes_generator = VoteCastsGenerator::new( | ||
voters, | ||
vote_plan.clone(), | ||
jormungandr.to_remote(), | ||
transaction_sender.clone(), | ||
); | ||
|
||
let stats = load::start_async( | ||
votes_generator, | ||
FragmentStatusProvider::new(jormungandr.to_remote()), | ||
quick_config.configuration(), | ||
&quick_config.measurement_name(), | ||
); | ||
|
||
stats.print_summary(&quick_config.measurement_name()); | ||
assert_eq!( | ||
stats | ||
.measure( | ||
&quick_config.measurement_name(), | ||
quick_config.tx_target_success_rate() | ||
) | ||
.status(), | ||
Status::Green | ||
); | ||
|
||
wait_for_epoch( | ||
quick_config.voting_timing()[1].into(), | ||
jormungandr.explorer().clone(), | ||
); | ||
|
||
transaction_sender | ||
.send_encrypted_tally(&mut committee, &vote_plan, &jormungandr) | ||
.unwrap(); | ||
|
||
wait_for_date( | ||
BlockDateLib::new( | ||
quick_config.voting_timing()[1].into(), | ||
(quick_config.slots_in_epoch() / 2).into(), | ||
), | ||
jormungandr.explorer().clone(), | ||
); | ||
|
||
let active_vote_plans = jormungandr.rest().vote_plan_statuses().unwrap(); | ||
let vote_plan_status = active_vote_plans | ||
.iter() | ||
.find(|c_vote_plan| c_vote_plan.id == vote_plan.to_id().into()) | ||
.unwrap(); | ||
|
||
let shares = decrypt_tally(&vote_plan_status.clone().into(), &members); | ||
|
||
transaction_sender | ||
.send_vote_tally( | ||
&mut committee, | ||
&vote_plan, | ||
&jormungandr, | ||
VoteTallyPayload::Private { inner: shares }, | ||
) | ||
.unwrap(); | ||
|
||
wait_for_epoch( | ||
quick_config.voting_timing()[2].into(), | ||
jormungandr.explorer().clone(), | ||
); | ||
let active_vote_plans = jormungandr.rest().vote_plan_statuses().unwrap(); | ||
|
||
let vote_plan_status = active_vote_plans | ||
.iter() | ||
.find(|c_vote_plan| c_vote_plan.id == vote_plan.to_id().into()) | ||
.unwrap(); | ||
|
||
for proposal in vote_plan_status.proposals.iter() { | ||
assert!( | ||
proposal.tally.is_some(), | ||
"Proposal is not tallied {:?}", | ||
proposal | ||
); | ||
} | ||
|
||
benchmark_consumption_monitor.stop(); | ||
|
||
jormungandr.assert_no_errors_in_log(); | ||
} |
Oops, something went wrong.