1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-12-23 13:51:22 +00:00

Simply run all tests in parallel at the same time

This commit is contained in:
Felix Ableitner 2024-12-05 12:47:28 +01:00
parent e0ed85daf2
commit 0868db9210

View file

@ -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(())
}
}