-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helper: Add develp with test using webrtc and task count
Signed-off-by: Patrick José Pereira <[email protected]>
- Loading branch information
1 parent
abd3fb0
commit 460215a
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |