Allow more time between thread CPU slices in db_init_outside_future_executor (#5310)

This commit is contained in:
teor 2022-10-04 12:51:53 +10:00 committed by GitHub
parent 469c471d92
commit cea622307a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -76,7 +76,7 @@ const DEFAULT_PROXY_CHANNEL_SIZE: usize = 100;
///
/// Note that if a test checks that no requests are received, each check has to wait for this
/// amount of time, so this may affect the test execution time.
const DEFAULT_MAX_REQUEST_DELAY: Duration = Duration::from_millis(25);
pub const DEFAULT_MAX_REQUEST_DELAY: Duration = Duration::from_millis(25);
/// An internal type representing the item that's sent in the [`broadcast`] channel.
///

View File

@ -113,7 +113,12 @@
//! export TMPDIR=/path/to/disk/directory
//! ```
use std::{collections::HashSet, env, fs, panic, path::PathBuf, time::Duration};
use std::{
collections::HashSet,
env, fs, panic,
path::PathBuf,
time::{Duration, Instant},
};
use color_eyre::{
eyre::{eyre, Result, WrapErr},
@ -152,6 +157,13 @@ use common::{
},
};
/// The maximum amount of time that we allow the creation of a future to block the `tokio` executor.
///
/// This should be larger than the amount of time between thread time slices on a busy test VM.
///
/// This limit only applies to some tests.
pub const MAX_ASYNC_BLOCKING_TIME: Duration = zebra_test::mock_service::DEFAULT_MAX_REQUEST_DELAY;
#[test]
fn generate_no_args() -> Result<()> {
let _init_guard = zebra_test::init();
@ -315,8 +327,6 @@ fn start_args() -> Result<()> {
#[tokio::test]
async fn db_init_outside_future_executor() -> Result<()> {
use std::time::{Duration, Instant};
let _init_guard = zebra_test::init();
let config = default_test_config()?;
@ -328,7 +338,7 @@ async fn db_init_outside_future_executor() -> Result<()> {
// will wait indefinitely for blocking operation to finish once started
let block_duration = start.elapsed();
assert!(
block_duration < Duration::from_millis(5),
block_duration <= MAX_ASYNC_BLOCKING_TIME,
"futures executor was blocked longer than expected ({:?})",
block_duration,
);