Skip to content

Commit

Permalink
fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocynicys committed Sep 20, 2023
1 parent eaf5c59 commit 6440067
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 10 deletions.
12 changes: 6 additions & 6 deletions teos/src/dbm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,14 @@ mod tests {

#[cfg(feature = "postgres")]
async fn postgres() -> Self {
(|| async {
async {
return_db_if_matching!(
"postgres://user:pass@localhost/teos",
postgres,
"migrations/postgres"
);
Err(format!("Unreachable (the macro above will always match)"))
})()
Err("Unreachable (the macro above will always match)".to_string())
}
.await
.unwrap()
}
Expand Down Expand Up @@ -763,7 +763,7 @@ mod tests {
SUBSCRIPTION_START + i,
SUBSCRIPTION_EXPIRY + i,
);
users.insert(user_id, user_info.clone());
users.insert(user_id, user_info);
dbm.store_user(user_id, &user_info).await.unwrap();
}

Expand Down Expand Up @@ -1155,7 +1155,7 @@ mod tests {
assert_eq!(
dbm.batch_remove_appointments(to_be_deleted, updated_users)
.await,
i as usize
i
);
// Check appointment data was deleted and users properly updated
assert_eq!(
Expand Down Expand Up @@ -1188,7 +1188,7 @@ mod tests {

dbm.batch_remove_appointments(
vec![uuid],
HashMap::from_iter([(appointment.user_id, info.clone())]),
HashMap::from_iter([(appointment.user_id, info)]),
)
.await;
assert!(dbm.load_appointment(uuid).await.is_none());
Expand Down
38 changes: 38 additions & 0 deletions watchtower-plugin/runtowers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
###########################
printf "Press enter to start teosd-rusqlite "
read
~/teosd-rusqlite >/dev/null 2>/dev/null &
printf "Press enter to stop teosd-rusqlite "
read
teos-cli stop
sleep 1


###########################
printf "Press enter to start teosd-1lite "
read
~/teosd-1lite --databaseurl "sqlite:///home/mario/sqlx.db?mode=rwc" >/dev/null 2>/dev/null &
printf "Press enter to stop teosd-1lite "
read
teos-cli stop
sleep 1


###########################
printf "Press enter to start teosd-sqlx "
read
~/teosd-sqlx --databaseurl "sqlite:///home/mario/sqlx.db?mode=rwc" >/dev/null 2>/dev/null &
printf "Press enter to stop teosd-sqlx "
read
teos-cli stop
sleep 1


###########################
printf "Press enter to start teosd-gres "
read
~/teosd-gres --databaseurl "postgres://user:pass@localhost/teos" >/dev/null 2>/dev/null &
printf "Press enter to stop teosd-gres "
read
teos-cli stop
sleep 1
8 changes: 4 additions & 4 deletions watchtower-plugin/src/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn get_appointment(
) -> Result<(), http::RequestError> {
http::process_post_response::<http::ApiResponse<common_msgs::GetAppointmentResponse>>(
http::post_request(
&tower_net_addr,
tower_net_addr,
Endpoint::GetAppointment,
&common_msgs::GetAppointmentRequest {
locator: locator.to_vec(),
Expand Down Expand Up @@ -132,7 +132,7 @@ async fn main() {
appointment_send_times.iter().min().unwrap(),
appointment_send_times.iter().max().unwrap(),
appointment_send_times.iter().sum::<tokio::time::Duration>()
/ appointment_send_times.iter().count() as u32
/ appointment_send_times.len() as u32
);

// Now retrieve all these sent appointment.
Expand All @@ -150,7 +150,7 @@ async fn main() {
for (j, locator) in locators.iter().enumerate() {
let signature = sign(format!("get appointment {locator}").as_bytes(), &sk).unwrap();
let start = tokio::time::Instant::now();
get_appointment(&tower_net_addr, &locator, signature)
get_appointment(&tower_net_addr, locator, signature)
.await
.map_err(|e| {
println!("User {i} faced an error while retrieve appointment {j}: {e:?}")
Expand Down Expand Up @@ -182,6 +182,6 @@ async fn main() {
appointment_send_times.iter().min().unwrap(),
appointment_send_times.iter().max().unwrap(),
appointment_send_times.iter().sum::<tokio::time::Duration>()
/ appointment_send_times.iter().count() as u32
/ appointment_send_times.len() as u32
);
}
Binary file added watchtower-plugin/stress
Binary file not shown.
45 changes: 45 additions & 0 deletions watchtower-plugin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cd $(dirname $0)
users=$1
appointments=$2

# cargo build --target x86_64-unknown-linux-musl --release --bin stress
# cp ../target/x86_64-unknown-linux-musl/release/stress .

cargo build --release --bin stress
cp ../target/release/stress .


###########################
~/teosd-rusqlite >/dev/null 2>/dev/null &
echo "rusqlite sync driver:"
sleep 1
./stress $users $appointments
teos-cli stop
sleep 1


###########################
~/teosd-1lite --databaseurl "sqlite:///home/mario/sqlx.db?mode=rwc" >/dev/null 2>/dev/null &
echo "Sqlx sqlite pool of 1 connection:"
sleep 1
./stress $users $appointments
teos-cli stop
sleep 1


###########################
~/teosd-sqlx --databaseurl "sqlite:///home/mario/sqlx.db?mode=rwc" >/dev/null 2>/dev/null &
echo "Sqlx sqlite pool of 20 connections:"
sleep 1
./stress $users $appointments
teos-cli stop
sleep 1


###########################
~/teosd-gres --databaseurl "postgres://user:pass@localhost/teos" >/dev/null 2>/dev/null &
echo "Sqlx postgresql:"
sleep 1
./stress $users $appointments
teos-cli stop
sleep 1

0 comments on commit 6440067

Please sign in to comment.