Skip to content

Commit 45520c1

Browse files
committed
fix(test): use proxy's configured database port in advisory lock test
client_a was hardcoded to PG_PORT (5532) while the proxy may connect to a different PostgreSQL instance (e.g. postgres-tls:5617 in TLS CI). This meant the advisory lock was held on a different server than client_b was targeting, so the lock never blocked and the test was flaky in CI. Use get_database_port() to ensure client_a connects to the same PostgreSQL instance the proxy uses.
1 parent 06a9a54 commit 45520c1

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/cipherstash-proxy-integration/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ where
272272
}
273273

274274
/// Get database port from environment or use default.
275-
fn get_database_port() -> u16 {
275+
pub fn get_database_port() -> u16 {
276276
std::env::var("CS_DATABASE__PORT")
277277
.ok()
278278
.and_then(|s| s.parse().ok())

packages/cipherstash-proxy-integration/src/connection_resilience.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// - Blocked backend connections don't affect other proxy connections
88
#[cfg(test)]
99
mod tests {
10-
use crate::common::{connect_with_tls, PG_PORT, PROXY};
10+
use crate::common::{connect_with_tls, get_database_port, PROXY};
1111
use std::time::Instant;
1212
use tokio::task::JoinSet;
1313
use tokio::time::{timeout, Duration};
@@ -128,7 +128,8 @@ mod tests {
128128

129129
let result = timeout(Duration::from_secs(30), async {
130130
// Connection A: hold an advisory lock (connect directly to PG to avoid proxy interference)
131-
let client_a = connect_with_tls(PG_PORT).await;
131+
let pg_port = get_database_port();
132+
let client_a = connect_with_tls(pg_port).await;
132133
client_a
133134
.simple_query(&lock_query)
134135
.await

0 commit comments

Comments
 (0)