Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
version: '3'

services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=sentry
- RABBITMQ_DEFAULT_PASS=sentry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,50 @@ describe('amqplib auto-instrumentation', () => {
cleanupChildProcesses();
});

createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('should be able to send and receive messages', { timeout: 60_000 }, async () => {
// The producer ('root span') and consumer ('queue1 process') transactions can
// arrive in any order, so we collect them and assert after both are received.
const receivedTransactions: TransactionEvent[] = [];
describe.each([
['v1', { amqplib: '^1.0.0' }],
['v2', {}],
])('%s', (version, additionalDependencies) => {
createEsmAndCjsTests(
__dirname,
'scenario.mjs',
'instrument.mjs',
(createTestRunner, test) => {
test('should be able to send and receive messages', { timeout: 60_000 }, async () => {
// The producer ('root span') and consumer ('queue1 process') transactions can
// arrive in any order, so we collect them and assert after both are received.
const receivedTransactions: TransactionEvent[] = [];

await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
},
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);
},
})
.expect({
transaction: (transaction: TransactionEvent) => {
receivedTransactions.push(transaction);

const producer = receivedTransactions.find(t => t.transaction === 'root span');
const consumer = receivedTransactions.find(t => t.transaction === 'queue1 process');
const producer = receivedTransactions.find(t => t.transaction === 'root span');
const consumer = receivedTransactions.find(t => t.transaction === 'queue1 process');

expect(producer).toBeDefined();
expect(consumer).toBeDefined();
expect(producer).toBeDefined();
expect(consumer).toBeDefined();

expect(producer!.spans?.length).toEqual(1);
expect(producer!.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
expect(producer!.spans?.length).toEqual(1);
expect(producer!.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);

expect(consumer!.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
},
})
.start()
.completed();
});
expect(consumer!.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
},
})
.start()
.completed();
});
},
{ additionalDependencies },
);
});
});
Comment on lines +68 to 78

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The amqplib v1 and v2 test suites run in parallel but use the same hardcoded port 5672 in their shared docker-compose.yml, causing a port conflict.
Severity: HIGH

Suggested Fix

To prevent port conflicts, ensure each parallel test suite uses a unique port. This can be achieved by either running the v1 and v2 test suites sequentially or by dynamically assigning different ports to the RabbitMQ containers for each test suite. Modifying the test setup to avoid shared, hardcoded resources during parallel execution is necessary.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: dev-packages/node-integration-tests/suites/tracing/amqplib/test.ts#L68-L78

Potential issue: The test configuration uses Vitest's thread pool (`pool: 'threads'`)
without limiting the number of threads, enabling parallel execution. Both the v1 and v2
`amqplib` test suites, now wrapped in `describe.each`, use the same `docker-compose.yml`
file which hardcodes RabbitMQ to port `5672`. When these tests run concurrently on a
multi-core machine, they will attempt to start a Docker container on the same port,
resulting in a "port is already allocated" error and causing the test suite to fail.

Also affects:

  • dev-packages/node-integration-tests/suites/tracing/amqplib/docker-compose.yml:5~6

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this runs sequentially so should hopefully be OK

Loading