diff --git a/services/commtest/tests/blob/blob_utils.rs b/services/commtest/tests/blob/blob_utils.rs --- a/services/commtest/tests/blob/blob_utils.rs +++ b/services/commtest/tests/blob/blob_utils.rs @@ -5,6 +5,7 @@ pub use proto::blob_service_client::BlobServiceClient; #[allow(dead_code)] +#[derive(Clone)] pub struct BlobData { pub holder: String, pub hash: String, diff --git a/services/commtest/tests/blob_performance_test.rs b/services/commtest/tests/blob_performance_test.rs --- a/services/commtest/tests/blob_performance_test.rs +++ b/services/commtest/tests/blob_performance_test.rs @@ -1,5 +1,7 @@ #[path = "./blob/blob_utils.rs"] mod blob_utils; +#[path = "./blob/put.rs"] +mod put; #[path = "./lib/tools.rs"] mod tools; @@ -9,10 +11,14 @@ use tokio::runtime::Runtime; use tools::Error; -use blob_utils::BlobData; +use blob_utils::{BlobData, BlobServiceClient}; #[tokio::test] async fn blob_performance_test() -> Result<(), Error> { + let port = env::var("COMM_SERVICES_PORT_BLOB") + .expect("port env var expected but not received"); + let client = + BlobServiceClient::connect(format!("http://localhost:{}", port)).await?; // change this value to test more simultaneous connections let number_of_threads: usize = env::var("COMM_NUMBER_OF_THREADS") @@ -40,6 +46,20 @@ // PUT rt.block_on(async { println!("performing PUT operations"); + let mut handlers = vec![]; + for item in &blob_data { + let item_cloned = item.clone(); + let mut client_cloned = client.clone(); + handlers.push(tokio::spawn(async move { + let data_exists: bool = + put::run(&mut client_cloned, &item_cloned).await.unwrap(); + assert!(!data_exists, "test data should not exist"); + })); + } + + for handler in handlers { + handler.await.unwrap(); + } }); // GET