Skip to content

Commit 0e080a6

Browse files
authored
tests: Explicitly close async database pools within the context of a tokio runtime (#8382)
Without this, the `Drop` implementation of the the pool would complain about not running within a tokio runtime and ultimately panic the tests. This only happened to work so far because none of our integration tests had used the async database pool yet.
1 parent eee300c commit 0e080a6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/tests/util/test_app.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ impl Drop for TestAppInner {
6767
);
6868

6969
// TODO: If a runner was started, obtain the clone from it and ensure its HEAD matches the upstream index HEAD
70+
71+
// We manually close the connection pools here to prevent their `Drop`
72+
// implementation from failing because no tokio runtime is running.
73+
{
74+
let _rt_guard = self.runtime.enter();
75+
self.app.deadpool_primary.close();
76+
if let Some(pool) = &self.app.deadpool_replica {
77+
pool.close();
78+
}
79+
}
7080
}
7181
}
7282

0 commit comments

Comments
 (0)