Skip to content

Commit 6d2942c

Browse files
nicohrubecclaude
andauthored
test(node): Use docker-compose healthchecks for service readiness (#20429)
Replace the stdout `readyMatches` approach in the node-integration-tests runner with Docker native healthchecks + `docker compose up -d --wait`. The old approach matched log substrings like `'port 5432'`, which can fire too early when the server is not actually yet accepting connections resulting in flakes. Each `docker-compose.yml` now defines a proper healthcheck (e.g. pg_isready) and the runner blocks on `--wait` until every service reports healthy. Also renames the redis-cache container to avoid collision with redis. Closes #20418 Closes #20335 --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b2033c0 commit 6d2942c

28 files changed

Lines changed: 131 additions & 69 deletions

File tree

.cursor/BUGBOT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Do not flag the issues below if they appear in tests.
6363
- Race conditions when waiting on multiple requests. Ensure that waiting checks are unique enough and don't depend on a hard order when there's a chance that telemetry can be sent in arbitrary order.
6464
- Timeouts or sleeps in tests. Instead suggest concrete events or other signals to wait on.
6565
- Flag usage of `getFirstEnvelope*`, `getMultipleEnvelope*` or related test helpers. These are NOT reliable anymore. Instead suggest helpers like `waitForTransaction`, `waitForError`, `waitForSpans`, etc.
66+
- Flag any new or modified `docker-compose.yml` under `dev-packages/node-integration-tests/suites/` or `dev-packages/node-core-integration-tests/suites/` where a service does not define a `healthcheck:`. The runner uses `docker compose up --wait` and relies on healthchecks to know when services are actually ready; without one the test will race the service's startup.
6667

6768
## Platform-safe code
6869

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

0 commit comments

Comments
 (0)