Skip to content

Commit 8ca9e3d

Browse files
Update healthcheck command
1 parent af977a9 commit 8ca9e3d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/modules/cockroachdb/src/cockroachdb-container.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ describe("CockroachDbContainer", () => {
88
it("should connect and return a query result", async () => {
99
const container = await new CockroachDbContainer().start();
1010

11-
console.log(container.getDatabase(), container.getHost(), container.getPort());
12-
1311
const client = new Client({
1412
host: container.getHost(),
1513
port: container.getPort(),

packages/modules/cockroachdb/src/cockroachdb-container.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@ export class CockroachDbContainer extends GenericContainer {
99

1010
constructor(image = "cockroachdb/cockroach:v24.3.5") {
1111
super(image);
12-
this.withExposedPorts(COCKROACH_PORT, COCKROACH_HTTP_PORT)
13-
.withCommand(["start-single-node", "--insecure", "--http-addr=0.0.0.0:" + COCKROACH_HTTP_PORT])
14-
.withHealthCheck({
15-
test: ["CMD-SHELL", "curl -f http://localhost:" + COCKROACH_HTTP_PORT + " || exit 1"],
16-
interval: 1000,
17-
timeout: 3000,
18-
retries: 5,
19-
startPeriod: 1000,
20-
})
21-
.withWaitStrategy(Wait.forHealthCheck());
12+
this.withExposedPorts(COCKROACH_PORT, COCKROACH_HTTP_PORT).withCommand([
13+
"start-single-node",
14+
"--insecure",
15+
`--http-addr=0.0.0.0:${COCKROACH_HTTP_PORT}`,
16+
]);
2217
}
2318

2419
public withDatabase(database: string): this {
@@ -36,6 +31,13 @@ export class CockroachDbContainer extends GenericContainer {
3631
COCKROACH_DATABASE: this.database,
3732
COCKROACH_USER: this.username,
3833
});
34+
this.withHealthCheck({
35+
test: ["CMD-SHELL", `cockroach sql --insecure -u ${this.username} -d ${this.database} -e "SELECT 1;"`],
36+
interval: 250,
37+
timeout: 1000,
38+
retries: 1000,
39+
});
40+
this.withWaitStrategy(Wait.forHealthCheck());
3941
return new StartedCockroachDbContainer(await super.start(), this.database, this.username);
4042
}
4143
}

0 commit comments

Comments
 (0)