Skip to content

Commit

Permalink
Merge pull request #52 from input-output-hk/load_tests
Browse files Browse the repository at this point in the history
Backend Load tests
  • Loading branch information
dkijania authored Mar 2, 2021
2 parents e5ed3d0 + db4a1d0 commit b80c0b6
Show file tree
Hide file tree
Showing 11 changed files with 483 additions and 405 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ commands:
environment:
RUST_BACKTRACE: 1
command: |
cargo test -- --test-threads=1
cargo test --release -- --test-threads=1
workflows:
version: 2
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ cfg-if = "1.0.0"
assert_fs = "1.0"

[features]
non-functional = []
load-tests = []
soak-tests = []
9 changes: 8 additions & 1 deletion integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cfg_if::cfg_if! {
if #[cfg(test)] {
pub mod setup;
pub mod public;
#[cfg(feature = "non-functional")]
pub mod private;
pub mod non_functional;
}
}
Expand All @@ -24,3 +24,10 @@ pub enum Error {
#[error("iapyx error")]
IapyxError(#[from] iapyx::ControllerError),
}

#[allow(dead_code)]
pub enum Vote {
BLANK = 0,
YES = 1,
NO = 2,
}
132 changes: 132 additions & 0 deletions integration-tests/src/non_functional/load.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
use crate::non_functional::build_load_config;
use crate::non_functional::private_vote_test_scenario;
use crate::setup::vitup_setup;
use assert_fs::TempDir;
use iapyx::{IapyxLoad, Protocol};
use jormungandr_testing_utils::testing::node::time;
use jortestkit::measurement::Status;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::scenario::network::setup_network;
use vitup::setup::start::quick::QuickVitBackendSettingsBuilder;

#[tokio::test]
pub async fn load_test_public_100_000_votes() {
let testing_directory = TempDir::new().unwrap().into_persistent();
let endpoint = "127.0.0.1:8080";

let no_of_votes = 100_000;
let no_of_threads = 10;
let no_of_wallets = 4_000;

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_start_epoch(0)
.tally_start_epoch(3)
.tally_end_epoch(4)
.slot_duration_in_seconds(2)
.slots_in_epoch_count(60)
.proposals_count(250)
.voting_power(31_000)
.private(false);

let mut template_generator = ArbitraryValidVotingTemplateGenerator::new();
let (mut vit_controller, mut controller, vit_parameters, fund_name) =
vitup_setup(quick_setup, testing_directory.path().to_path_buf());

let (nodes, vit_station, wallet_proxy) = setup_network(
&mut controller,
&mut vit_controller,
vit_parameters,
&mut template_generator,
endpoint.to_string(),
&Protocol::Http,
)
.unwrap();

let mut qr_codes_folder = testing_directory.path().to_path_buf();
qr_codes_folder.push("vit_backend/qr-codes");

let config = build_load_config(endpoint, qr_codes_folder, no_of_threads, no_of_votes);
let iapyx_load = IapyxLoad::new(config);
if let Some(benchmark) = iapyx_load.start().unwrap() {
assert!(benchmark.status() == Status::Green, "too low efficiency");
}

println!(
"{:?}",
nodes
.get(0)
.unwrap()
.explorer()
.status()
.unwrap()
.data
.unwrap()
.status
);

time::wait_for_epoch(10, nodes.get(0).unwrap().explorer());

let mut committee = controller.wallet("committee").unwrap();
let vote_plan = controller.vote_plan(&fund_name).unwrap();

controller
.fragment_sender()
.send_public_vote_tally(&mut committee, &vote_plan.into(), nodes.get(0).unwrap())
.unwrap();

vit_station.shutdown();
wallet_proxy.shutdown();
for node in nodes {
node.logger()
.assert_no_errors(&format!("Errors in logs for node: {}", node.alias()));
node.shutdown().unwrap();
}

controller.finalize();
}

#[tokio::test]
pub async fn load_test_private_pesimistic() {
let no_of_votes = 30_000;
let no_of_threads = 10;
let no_of_wallets = 4_000;
let endpoint = "127.0.0.1:8080";

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_start_epoch(0)
.tally_start_epoch(3)
.tally_end_epoch(4)
.slot_duration_in_seconds(2)
.slots_in_epoch_count(60)
.proposals_count(250)
.voting_power(31_000)
.private(true);

private_vote_test_scenario(quick_setup, endpoint, no_of_votes, no_of_threads);
}

#[tokio::test]
pub async fn load_test_private_optimistic() {
let no_of_votes = 100_000;
let no_of_threads = 10;
let no_of_wallets = 20_000;
let endpoint = "127.0.0.1:8080";

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_start_epoch(0)
.tally_start_epoch(6)
.tally_end_epoch(7)
.slot_duration_in_seconds(2)
.slots_in_epoch_count(60)
.proposals_count(250)
.voting_power(31_000)
.private(true);

private_vote_test_scenario(quick_setup, endpoint, no_of_votes, no_of_threads);
}
223 changes: 0 additions & 223 deletions integration-tests/src/non_functional/load_test.rs

This file was deleted.

Loading

0 comments on commit b80c0b6

Please sign in to comment.