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 abd3fb0 commit 460215a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/helper/develop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use crate::cli;
use crate::helper;
use anyhow::Result;
use core::time::Duration;
use std::thread;
use thirtyfour::prelude::*;
use tokio::runtime::Runtime;
use tracing::*;

async fn task(mut counter: i32) -> Result<()> {
info!("Started webrtc test..");

let mut caps = DesiredCapabilities::chrome();
let _ = caps.set_headless();

let port = cli::manager::enable_webrtc_task_test().unwrap();
let driver = WebDriver::new(&format!("http://localhost:{}", port), 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?.click().await?;
}

counter += 1;

info!("Restarted webrtc {} times", counter);
if helper::threads::process_task_counter() > 100 {
error!("Thead leak detected!");
std::process::exit(-1);
}
}
}

pub fn start_check_tasks_on_webrtc_reconnects() {
let counter = 0;
thread::spawn(move || {
let rt = Runtime::new().unwrap();
rt.block_on(async move {
loop {
if let Err(error) = task(counter).await {
error!("WebRTC Checker Task failed: {error:#?}");
}
}
});
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 460215a

Please sign in to comment.