Skip to content

Commit c5c967c

Browse files
nicohrubecclaude
andcommitted
test(node): Use docker-compose healthchecks for service readiness
Replace the stdout-scraping readyMatches approach in the node-integration-tests runner with Docker's native healthchecks + `docker compose up -d --wait`. The old approach matched log substrings like `'port 5432'` or `'port: 3306'`, which fire when the socket is bound but not when the server is actually accepting queries — producing intermittent CI flakes (e.g. #20418, #20335) under load. Each docker-compose.yml now defines a proper healthcheck (pg_isready, mysqladmin ping, redis-cli ping, rabbitmq-diagnostics, etc.), and the runner blocks on `--wait` until every service reports healthy. On failure, the runner surfaces `docker compose logs` for easier debugging. Also renames the redis-cache container to avoid collision with redis. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 617fede commit c5c967c

27 files changed

Lines changed: 130 additions & 69 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ services:
1010
ports:
1111
- '5672:5672'
1212
- '15672:15672'
13+
healthcheck:
14+
test: ['CMD-SHELL', 'rabbitmq-diagnostics -q ping']
15+
interval: 2s
16+
timeout: 10s
17+
retries: 30
18+
start_period: 15s
1319

1420
networks:
1521
default:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ describe('amqplib auto-instrumentation', () => {
3434
await createTestRunner()
3535
.withDockerCompose({
3636
workingDirectory: [__dirname],
37-
readyMatches: ['Time to start RabbitMQ'],
3837
})
3938
.expect({
4039
transaction: (transaction: TransactionEvent) => {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ services:
55
container_name: integration-tests-kafka
66
ports:
77
- '9092:9092'
8+
healthcheck:
9+
test: ['CMD-SHELL', '/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092']
10+
interval: 2s
11+
timeout: 5s
12+
retries: 30
13+
start_period: 15s

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe('kafkajs', () => {
1616
await createRunner()
1717
.withDockerCompose({
1818
workingDirectory: [__dirname],
19-
readyMatches: ['9092'],
2019
})
2120
.expect({
2221
transaction: (transaction: TransactionEvent) => {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ services:
1010
environment:
1111
MYSQL_ROOT_PASSWORD: docker
1212
MYSQL_DATABASE: tests
13+
healthcheck:
14+
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 -uroot -pdocker']
15+
interval: 2s
16+
timeout: 3s
17+
retries: 30
18+
start_period: 10s

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('knex auto instrumentation', () => {
6363
};
6464

6565
await createRunner()
66-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] })
66+
.withDockerCompose({ workingDirectory: [__dirname] })
6767
.expect({ transaction: EXPECTED_TRANSACTION })
6868
.start()
6969
.completed();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ services:
1111
POSTGRES_USER: test
1212
POSTGRES_PASSWORD: test
1313
POSTGRES_DB: tests
14+
healthcheck:
15+
test: ['CMD-SHELL', 'pg_isready -U test -d tests']
16+
interval: 2s
17+
timeout: 3s
18+
retries: 30
19+
start_period: 5s

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('knex auto instrumentation', () => {
6161
};
6262

6363
await createRunner()
64-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
64+
.withDockerCompose({ workingDirectory: [__dirname] })
6565
.expect({ transaction: EXPECTED_TRANSACTION })
6666
.start()
6767
.completed();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ services:
77
- '3306:3306'
88
environment:
99
MYSQL_ROOT_PASSWORD: password
10+
healthcheck:
11+
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 -uroot -ppassword']
12+
interval: 2s
13+
timeout: 3s
14+
retries: 30
15+
start_period: 10s

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('mysql2 auto instrumentation', () => {
3434
};
3535

3636
await createRunner(__dirname, 'scenario.js')
37-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] })
37+
.withDockerCompose({ workingDirectory: [__dirname] })
3838
.expect({ transaction: EXPECTED_TRANSACTION })
3939
.start()
4040
.completed();

0 commit comments

Comments
 (0)