Skip to content

Commit faf388f

Browse files
helper: Add develp with test using webrtc and task count
Signed-off-by: Patrick José Pereira <[email protected]>
1 parent 4b25dfd commit faf388f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/helper/develop.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use crate::helper;
2+
use core::time::Duration;
3+
use std::thread;
4+
use thirtyfour::prelude::*;
5+
use tokio::runtime::Runtime;
6+
use tracing::*;
7+
8+
pub fn start_check_tasks_on_webrtc_reconnects() {
9+
let mut counter = 0;
10+
thread::spawn(move || {
11+
let rt = Runtime::new().unwrap();
12+
rt.block_on(async move {
13+
info!("Started webrtc test..");
14+
let mut caps = DesiredCapabilities::chrome();
15+
let _ = caps.set_headless();
16+
let driver = WebDriver::new("http://localhost:9515", caps)
17+
.await
18+
.expect("Failed to create web driver.");
19+
driver
20+
.goto("http://0.0.0.0:6020/webrtc/index.html")
21+
.await
22+
.expect("Failed to connect to local webrtc page.");
23+
loop {
24+
for button in ["add-consumer", "add-session", "remove-all-consumers"] {
25+
thread::sleep(Duration::from_secs(3));
26+
driver
27+
.find(By::Id(button))
28+
.await
29+
.unwrap()
30+
.click()
31+
.await
32+
.unwrap();
33+
}
34+
counter += 1;
35+
info!("Restarted webrtc {} times", counter);
36+
if helper::threads::process_task_counter() > 100 {
37+
error!("Thead leak detected!");
38+
std::process::exit(-1);
39+
}
40+
}
41+
});
42+
error!("Webrtc test failed internally.");
43+
std::process::exit(-1);
44+
});
45+
}

src/helper/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#[macro_use]
2+
pub mod develop;
23
pub mod macros;
34
pub mod threads;

0 commit comments

Comments
 (0)