Skip to content

Commit

Permalink
example: speed up sync-test
Browse files Browse the repository at this point in the history
By removing sleep from client.rs,
and remoing retry.

Signed-off-by: Tim Zhang <[email protected]>
  • Loading branch information
Tim-Zhang committed Oct 9, 2024
1 parent 5c0da46 commit e4d0d20
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions example/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod utils;
use log::LevelFilter;
use protocols::sync::{agent, agent_ttrpc, health, health_ttrpc};
use std::thread;
use std::time::Duration;
use ttrpc::context::{self, Context};
use ttrpc::error::Error;
use ttrpc::proto::Code;
Expand All @@ -38,18 +39,12 @@ fn get_fd_count() -> usize {
}

fn main() {
connect_once();
let expected_fd_count = get_fd_count();

// connect 3 times and check the fd leak.
for index in 0..3 {
connect_once();
let current_fd_count = get_fd_count();
assert_eq!(
expected_fd_count, current_fd_count,
"check fd count in {index}"
);
}
connect_once();
// Give some time for fd to be released in the other thread
thread::sleep(Duration::from_secs(1));
let current_fd_count = get_fd_count();
assert_eq!(current_fd_count, expected_fd_count, "check fd count");
}

fn connect_once() {
Expand Down Expand Up @@ -151,9 +146,6 @@ fn connect_once() {
now.elapsed()
);

println!("\nsleep 2 seconds ...\n");
thread::sleep(std::time::Duration::from_secs(2));

let version = hc.version(default_ctx(), &health::CheckRequest::new());
assert_eq!("mock.0.1", version.as_ref().unwrap().agent_version.as_str());
assert_eq!("0.0.1", version.as_ref().unwrap().grpc_version.as_str());
Expand Down

0 comments on commit e4d0d20

Please sign in to comment.