From ed8d96bac952836d27521c2fe652daa193370393 Mon Sep 17 00:00:00 2001 From: Daniel Carl Jones Date: Tue, 24 Sep 2024 10:39:04 +0100 Subject: [PATCH] Update mock-mount-s3 to require '--max-throughput-gbps' argument (#1018) * Update mock-mount-s3 to require '--max-throughput-gbps' argument Signed-off-by: Daniel Carl Jones * Fix error message Signed-off-by: Daniel Carl Jones --------- Signed-off-by: Daniel Carl Jones --- mountpoint-s3/src/bin/mock-mount-s3.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mountpoint-s3/src/bin/mock-mount-s3.rs b/mountpoint-s3/src/bin/mock-mount-s3.rs index f4a656da4..fb541a3e1 100644 --- a/mountpoint-s3/src/bin/mock-mount-s3.rs +++ b/mountpoint-s3/src/bin/mock-mount-s3.rs @@ -10,7 +10,9 @@ //! //! This binary is intended only for use in testing and development of Mountpoint. +use anyhow::anyhow; use futures::executor::ThreadPool; + use mountpoint_s3::cli::CliArgs; use mountpoint_s3::s3::S3Personality; use mountpoint_s3_client::mock_client::throughput_client::ThroughputMockClient; @@ -32,7 +34,11 @@ fn create_mock_client(args: &CliArgs) -> anyhow::Result<(ThroughputMockClient, T tracing::warn!("using mock client"); - let max_throughput_gbps = args.maximum_throughput_gbps.unwrap_or(10) as f64; + let Some(max_throughput_gbps) = args.maximum_throughput_gbps else { + return Err(anyhow!( + "must set --maximum-throughput-gbps when using mock-mount-s3 binary" + )); + }; tracing::info!("mock client target network throughput {max_throughput_gbps} Gbps"); let config = MockClientConfig { @@ -42,7 +48,7 @@ fn create_mock_client(args: &CliArgs) -> anyhow::Result<(ThroughputMockClient, T enable_backpressure: true, initial_read_window_size: 1024 * 1024 + 128 * 1024, // matching real MP }; - let client = ThroughputMockClient::new(config, max_throughput_gbps); + let client = ThroughputMockClient::new(config, max_throughput_gbps as f64); let runtime = ThreadPool::builder().name_prefix("runtime").create()?;