Skip to content

Commit e61484d

Browse files
committed
Check that we time out when we have too many connection requests
1 parent c0023d7 commit e61484d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

doc/developer/cloudtest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ cluster to become ready:
136136
137137
See the examples in `test/clustertest/test_smoke.py`.
138138
139-
The tests folow pytest conventions:
139+
The tests follow pytest conventions:
140140
141141
```python
142142
from materialize.cloudtest.app.materialize_application import MaterializeApplication

src/persist/src/postgres.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl PostgresConsensusConfig {
140140
}
141141

142142
fn connection_pool_max_wait(&self) -> Option<Duration> {
143-
None
143+
Some(Duration::from_secs(1))
144144
}
145145

146146
fn connection_pool_ttl(&self) -> Duration {
@@ -415,4 +415,31 @@ mod tests {
415415

416416
Ok(())
417417
}
418+
419+
#[mz_ore::test(tokio::test(flavor = "multi_thread"))]
420+
#[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
421+
async fn postgres_consensus_blocking() -> Result<(), ExternalError> {
422+
let config = match PostgresConsensusConfig::new_for_test()? {
423+
Some(config) => config,
424+
None => {
425+
info!(
426+
"{} env not set: skipping test that uses external service",
427+
PostgresConsensusConfig::EXTERNAL_TESTS_POSTGRES_URL
428+
);
429+
return Ok(());
430+
}
431+
};
432+
433+
let consensus: PostgresConsensus = PostgresConsensus::open(config.clone()).await?;
434+
// Max size in test is 2... let's saturate the pool.
435+
let _conn1 = consensus.get_connection().await?;
436+
let _conn2 = consensus.get_connection().await?;
437+
438+
// And finally, we should see the next connect time out.
439+
let conn3 = consensus.get_connection().await;
440+
441+
assert!(conn3.is_err());
442+
443+
Ok(())
444+
}
418445
}

0 commit comments

Comments
 (0)