Merge 56fd4ed639b30036cea182cb7158c517770f44d1 into 96196ab8bc05f31b09dac2403f9d5de3bc05f31b

This commit is contained in:
Fabiana Cecin 2025-12-23 12:11:59 +01:00 committed by GitHub
commit 3c3a95a03a
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

@ -1422,6 +1422,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.} =