Merge 56fd4ed639b30036cea182cb7158c517770f44d1 into 5bc1ad63a76ed2b41eeeced50d2ea778138d09e6

This commit is contained in:
Fabiana Cecin 2026-05-30 15:14:14 -07:00 committed by GitHub
commit 151353f62d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

@ -23,6 +23,8 @@ suite "Postgres driver":
driver = PostgresDriver(driverRes.get())
(await driver.waitForPartition()).expect("Test has no DB partition")
asyncTeardown:
let resetRes = await driver.reset()
if resetRes.isErr():

View File

@ -38,6 +38,8 @@ suite "Postgres driver - queries":
driver = PostgresDriver(driverRes.get())
(await driver.waitForPartition()).expect("Test has no DB partition")
asyncTeardown:
let resetRes = await driver.reset()

View File

@ -1488,6 +1488,21 @@ proc removeOldestPartition(
proc containsAnyPartition*(self: PostgresDriver): bool =
return not self.partitionMngr.isEmpty()
proc waitForPartition*(
self: PostgresDriver, timeout = chronos.seconds(5)
): Future[ArchiveDriverResult[void]] {.async.} =
let pollInterval = chronos.milliseconds(100)
var elapsed = chronos.milliseconds(0)
while elapsed < timeout:
if self.containsAnyPartition():
return ok()
await sleepAsync(pollInterval)
elapsed += pollInterval
return err("PostgresDriver.waitForPartition() timed out after " & $timeout)
method decreaseDatabaseSize*(
driver: PostgresDriver, targetSizeInBytes: int64, forceRemoval: bool = false
): Future[ArchiveDriverResult[void]] {.async.} =