Skip to content

Commit

Permalink
An end-to-end test for the benchmark command. (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
afck authored Jan 24, 2024
1 parent f267285 commit 26764c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run the benchmark test
run: |
cargo build --locked -p linera-service --bin linera-benchmark --features benchmark
cargo test --locked -p linera-service --features benchmark test_end_to_end_fungible_benchmark
cargo test --locked -p linera-service --features benchmark benchmark
- name: Build Wasm test runner
# use debug mode to avoid building wasmtime in release mode
run: |
Expand Down
4 changes: 1 addition & 3 deletions linera-execution/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ pub enum SystemExecutionError {
IncorrectTransferAmount,
#[error("Transfer from owned account must be authenticated by the right signer")]
UnauthenticatedTransferOwner,
#[error(
"The transferred amount must be not exceed the current chain balance: {current_balance}"
)]
#[error("The transferred amount must not exceed the current chain balance: {current_balance}")]
InsufficientFunding { current_balance: Amount },
#[error("Claim must have positive amount")]
IncorrectClaimAmount,
Expand Down
7 changes: 4 additions & 3 deletions linera-service/src/cli_wrappers/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,13 @@ impl ClientWrapper {
}

/// Runs `linera benchmark`.
#[cfg(benchmark)]
async fn benchmark(&self, max_in_flight: usize) -> Result<()> {
#[cfg(feature = "benchmark")]
pub async fn benchmark(&self, max_in_flight: usize, num_chains: usize) -> Result<()> {
self.command()
.await
.await?
.arg("benchmark")
.args(["--max-in-flight", &max_in_flight.to_string()])
.args(["--num-chains", &num_chains.to_string()])
.spawn_and_wait_for_stdout()
.await?;
Ok(())
Expand Down
30 changes: 24 additions & 6 deletions linera-service/tests/end_to_end_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,12 +1398,6 @@ async fn test_end_to_end_reconfiguration(config: LocalNetTestingConfig) {
Amount::from_tokens(3)
);

#[cfg(benchmark)]
{
// Launch local benchmark using all user chains
client.benchmark(500).await;
}

// Create derived chain
let (_, chain_3) = client
.open_chain(chain_1, None, Amount::ZERO)
Expand Down Expand Up @@ -2214,3 +2208,27 @@ async fn test_end_to_end_retry_pending_block(config: LocalNetTestingConfig) {
net.ensure_is_running().await.unwrap();
net.terminate().await.unwrap();
}

#[cfg(feature = "benchmark")]
#[cfg_attr(feature = "rocksdb", test_case(LocalNetTestingConfig::new(Database::RocksDb, Network::Grpc) ; "rocksdb_grpc"))]
#[cfg_attr(feature = "scylladb", test_case(LocalNetTestingConfig::new(Database::ScyllaDb, Network::Grpc) ; "scylladb_grpc"))]
#[cfg_attr(feature = "aws", test_case(LocalNetTestingConfig::new(Database::DynamoDb, Network::Grpc) ; "aws_grpc"))]
#[cfg_attr(feature = "rocksdb", test_case(LocalNetTestingConfig::new(Database::RocksDb, Network::Tcp) ; "rocksdb_tcp"))]
#[cfg_attr(feature = "scylladb", test_case(LocalNetTestingConfig::new(Database::ScyllaDb, Network::Tcp) ; "scylladb_tcp"))]
#[cfg_attr(feature = "aws", test_case(LocalNetTestingConfig::new(Database::DynamoDb, Network::Tcp) ; "aws_tcp"))]
#[cfg_attr(feature = "rocksdb", test_case(LocalNetTestingConfig::new(Database::RocksDb, Network::Udp) ; "rocksdb_udp"))]
#[cfg_attr(feature = "scylladb", test_case(LocalNetTestingConfig::new(Database::ScyllaDb, Network::Udp) ; "scylladb_udp"))]
#[cfg_attr(feature = "aws", test_case(LocalNetTestingConfig::new(Database::DynamoDb, Network::Udp) ; "aws_udp"))]
#[test_log::test(tokio::test)]
async fn test_end_to_end_benchmark(config: LocalNetTestingConfig) {
let _guard = INTEGRATION_TEST_GUARD.lock().await;
let (mut net, client) = config.instantiate().await.unwrap();

assert_eq!(client.get_wallet().unwrap().num_chains(), 10);
// Launch local benchmark using all user chains and creating additional ones.
client.benchmark(12, 15).await.unwrap();
assert_eq!(client.get_wallet().unwrap().num_chains(), 15);

net.ensure_is_running().await.unwrap();
net.terminate().await.unwrap();
}

0 comments on commit 26764c5

Please sign in to comment.