Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32344709
D4277.1765312803.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D4277.1765312803.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
Tue, Dec 9, 8:40 PM (2 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5857633
Default Alt Text
D4277.1765312803.diff (2 KB)
Attached To
Mode
D4277: [services] Tests - Blob - Add test logic
Attached
Detach File
Event Timeline
Log In to Comment