Skip to content

Commit

Permalink
helper: Add develp with test using webrtc and task count
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Nov 30, 2023
1 parent 99ea408 commit 73fa81e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/helper/develop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use crate::helper;
use core::time::Duration;
use std::thread;
use thirtyfour::prelude::*;
use tokio::runtime::Runtime;
use tracing::*;

pub fn start_check_tasks_on_webrtc_reconnects() {
let mut counter = 0;
thread::spawn(move || {
let rt = Runtime::new().unwrap();
rt.block_on(async move {
info!("Started webrtc test..");
let mut caps = DesiredCapabilities::chrome();
let _ = caps.set_headless();
let driver = WebDriver::new("http://localhost:9515", caps)
.await
.expect("Failed to create web driver.");
driver
.goto("http://0.0.0.0:6020/webrtc/index.html")
.await
.expect("Failed to connect to local webrtc page.");
loop {
for button in ["add-consumer", "add-session", "remove-all-consumers"] {
thread::sleep(Duration::from_secs(3));
driver
.find(By::Id(button))
.await
.unwrap()
.click()
.await
.unwrap();
}
counter += 1;
info!("Restarted webrtc {} times", counter);
if helper::threads::process_task_counter() > 100 {
error!("Thead leak detected!");
std::process::exit(-1);
}
}
});
error!("Webrtc test failed internally.");
std::process::exit(-1);
});
}
1 change: 1 addition & 0 deletions src/helper/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[macro_use]
pub mod develop;
pub mod macros;
pub mod threads;

0 comments on commit 73fa81e

Please sign in to comment.