Page MenuHomePhabricator

D5203.id17183.diff
No OneTemporary

D5203.id17183.diff

diff --git a/services/commtest/src/backup/add_attachments.rs b/services/commtest/src/backup/add_attachments.rs
--- a/services/commtest/src/backup/add_attachments.rs
+++ b/services/commtest/src/backup/add_attachments.rs
@@ -1,7 +1,8 @@
use crate::backup::backup_utils::{
proto::AddAttachmentsRequest, BackupData, BackupServiceClient,
};
-use crate::tools::{Error, ATTACHMENT_DELIMITER};
+use crate::constants::ATTACHMENT_DELIMITER;
+use crate::tools::Error;
use tonic::Request;
// log_index = None means that we add attachments to the backup
diff --git a/services/commtest/src/backup/pull_backup.rs b/services/commtest/src/backup/pull_backup.rs
--- a/services/commtest/src/backup/pull_backup.rs
+++ b/services/commtest/src/backup/pull_backup.rs
@@ -3,7 +3,8 @@
proto::pull_backup_response::Id, proto::pull_backup_response::Id::*,
proto::PullBackupRequest, BackupData, BackupServiceClient, Item,
};
-use crate::tools::{Error, ATTACHMENT_DELIMITER};
+use crate::constants::ATTACHMENT_DELIMITER;
+use crate::tools::Error;
use std::io::{Error as IOError, ErrorKind};
use tonic::Request;
diff --git a/services/commtest/src/constants.rs b/services/commtest/src/constants.rs
new file mode 100644
--- /dev/null
+++ b/services/commtest/src/constants.rs
@@ -0,0 +1,13 @@
+use bytesize::ByteSize;
+use lazy_static::lazy_static;
+
+pub const ATTACHMENT_DELIMITER: &str = ";";
+
+pub const GRPC_METADATA_SIZE_BYTES: usize = 5;
+
+lazy_static! {
+ pub static ref DYNAMO_DB_ITEM_SIZE_LIMIT: usize =
+ ByteSize::kib(400).as_u64() as usize;
+ pub static ref GRPC_CHUNK_SIZE_LIMIT: usize =
+ (ByteSize::mib(4).as_u64() as usize) - GRPC_METADATA_SIZE_BYTES;
+}
diff --git a/services/commtest/src/lib.rs b/services/commtest/src/lib.rs
--- a/services/commtest/src/lib.rs
+++ b/services/commtest/src/lib.rs
@@ -1,3 +1,4 @@
pub mod backup;
pub mod blob;
+pub mod constants;
pub mod tools;
diff --git a/services/commtest/src/tools.rs b/services/commtest/src/tools.rs
--- a/services/commtest/src/tools.rs
+++ b/services/commtest/src/tools.rs
@@ -1,6 +1,4 @@
-use bytesize::ByteSize;
use hex::ToHex;
-use lazy_static::lazy_static;
use num_cpus;
use sha2::{Digest, Sha512};
use std::env;
@@ -25,17 +23,6 @@
TonicStatus(tonic::Status),
}
-pub const GRPC_METADATA_SIZE_BYTES: usize = 5;
-
-lazy_static! {
- pub static ref DYNAMO_DB_ITEM_SIZE_LIMIT: usize =
- ByteSize::kib(400).as_u64() as usize;
- pub static ref GRPC_CHUNK_SIZE_LIMIT: usize =
- (ByteSize::mib(4).as_u64() as usize) - GRPC_METADATA_SIZE_BYTES;
-}
-
-pub const ATTACHMENT_DELIMITER: &str = ";";
-
pub fn obtain_number_of_threads() -> usize {
let number_of_threads_str: String =
env::var("COMM_NUMBER_OF_THREADS").unwrap();
diff --git a/services/commtest/tests/backup_integration_test.rs b/services/commtest/tests/backup_integration_test.rs
--- a/services/commtest/tests/backup_integration_test.rs
+++ b/services/commtest/tests/backup_integration_test.rs
@@ -4,7 +4,8 @@
backup_utils::{self, BackupData, BackupServiceClient, Item},
create_new_backup, pull_backup, send_log,
};
-use commtest::tools::{self, Error};
+use commtest::constants;
+use commtest::tools::Error;
use std::collections::HashMap;
use std::env;
@@ -36,7 +37,7 @@
Item::new(
String::new(),
vec![
- *tools::DYNAMO_DB_ITEM_SIZE_LIMIT
+ *constants::DYNAMO_DB_ITEM_SIZE_LIMIT
- ByteSize::b(attachments_fill_size / 2).as_u64() as usize,
],
vec!["holder0".to_string(), "holder1".to_string()],
@@ -50,7 +51,10 @@
// a big item that should be placed in the S3 right away
Item::new(
String::new(),
- vec![*tools::GRPC_CHUNK_SIZE_LIMIT, *tools::GRPC_CHUNK_SIZE_LIMIT],
+ vec![
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
+ ],
vec![
"holder0".to_string(),
"holder1".to_string(),
diff --git a/services/commtest/tests/blob_integration_test.rs b/services/commtest/tests/blob_integration_test.rs
--- a/services/commtest/tests/blob_integration_test.rs
+++ b/services/commtest/tests/blob_integration_test.rs
@@ -3,7 +3,8 @@
blob_utils::{BlobData, BlobServiceClient},
get, put, remove,
};
-use commtest::tools::{self, Error};
+use commtest::constants;
+use commtest::tools::Error;
use std::env;
#[tokio::test]
@@ -27,8 +28,8 @@
holder: "test_holder002".to_string(),
hash: "test_hash002".to_string(),
chunks_sizes: vec![
- *tools::GRPC_CHUNK_SIZE_LIMIT,
- *tools::GRPC_CHUNK_SIZE_LIMIT,
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
ByteSize::b(10).as_u64() as usize,
],
},
@@ -36,9 +37,9 @@
holder: "test_holder003".to_string(),
hash: "test_hash003".to_string(),
chunks_sizes: vec![
- *tools::GRPC_CHUNK_SIZE_LIMIT,
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
ByteSize::b(100).as_u64() as usize,
- *tools::GRPC_CHUNK_SIZE_LIMIT,
+ *constants::GRPC_CHUNK_SIZE_LIMIT,
],
},
];

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 2:23 AM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495932
Default Alt Text
D5203.id17183.diff (4 KB)

Event Timeline