Skip to content

Commit

Permalink
simplify test_race_condition
Browse files Browse the repository at this point in the history
  • Loading branch information
suharev7 committed Mar 23, 2021
1 parent c235442 commit cbcab20
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,10 @@ impl Drop for ClientHandle {
mod test {
use std::{
str::FromStr,
sync::{
Arc,
atomic::{AtomicBool, Ordering},
},
time::{Duration, Instant},
};

use futures_util::future;
use tokio::runtime::Builder;

use crate::{Block, errors::Result, Options, test_misc::DATABASE_URL};

Expand Down Expand Up @@ -378,42 +373,6 @@ mod test {
Ok(())
}

#[test]
fn test_race_condition() {
let options = Options::from_str(DATABASE_URL.as_str())
.unwrap()
.pool_min(80)
.pool_max(99);

let barrier = Arc::new(AtomicBool::new(true));
let pool = Pool::new(options);

let runtime = Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();

let tasks: Vec<_> = (0..100)
.map(|_| {
let local_pool = pool.clone();
let local_barer = Arc::clone(&barrier);

runtime.spawn(async move {
while local_barer.load(Ordering::SeqCst) {}

let _ = local_pool.get_handle().await;
})
})
.collect();

barrier.store(false, Ordering::SeqCst);

match runtime.block_on(future::try_join_all(tasks)) {
Ok(_) => {}
Err(e) => panic!("{}", e),
}
}

#[tokio::test]
async fn test_wrong_insert() -> Result<()> {
let pool = Pool::new(DATABASE_URL.as_str());
Expand Down

0 comments on commit cbcab20

Please sign in to comment.