Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,25 @@ jobs:
RUST_BACKTRACE: 1
DATABASE_URL: mysql://root:password@127.0.0.1/mysql
displayName: Run tests in Docker

- job: "TestTiDB"
pool:
vmImage: "ubuntu-latest"
strategy:
matrix:
v5.3.0:
DB_VERSION: "v5.3.0"
v5.0.6:
DB_VERSION: "v5.0.6"
steps:
- bash: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.profile
tiup playground $(DB_VERSION) --db 1 --pd 1 --kv 1 &
while ! nc -W 1 localhost 4000 | grep -q -P '.+'; do sleep 1; done
displayName: Install and run TiDB
- bash: cargo test should_reuse_connections -- --nocapture
displayName: Run tests
env:
RUST_BACKTRACE: 1
DATABASE_URL: mysql://root@127.0.0.1:4000/mysql
2 changes: 1 addition & 1 deletion src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ impl Conn {
.opts
.conn_ttl()
.unwrap_or(self.inner.wait_timeout);
self.idling() > ttl
!ttl.is_zero() && self.idling() > ttl
}

/// Returns duration since last IO.
Expand Down
21 changes: 21 additions & 0 deletions src/conn/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,27 @@ mod test {
master.disconnect().await
}

#[tokio::test]
async fn should_reuse_connections() -> super::Result<()> {
let constraints = PoolConstraints::new(1, 1).unwrap();
let opts = get_opts().pool_opts(PoolOpts::default().with_constraints(constraints));

let pool = Pool::new(opts);
let mut conn = pool.get_conn().await?;

let server_version = conn.server_version();
let connection_id = conn.id();

for _ in 0..16 {
drop(conn);
conn = pool.get_conn().await?;
println!("CONN connection_id={}", conn.id());
assert!(conn.id() == connection_id || server_version < (5, 7, 2));
}

Ok(())
}

#[tokio::test]
#[ignore]
async fn can_handle_the_pressure() {
Expand Down