Skip to content

Commit e8a4144

Browse files
authored
crates_io_test_db: Reduce connection timeout to 5 sec. (rust-lang#8923)
The default value of 30 sec. is fine for production servers, but seems a bit excessive for our test suite.
1 parent 44328aa commit e8a4144

File tree

1 file changed

+5
-0
lines changed
  • crates/crates_io_test_db/src

1 file changed

+5
-0
lines changed

crates/crates_io_test_db/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ use diesel::sql_query;
55
use diesel_migrations::{FileBasedMigrations, MigrationHarness};
66
use once_cell::sync::Lazy;
77
use rand::Rng;
8+
use std::time::Duration;
89
use tracing::{debug, instrument};
910
use url::Url;
1011

12+
const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);
13+
1114
struct TemplateDatabase {
1215
base_url: Url,
1316
pool: Pool<ConnectionManager<PgConnection>>,
@@ -33,6 +36,7 @@ impl TemplateDatabase {
3336
// contention, so this is using a connection pool to reduce unnecessary
3437
// waiting times for the tests.
3538
let pool = Pool::builder()
39+
.connection_timeout(CONNECTION_TIMEOUT)
3640
.max_size(10)
3741
.min_idle(Some(0))
3842
.build_unchecked(ConnectionManager::new(base_url.as_ref()));
@@ -104,6 +108,7 @@ impl TestDatabase {
104108
url.set_path(&format!("/{name}"));
105109

106110
let pool = Pool::builder()
111+
.connection_timeout(CONNECTION_TIMEOUT)
107112
.min_idle(Some(0))
108113
.build_unchecked(ConnectionManager::new(url.as_ref()));
109114

0 commit comments

Comments
 (0)