Skip to content

Commit

Permalink
[forge] Add tests for validation set changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zcchahaha committed Sep 20, 2022
1 parent 4d29ede commit 023620c
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/aptos/Cargo.toml
Expand Up @@ -66,6 +66,7 @@ storage-interface = { path = "../../storage/storage-interface" }
default = []
fuzzing = []
no-upload-proposal = []
cli-framework-test-move = []

[build-dependencies]
shadow-rs = "0.16.2"
7 changes: 7 additions & 0 deletions crates/aptos/src/test/mod.rs
Expand Up @@ -16,7 +16,10 @@ use crate::common::types::{
MovePackageDir, OptionalPoolAddressArgs, PrivateKeyInputOptions, PromptOptions,
PublicKeyInputOptions, RestOptions, RngArgs, SaveFile, TransactionOptions, TransactionSummary,
};

#[cfg(feature = "cli-framework-test-move")]
use crate::common::utils::write_to_file;

use crate::move_tool::{
ArgWithType, CompilePackage, DownloadPackage, IncludedArtifacts, InitPackage, MemberId,
PublishPackage, RunFunction, TestPackage,
Expand Down Expand Up @@ -49,7 +52,10 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use std::{collections::BTreeMap, mem, path::PathBuf, str::FromStr, time::Duration};

#[cfg(feature = "cli-framework-test-move")]
use thiserror::private::PathAsDisplay;

use tokio::time::{sleep, Instant};

#[cfg(test)]
Expand Down Expand Up @@ -662,6 +668,7 @@ impl CliTestFramework {
self.move_dir = Some(move_dir.path().to_path_buf());
}

#[cfg(feature = "cli-framework-test-move")]
pub fn add_move_files(&self) {
let move_dir = self.move_dir();
let sources_dir = move_dir.join("sources");
Expand Down
20 changes: 20 additions & 0 deletions testsuite/forge-cli/src/main.rs
Expand Up @@ -21,6 +21,7 @@ use testcases::network_loss_test::NetworkLossTest;
use testcases::performance_with_fullnode_test::PerformanceBenchmarkWithFN;
use testcases::state_sync_performance::StateSyncValidatorPerformance;
use testcases::three_region_simulation_test::ThreeRegionSimulationTest;
use testcases::validator_join_leave_test::ValidatorJoinLeaveTest;
use testcases::validator_reboot_stress_test::ValidatorRebootStressTest;
use testcases::{
compatibility_test::SimpleValidatorUpgrade, forge_setup_test::ForgeSetupTest, generate_traffic,
Expand Down Expand Up @@ -437,6 +438,7 @@ fn single_test_suite(test_name: &str) -> Result<ForgeConfig<'static>> {
state_sync_perf_fullnodes_execute_transactions(config)
}
"state_sync_perf_validators" => state_sync_perf_validators(config),
"validators_join_and_leave" => validators_join_and_leave(config),
"compat" => config
.with_initial_validator_count(NonZeroUsize::new(5).unwrap())
.with_network_tests(vec![&SimpleValidatorUpgrade])
Expand Down Expand Up @@ -727,6 +729,24 @@ fn state_sync_perf_validators(forge_config: ForgeConfig<'static>) -> ForgeConfig
.with_success_criteria(SuccessCriteria::new(5000, 10000, false, None, None, None))
}

/// The config for running a validator join and leave test.
fn validators_join_and_leave(forge_config: ForgeConfig<'static>) -> ForgeConfig<'static> {
forge_config
.with_initial_validator_count(NonZeroUsize::new(7).unwrap())
.with_genesis_helm_config_fn(Arc::new(|helm_values| {
helm_values["chain"]["epoch_duration_secs"] = 600.into();
}))
.with_network_tests(vec![&ValidatorJoinLeaveTest])
.with_success_criteria(SuccessCriteria::new(
5000,
10000,
false,
Some(Duration::from_secs(600)),
None,
None,
))
}

fn land_blocking_test_suite(duration: Duration) -> ForgeConfig<'static> {
ForgeConfig::default()
.with_initial_validator_count(NonZeroUsize::new(20).unwrap())
Expand Down
1 change: 1 addition & 0 deletions testsuite/smoke-test/src/aptos_cli/mod.rs
Expand Up @@ -2,5 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

mod account;
#[cfg(feature = "cli-framework-test-move")]
mod r#move;
mod validator;
18 changes: 12 additions & 6 deletions testsuite/testcases/Cargo.toml
Expand Up @@ -11,18 +11,24 @@ edition = "2021"

[dependencies]
anyhow = "1.0.57"
futures = "0.3.21"
rand = "0.7.3"
reqwest = { version = "0.11.10", features = ["json", "cookies", "blocking"] }
serde_json = "1.0.81"
tokio = { version = "1.21.0", features = ["full"] }
aptos = { path = "../../crates/aptos", features = ["fuzzing"] }

aptos = { path = "../../crates/aptos" }
aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] }
aptos-global-constants = { path = "../../config/global-constants" }
aptos-keygen = { path = "../../crates/aptos-keygen" }
aptos-logger = { path = "../../crates/aptos-logger" }
aptos-rest-client = { path = "../../crates/aptos-rest-client" }
aptos-sdk = { path = "../../sdk" }
aptos-types = { path = "../../types" }

forge = { path = "../forge" }
futures = "0.3.21"
hex = "0.4.3"
move-examples = { path = "../../aptos-move/move-examples" }
rand = "0.7.3"
reqwest = { version = "0.11.10", features = ["json", "cookies", "blocking"] }
serde_json = "1.0.81"
tokio = { version = "1.21.0", features = ["full"] }

[[test]]
name = "forge-local-compatibility"
Expand Down
3 changes: 2 additions & 1 deletion testsuite/testcases/src/lib.rs
Expand Up @@ -17,6 +17,7 @@ pub mod performance_with_fullnode_test;
pub mod reconfiguration_test;
pub mod state_sync_performance;
pub mod three_region_simulation_test;
pub mod validator_join_leave_test;
pub mod validator_reboot_stress_test;

use anyhow::{anyhow, ensure};
Expand Down Expand Up @@ -115,7 +116,7 @@ pub trait NetworkLoadTest: Test {
fn setup(&self, _ctx: &mut NetworkContext) -> Result<LoadDestination> {
Ok(LoadDestination::AllNodes)
}
// Load is started before this funciton is called, and stops after this function returns.
// Load is started before this function is called, and stops after this function returns.
// Expected duration is passed into this function, expecting this function to take that much
// time to finish. How long this function takes will dictate how long the actual test lasts.
fn test(&self, _swarm: &mut dyn Swarm, duration: Duration) -> Result<()> {
Expand Down

0 comments on commit 023620c

Please sign in to comment.