Skip to content

Commit fd55ebc

Browse files
JPeer264claude
andcommitted
fixup! test(node): Fix flaky postgresjs integration test
Use a docker-compose healthcheck + ready-gate sidecar so readiness is gated on pg_isready succeeding inside the db container. The previous match on 'database system is ready to accept connections' fired on the initdb bootstrap postmaster and raced with its shutdown, causing ECONNRESET on CI under load. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7f4db78 commit fd55ebc

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

dev-packages/node-integration-tests/suites/tracing/postgresjs/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ services:
1111
POSTGRES_USER: test
1212
POSTGRES_PASSWORD: test
1313
POSTGRES_DB: test_db
14+
healthcheck:
15+
test: ['CMD-SHELL', 'pg_isready -U test -d test_db']
16+
interval: 500ms
17+
timeout: 3s
18+
retries: 60
19+
start_period: 2s
20+
21+
ready-gate:
22+
image: busybox
23+
depends_on:
24+
db:
25+
condition: service_healthy
26+
command: ['echo', 'postgresjs-ready']

dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('postgresjs auto instrumentation', () => {
220220
await createRunner(__dirname, 'scenario.js')
221221
.withDockerCompose({
222222
workingDirectory: [__dirname],
223-
readyMatches: ['database system is ready to accept connections'],
223+
readyMatches: ['postgresjs-ready'],
224224
})
225225
.expect({ transaction: EXPECTED_TRANSACTION })
226226
.expect({ event: EXPECTED_ERROR_EVENT })
@@ -443,7 +443,7 @@ describe('postgresjs auto instrumentation', () => {
443443
.withFlags('--import', `${__dirname}/instrument.mjs`)
444444
.withDockerCompose({
445445
workingDirectory: [__dirname],
446-
readyMatches: ['database system is ready to accept connections'],
446+
readyMatches: ['postgresjs-ready'],
447447
})
448448
.expect({ transaction: EXPECTED_TRANSACTION })
449449
.expect({ event: EXPECTED_ERROR_EVENT })
@@ -540,7 +540,7 @@ describe('postgresjs auto instrumentation', () => {
540540
.withFlags('--require', `${__dirname}/instrument-requestHook.cjs`)
541541
.withDockerCompose({
542542
workingDirectory: [__dirname],
543-
readyMatches: ['database system is ready to accept connections'],
543+
readyMatches: ['postgresjs-ready'],
544544
})
545545
.expect({ transaction: EXPECTED_TRANSACTION })
546546
.start()
@@ -636,7 +636,7 @@ describe('postgresjs auto instrumentation', () => {
636636
.withFlags('--import', `${__dirname}/instrument-requestHook.mjs`)
637637
.withDockerCompose({
638638
workingDirectory: [__dirname],
639-
readyMatches: ['database system is ready to accept connections'],
639+
readyMatches: ['postgresjs-ready'],
640640
})
641641
.expect({ transaction: EXPECTED_TRANSACTION })
642642
.start()
@@ -720,7 +720,7 @@ describe('postgresjs auto instrumentation', () => {
720720
await createRunner(__dirname, 'scenario-url.cjs')
721721
.withDockerCompose({
722722
workingDirectory: [__dirname],
723-
readyMatches: ['database system is ready to accept connections'],
723+
readyMatches: ['postgresjs-ready'],
724724
})
725725
.expect({ transaction: EXPECTED_TRANSACTION })
726726
.start()
@@ -804,7 +804,7 @@ describe('postgresjs auto instrumentation', () => {
804804
.withFlags('--import', `${__dirname}/instrument.mjs`)
805805
.withDockerCompose({
806806
workingDirectory: [__dirname],
807-
readyMatches: ['database system is ready to accept connections'],
807+
readyMatches: ['postgresjs-ready'],
808808
})
809809
.expect({ transaction: EXPECTED_TRANSACTION })
810810
.start()
@@ -886,7 +886,7 @@ describe('postgresjs auto instrumentation', () => {
886886
await createRunner(__dirname, 'scenario-unsafe.cjs')
887887
.withDockerCompose({
888888
workingDirectory: [__dirname],
889-
readyMatches: ['database system is ready to accept connections'],
889+
readyMatches: ['postgresjs-ready'],
890890
})
891891
.expect({ transaction: EXPECTED_TRANSACTION })
892892
.start()
@@ -969,7 +969,7 @@ describe('postgresjs auto instrumentation', () => {
969969
.withFlags('--import', `${__dirname}/instrument.mjs`)
970970
.withDockerCompose({
971971
workingDirectory: [__dirname],
972-
readyMatches: ['database system is ready to accept connections'],
972+
readyMatches: ['postgresjs-ready'],
973973
})
974974
.expect({ transaction: EXPECTED_TRANSACTION })
975975
.start()

0 commit comments

Comments
 (0)