Skip to content

Commit 00bd332

Browse files
authored
test(node): Streamline amqplib tests (#21723)
Combine this into a single test to ensure this does not run out of sync. Now, we simply use different docker files, leverage additionalDependencies, and otherwise use the same tests. Closes #21692 Closes #21693 (possibly, but let's see..)
1 parent edd795c commit 00bd332

7 files changed

Lines changed: 40 additions & 209 deletions

File tree

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

dev-packages/node-integration-tests/suites/tracing/amqplib-v1/instrument.mjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

dev-packages/node-integration-tests/suites/tracing/amqplib-v1/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

dev-packages/node-integration-tests/suites/tracing/amqplib-v1/scenario.mjs

Lines changed: 0 additions & 72 deletions
This file was deleted.

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

Lines changed: 0 additions & 67 deletions
This file was deleted.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
version: '3'
2-
31
services:
42
rabbitmq:
53
image: rabbitmq:management
6-
container_name: rabbitmq
74
environment:
85
- RABBITMQ_DEFAULT_USER=sentry
96
- RABBITMQ_DEFAULT_PASS=sentry

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

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,50 @@ describe('amqplib auto-instrumentation', () => {
2929
cleanupChildProcesses();
3030
});
3131

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

38-
await createTestRunner()
39-
.withDockerCompose({
40-
workingDirectory: [__dirname],
41-
})
42-
.expect({
43-
transaction: (transaction: TransactionEvent) => {
44-
receivedTransactions.push(transaction);
45-
},
46-
})
47-
.expect({
48-
transaction: (transaction: TransactionEvent) => {
49-
receivedTransactions.push(transaction);
46+
await createTestRunner()
47+
.withDockerCompose({
48+
workingDirectory: [__dirname],
49+
})
50+
.expect({
51+
transaction: (transaction: TransactionEvent) => {
52+
receivedTransactions.push(transaction);
53+
},
54+
})
55+
.expect({
56+
transaction: (transaction: TransactionEvent) => {
57+
receivedTransactions.push(transaction);
5058

51-
const producer = receivedTransactions.find(t => t.transaction === 'root span');
52-
const consumer = receivedTransactions.find(t => t.transaction === 'queue1 process');
59+
const producer = receivedTransactions.find(t => t.transaction === 'root span');
60+
const consumer = receivedTransactions.find(t => t.transaction === 'queue1 process');
5361

54-
expect(producer).toBeDefined();
55-
expect(consumer).toBeDefined();
62+
expect(producer).toBeDefined();
63+
expect(consumer).toBeDefined();
5664

57-
expect(producer!.spans?.length).toEqual(1);
58-
expect(producer!.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
65+
expect(producer!.spans?.length).toEqual(1);
66+
expect(producer!.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
5967

60-
expect(consumer!.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
61-
},
62-
})
63-
.start()
64-
.completed();
65-
});
68+
expect(consumer!.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
69+
},
70+
})
71+
.start()
72+
.completed();
73+
});
74+
},
75+
{ additionalDependencies },
76+
);
6677
});
6778
});

0 commit comments

Comments
 (0)