Skip to content

Commit e4d0d20

Browse files
committed
example: speed up sync-test
By removing sleep from client.rs, and remoing retry. Signed-off-by: Tim Zhang <tim@hyper.sh>
1 parent 5c0da46 commit e4d0d20

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

example/client.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod utils;
1818
use log::LevelFilter;
1919
use protocols::sync::{agent, agent_ttrpc, health, health_ttrpc};
2020
use std::thread;
21+
use std::time::Duration;
2122
use ttrpc::context::{self, Context};
2223
use ttrpc::error::Error;
2324
use ttrpc::proto::Code;
@@ -38,18 +39,12 @@ fn get_fd_count() -> usize {
3839
}
3940

4041
fn main() {
41-
connect_once();
4242
let expected_fd_count = get_fd_count();
43-
44-
// connect 3 times and check the fd leak.
45-
for index in 0..3 {
46-
connect_once();
47-
let current_fd_count = get_fd_count();
48-
assert_eq!(
49-
expected_fd_count, current_fd_count,
50-
"check fd count in {index}"
51-
);
52-
}
43+
connect_once();
44+
// Give some time for fd to be released in the other thread
45+
thread::sleep(Duration::from_secs(1));
46+
let current_fd_count = get_fd_count();
47+
assert_eq!(current_fd_count, expected_fd_count, "check fd count");
5348
}
5449

5550
fn connect_once() {
@@ -151,9 +146,6 @@ fn connect_once() {
151146
now.elapsed()
152147
);
153148

154-
println!("\nsleep 2 seconds ...\n");
155-
thread::sleep(std::time::Duration::from_secs(2));
156-
157149
let version = hc.version(default_ctx(), &health::CheckRequest::new());
158150
assert_eq!("mock.0.1", version.as_ref().unwrap().agent_version.as_str());
159151
assert_eq!("0.0.1", version.as_ref().unwrap().grpc_version.as_str());

0 commit comments

Comments
 (0)