Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3502719
D4277.id14310.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4277.id14310.diff
View Options
diff --git a/services/commtest/tests/blob_test.rs b/services/commtest/tests/blob_test.rs
--- a/services/commtest/tests/blob_test.rs
+++ b/services/commtest/tests/blob_test.rs
@@ -1,7 +1,76 @@
+#[path = "./blob/blob_utils.rs"]
+mod blob_utils;
+#[path = "./blob/get.rs"]
+mod get;
+#[path = "./blob/put.rs"]
+mod put;
+#[path = "./blob/remove.rs"]
+mod remove;
#[path = "./lib/tools.rs"]
mod tools;
+use bytesize::ByteSize;
+
+use blob_utils::{BlobData, BlobServiceClient};
+use tools::Error;
+
#[tokio::test]
-async fn blob_test() {
- assert!(false, "not implemented");
+async fn blob_test() -> Result<(), Error> {
+ let mut client = BlobServiceClient::connect("http://localhost:50053").await?;
+
+ let blob_data = vec![
+ BlobData {
+ holder: "test_holder001".to_string(),
+ hash: "test_hash001".to_string(),
+ chunks_sizes: vec![
+ ByteSize::b(100).as_u64() as usize,
+ ByteSize::b(100).as_u64() as usize,
+ ByteSize::b(100).as_u64() as usize,
+ ],
+ },
+ BlobData {
+ holder: "test_holder002".to_string(),
+ hash: "test_hash002".to_string(),
+ chunks_sizes: vec![
+ tools::get_grpc_chunk_size_limit(),
+ tools::get_grpc_chunk_size_limit(),
+ ByteSize::b(10).as_u64() as usize,
+ ],
+ },
+ BlobData {
+ holder: "test_holder003".to_string(),
+ hash: "test_hash003".to_string(),
+ chunks_sizes: vec![
+ tools::get_grpc_chunk_size_limit(),
+ ByteSize::b(100).as_u64() as usize,
+ tools::get_grpc_chunk_size_limit(),
+ ],
+ },
+ ];
+
+ for item in &blob_data {
+ let data_exists: bool = put::run(&mut client, &item).await?;
+ assert!(!data_exists, "test data should not exist");
+ }
+
+ for (i, blob_item) in blob_data.iter().enumerate() {
+ let received_sizes = get::run(&mut client, &blob_item).await?;
+ let expected_data_size = blob_item.chunks_sizes.iter().sum::<usize>();
+ let received_data_size = received_sizes.iter().sum::<usize>();
+ assert_eq!(
+ expected_data_size, received_data_size,
+ "invalid size of data for index {}, expected {}, got {}",
+ i, expected_data_size, received_data_size
+ );
+ }
+
+ for item in &blob_data {
+ remove::run(&mut client, &item).await?;
+ assert!(
+ get::run(&mut client, &item).await.is_err(),
+ "item should no longer be available"
+ );
+ }
+
+ Ok(())
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 4:57 AM (17 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683595
Default Alt Text
D4277.id14310.diff (2 KB)
Attached To
Mode
D4277: [services] Tests - Blob - Add test logic
Attached
Detach File
Event Timeline
Log In to Comment