Skip to content

Commit

Permalink
crates_io_test_db: Reduce connection timeout to 5 sec. (rust-lang#8923)
Browse files Browse the repository at this point in the history
The default value of 30 sec. is fine for production servers, but seems a bit excessive for our test suite.
  • Loading branch information
Turbo87 authored Jun 25, 2024
1 parent 44328aa commit e8a4144
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/crates_io_test_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ use diesel::sql_query;
use diesel_migrations::{FileBasedMigrations, MigrationHarness};
use once_cell::sync::Lazy;
use rand::Rng;
use std::time::Duration;
use tracing::{debug, instrument};
use url::Url;

const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);

struct TemplateDatabase {
base_url: Url,
pool: Pool<ConnectionManager<PgConnection>>,
Expand All @@ -33,6 +36,7 @@ impl TemplateDatabase {
// contention, so this is using a connection pool to reduce unnecessary
// waiting times for the tests.
let pool = Pool::builder()
.connection_timeout(CONNECTION_TIMEOUT)
.max_size(10)
.min_idle(Some(0))
.build_unchecked(ConnectionManager::new(base_url.as_ref()));
Expand Down Expand Up @@ -104,6 +108,7 @@ impl TestDatabase {
url.set_path(&format!("/{name}"));

let pool = Pool::builder()
.connection_timeout(CONNECTION_TIMEOUT)
.min_idle(Some(0))
.build_unchecked(ConnectionManager::new(url.as_ref()));

Expand Down

0 comments on commit e8a4144

Please sign in to comment.