Skip to content

Commit

Permalink
Speedup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Feb 2, 2024
1 parent 36b542b commit 5774b61
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions zenoh/tests/interceptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ fn downsampling_by_keyexpr() {
.unwrap();

let interval = std::time::Duration::from_millis(1);
for i in 0..1000 {
let messages_count = 1000;
for i in 0..messages_count {
println!("message {}", i);
publisher_r100.put(format!("message {}", i)).res().unwrap();
publisher_r50.put(format!("message {}", i)).res().unwrap();
Expand All @@ -87,8 +88,13 @@ fn downsampling_by_keyexpr() {
std::thread::sleep(interval);
}

std::thread::sleep(std::time::Duration::from_secs(1));
assert!(*(total_count.lock().unwrap()) >= 1000);
for _ in 0..100 {
if *(total_count.lock().unwrap()) >= messages_count {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert!(*(total_count.lock().unwrap()) >= messages_count);
}

#[cfg(unix)]
Expand Down Expand Up @@ -165,14 +171,20 @@ fn downsampling_by_interface() {
.unwrap();

let interval = std::time::Duration::from_millis(1);
for i in 0..1000 {
let messages_count = 1000;
for i in 0..messages_count {
println!("message {}", i);
publisher_r100.put(format!("message {}", i)).res().unwrap();
publisher_all.put(format!("message {}", i)).res().unwrap();

std::thread::sleep(interval);
}

std::thread::sleep(std::time::Duration::from_secs(1));
assert!(*(total_count.lock().unwrap()) >= 1000);
for _ in 0..100 {
if *(total_count.lock().unwrap()) >= messages_count {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
assert!(*(total_count.lock().unwrap()) >= messages_count);
}

0 comments on commit 5774b61

Please sign in to comment.