Page MenuHomePhabricator

D4581.id14798.diff
No OneTemporary

D4581.id14798.diff

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,7 +1,59 @@
+#[path = "./blob/blob_utils.rs"]
+mod blob_utils;
#[path = "./lib/tools.rs"]
mod tools;
+use bytesize::ByteSize;
+use std::env;
+
+use tokio::runtime::Runtime;
+use tools::Error;
+
+use blob_utils::BlobData;
+
#[tokio::test]
-async fn blob_performance_test() {
- assert!(false, "not implemented");
+async fn blob_performance_test() -> Result<(), Error> {
+
+ // change this value to test more simultaneous connections
+ let number_of_threads: usize = env::var("COMM_NUMBER_OF_THREADS")
+ .expect("number of threads expected but not received")
+ .parse::<usize>()
+ .unwrap();
+
+ let mut blob_data = vec![];
+
+ for i in 0..number_of_threads {
+ let index: u64 = (i as u64) % 10;
+ blob_data.push(BlobData {
+ holder: format!("test_holder_{}", i),
+ hash: format!("test_hash_{}", i),
+ chunks_sizes: vec![
+ ByteSize::kib(200 + (300 - index * 20)).as_u64() as usize,
+ ByteSize::kib(500 + (400 - index * 20)).as_u64() as usize,
+ ByteSize::kib(700 + (500 - index * 25)).as_u64() as usize,
+ ],
+ })
+ }
+
+ let rt = Runtime::new().unwrap();
+ tokio::task::spawn_blocking(move || {
+ // PUT
+ rt.block_on(async {
+ println!("performing PUT operations");
+ });
+
+ // GET
+ rt.block_on(async {
+ println!("performing GET operations");
+ });
+
+ // REMOVE
+ rt.block_on(async {
+ println!("performing REMOVE operations");
+ });
+ })
+ .await
+ .expect("Task panicked");
+
+ Ok(())
}
diff --git a/services/scripts/run_performance_tests.sh b/services/scripts/run_performance_tests.sh
--- a/services/scripts/run_performance_tests.sh
+++ b/services/scripts/run_performance_tests.sh
@@ -10,18 +10,29 @@
cargo test "$1"_performance_test --test '*' --manifest-path=commtest/Cargo.toml #-- --nocapture
}
-list_expected () {
- echo "Expected one of these:";
+help () {
+ echo "Usage:";
+ echo "There are two arguments you can specify";
+ echo "First is a target service:";
echo "$SERVICES";
echo "all";
+ echo "Second is a number of threads that you'd like to spawn.";
+ echo "It is optional, if not specified, it will fall back to a default value";
}
if [[ -z "$1" ]]; then
echo "No service specified" >&2
- list_expected;
+ help;
exit 1
fi
+THREADS="$2"
+NUMBER_REGEX='^[0-9]+$'
+if ! [[ "$THREADS" =~ $NUMBER_REGEX ]] ; then
+ THREADS="5";
+fi
+export COMM_NUMBER_OF_THREADS="$THREADS"
+
if [[ "$1" == "all" ]]; then
for SERVICE in "$SERVICES"; do
run_performance_test "$SERVICE"
@@ -33,7 +44,7 @@
if [[ "$SERVICE" != "$1" ]]; then
echo "No such service: $1";
- list_expected;
+ help;
exit 1;
fi;

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 8:41 PM (20 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2689010
Default Alt Text
D4581.id14798.diff (2 KB)

Event Timeline