Skip to content

Commit 481c4c0

Browse files
committed
Wait for readiness
1 parent 3789c45 commit 481c4c0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/server/src/sdk/tests/datasources/validators.spec.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { GenericContainer } from "testcontainers"
22
import { generator } from "@budibase/backend-core/tests"
3+
import { Duration, TemporalUnit } from "node-duration"
4+
35
import postgres from "../../../integrations/postgres"
46
import mysql from "../../../integrations/mysql"
57
import couchdb from "../../../integrations/couchdb"
8+
import { SourceName } from "@budibase/types"
9+
import integrations from "../../../integrations"
610

711
jest.unmock("pg")
812
jest.unmock("mysql2/promise")
@@ -207,14 +211,24 @@ describe("datasource validators", () => {
207211

208212
let host: string, port: number
209213

214+
const password = "Str0Ng_p@ssW0rd!"
215+
210216
beforeAll(async () => {
211217
const container = await new GenericContainer(
212218
"mcr.microsoft.com/mssql/server"
213219
)
214220
.withExposedPorts(1433)
215221
.withEnv("ACCEPT_EULA", "Y")
216-
.withEnv("MSSQL_SA_PASSWORD", "Str0Ng_p@ssW0rd!")
222+
.withEnv("MSSQL_SA_PASSWORD", password)
217223
.withEnv("MSSQL_PID", "Developer")
224+
.withWaitStrategy(Wait.forHealthCheck())
225+
.withHealthCheck({
226+
test: `/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${password}" -Q "SELECT 1" -b -o /dev/null`,
227+
interval: new Duration(1000, TemporalUnit.MILLISECONDS),
228+
timeout: new Duration(3, TemporalUnit.SECONDS),
229+
retries: 20,
230+
startPeriod: new Duration(100, TemporalUnit.MILLISECONDS),
231+
})
218232
.start()
219233

220234
host = container.getContainerIpAddress()
@@ -224,7 +238,7 @@ describe("datasource validators", () => {
224238
it("test valid connection string", async () => {
225239
const result = await validator({
226240
user: "sa",
227-
password: "Str0Ng_p@ssW0rd!",
241+
password,
228242
server: host,
229243
port: port,
230244
database: "master",

0 commit comments

Comments
 (0)