Only hold the lock during container start.
This commit is contained in:
parent
1d1ca694c8
commit
af0802df30
|
@ -4,7 +4,7 @@ import * as mongodb from "./mongodb"
|
|||
import * as mysql from "./mysql"
|
||||
import * as mssql from "./mssql"
|
||||
import * as mariadb from "./mariadb"
|
||||
import { GenericContainer } from "testcontainers"
|
||||
import { GenericContainer, StartedTestContainer } from "testcontainers"
|
||||
import { testContainerUtils } from "@budibase/backend-core/tests"
|
||||
import lockfile from "proper-lockfile"
|
||||
import path from "path"
|
||||
|
@ -90,8 +90,12 @@ export async function startContainer(container: GenericContainer) {
|
|||
retries: 10,
|
||||
})
|
||||
|
||||
let startedContainer: StartedTestContainer
|
||||
try {
|
||||
const startedContainer = await container.start()
|
||||
startedContainer = await container.start()
|
||||
} finally {
|
||||
await lockfile.unlock(lockPath)
|
||||
}
|
||||
|
||||
const info = testContainerUtils.getContainerById(startedContainer.getId())
|
||||
if (!info) {
|
||||
|
@ -107,7 +111,4 @@ export async function startContainer(container: GenericContainer) {
|
|||
// that reason, we don't use testcontainers' `getExposedPort` function,
|
||||
// preferring instead our own method that guaranteed v4 ports.
|
||||
return testContainerUtils.getExposedV4Ports(info)
|
||||
} finally {
|
||||
await lockfile.unlock(lockPath)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue