From 0868db921059fc39e739e58bac034720bfc6add5 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 5 Dec 2024 12:47:28 +0100 Subject: [PATCH] Simply run all tests in parallel at the same time --- tests/common.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/common.rs b/tests/common.rs index 1eee138..7387230 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -16,19 +16,16 @@ use std::{ ops::Deref, process::{Command, Stdio}, sync::{ - atomic::{AtomicI32, AtomicUsize, Ordering}, + atomic::{AtomicI32, Ordering}, Once, }, - thread::{available_parallelism, sleep, spawn}, - time::Duration, + thread::spawn, }; use tokio::{join, sync::oneshot, task::JoinHandle}; use tracing::log::LevelFilter; pub struct TestData(pub IbisInstance, pub IbisInstance, pub IbisInstance); -static ACTIVE_TESTS: AtomicUsize = AtomicUsize::new(0); - impl TestData { pub async fn start(article_approval: bool) -> Self { static INIT: Once = Once::new(); @@ -44,13 +41,6 @@ impl TestData { static COUNTER: AtomicI32 = AtomicI32::new(0); let current_run = COUNTER.fetch_add(1, Ordering::Relaxed); - // Limit number of parallel test runs based on number of cpu cores - let cores = available_parallelism().unwrap().get(); - while ACTIVE_TESTS.load(Ordering::Acquire) >= cores { - sleep(Duration::from_millis(1000)); - } - ACTIVE_TESTS.fetch_add(1, Ordering::AcqRel); - let first_port = 8100 + (current_run * 3); let port_alpha = first_port; let port_beta = first_port + 1; @@ -82,7 +72,6 @@ impl TestData { for j in [alpha.stop(), beta.stop(), gamma.stop()] { j.join().unwrap(); } - ACTIVE_TESTS.fetch_sub(1, Ordering::AcqRel); Ok(()) } }