mirror of
https://github.com/Nutomic/ibis.git
synced 2024-12-24 00:11:24 +00:00
Simply run all tests in parallel at the same time
This commit is contained in:
parent
e0ed85daf2
commit
0868db9210
1 changed files with 2 additions and 13 deletions
|
@ -16,19 +16,16 @@ use std::{
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicI32, AtomicUsize, Ordering},
|
atomic::{AtomicI32, Ordering},
|
||||||
Once,
|
Once,
|
||||||
},
|
},
|
||||||
thread::{available_parallelism, sleep, spawn},
|
thread::spawn,
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
use tokio::{join, sync::oneshot, task::JoinHandle};
|
use tokio::{join, sync::oneshot, task::JoinHandle};
|
||||||
use tracing::log::LevelFilter;
|
use tracing::log::LevelFilter;
|
||||||
|
|
||||||
pub struct TestData(pub IbisInstance, pub IbisInstance, pub IbisInstance);
|
pub struct TestData(pub IbisInstance, pub IbisInstance, pub IbisInstance);
|
||||||
|
|
||||||
static ACTIVE_TESTS: AtomicUsize = AtomicUsize::new(0);
|
|
||||||
|
|
||||||
impl TestData {
|
impl TestData {
|
||||||
pub async fn start(article_approval: bool) -> Self {
|
pub async fn start(article_approval: bool) -> Self {
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
|
@ -44,13 +41,6 @@ impl TestData {
|
||||||
static COUNTER: AtomicI32 = AtomicI32::new(0);
|
static COUNTER: AtomicI32 = AtomicI32::new(0);
|
||||||
let current_run = COUNTER.fetch_add(1, Ordering::Relaxed);
|
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 first_port = 8100 + (current_run * 3);
|
||||||
let port_alpha = first_port;
|
let port_alpha = first_port;
|
||||||
let port_beta = first_port + 1;
|
let port_beta = first_port + 1;
|
||||||
|
@ -82,7 +72,6 @@ impl TestData {
|
||||||
for j in [alpha.stop(), beta.stop(), gamma.stop()] {
|
for j in [alpha.stop(), beta.stop(), gamma.stop()] {
|
||||||
j.join().unwrap();
|
j.join().unwrap();
|
||||||
}
|
}
|
||||||
ACTIVE_TESTS.fetch_sub(1, Ordering::AcqRel);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue