Skip to content
Closed
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
1 change: 1 addition & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"reflect-metadata": "0.2.1",
"rxjs": "^7.8.1",
"tedious": "^18.6.1",
"wait-port": "^1.1.0",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('amqplib auto-instrumentation', () => {
await createRunner(__dirname, 'scenario-message.ts')
.withDockerCompose({
workingDirectory: [__dirname],
readyMatches: ['Time to start RabbitMQ'],
waitForPorts: [5672],
})
.expect({
transaction: (transaction: TransactionEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('kafkajs', () => {
await createRunner(__dirname, 'scenario.js')
.withDockerCompose({
workingDirectory: [__dirname],
readyMatches: ['9092'],
waitForPorts: [9092],
})
.expect({
transaction: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('knex auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-withPostgres.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [5432] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('knex auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-withMysql2.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [3306] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('mysql2 auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [3306] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('postgres auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [5432] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Prisma ORM v5 Tests', () => {
await createRunner(__dirname, 'scenario.js')
.withDockerCompose({
workingDirectory: [__dirname],
readyMatches: ['port 5432'],
waitForPorts: [5432],
setupCommand: 'yarn && yarn setup',
})
.expect({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Prisma ORM v6 Tests', () => {
await createRunner(__dirname, 'scenario.js')
.withDockerCompose({
workingDirectory: [__dirname],
readyMatches: ['port 5432'],
waitForPorts: [5432],
setupCommand: 'yarn && yarn setup',
})
.expect({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('redis cache auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-ioredis.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [6379] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('redis cache auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-ioredis.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [6379] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('redis cache auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-redis-4.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [6379] })
.expect({ transaction: EXPECTED_REDIS_CONNECT })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('redis auto instrumentation', () => {
};

await createRunner(__dirname, 'scenario-ioredis.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [6379] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Sentry.init({

const { Connection, Request } = require('tedious');

const config = {
const connection = new Connection({
server: '127.0.0.1',
authentication: {
type: 'default',
Expand All @@ -23,9 +23,7 @@ const config = {
port: 1433,
encrypt: false,
},
};

const connection = new Connection(config);
});

function executeAllStatements(span) {
executeStatement('SELECT 1 + 1 AS solution', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, describe, expect, test } from 'vitest';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

describe('tedious auto instrumentation', {timeout: 75_000}, () => {
describe('tedious auto instrumentation', { timeout: 75_000 }, () => {
afterAll(() => {
cleanupChildProcesses();
});
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('tedious auto instrumentation', {timeout: 75_000}, () => {
};

await createRunner(__dirname, 'scenario.js')
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['1433'] })
.withDockerCompose({ workingDirectory: [__dirname], waitForPorts: [1433] })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
Expand Down
64 changes: 35 additions & 29 deletions dev-packages/node-integration-tests/utils/runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-lines */
import { execSync, spawn, spawnSync } from 'child_process';
import { spawn, spawnSync } from 'child_process';
import { existsSync } from 'fs';
import { join } from 'path';
import { normalize } from '@sentry/core';
Expand All @@ -25,6 +25,7 @@ import {
assertSentryTransaction,
} from './assertions';
import { createBasicSentryServer } from './server';
import waitPort from 'wait-port';

const CLEANUP_STEPS = new Set<VoidFunction>();

Expand Down Expand Up @@ -56,14 +57,14 @@ interface DockerOptions {
* The working directory to run docker compose in
*/
workingDirectory: string[];
/**
* The strings to look for in the output to know that the docker compose is ready for the test to be run
*/
readyMatches: string[];
/**
* The command to run after docker compose is up
*/
setupCommand?: string;
/**
* Ports to watch until proceeding to know that the containers are ready for the tests to be run
*/
waitForPorts: number[];
}

/**
Expand All @@ -84,32 +85,37 @@ async function runDockerCompose(options: DockerOptions): Promise<VoidFunction> {
// ensure we're starting fresh
close();

const child = spawn('docker', ['compose', 'up'], { cwd });

const timeout = setTimeout(() => {
close();
reject(new Error('Timed out waiting for docker-compose'));
}, 75_000);

function newData(data: Buffer): void {
const text = data.toString('utf8');

if (process.env.DEBUG) log(text);

for (const match of options.readyMatches) {
if (text.includes(match)) {
child.stdout.removeAllListeners();
clearTimeout(timeout);
if (options.setupCommand) {
execSync(options.setupCommand, { cwd, stdio: 'inherit' });
}
spawn('docker', ['compose', 'up'], { cwd });

Promise.all(
(options.waitForPorts ?? []).map(async port => {
return {
port: port,
isReachable: (
await waitPort({
port,
host: 'localhost',
timeout: 75_000,
interval: 1_000,
output: 'silent',
})
).open,
};
}),
).then(
isReachableResults => {
if (isReachableResults.some(({ isReachable }) => !isReachable)) {
close();
reject(`Timed out waiting for docker-compose ${JSON.stringify(isReachableResults)}`);
} else {
resolve(close);
}
}
}

child.stdout.on('data', newData);
child.stderr.on('data', newData);
},
e => {
close();
reject(e);
},
);
});
}

Expand Down
62 changes: 55 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8509,7 +8509,12 @@
dependencies:
"@types/unist" "*"

"@types/history-4@npm:@types/[email protected]", "@types/history-5@npm:@types/[email protected]":
"@types/history-4@npm:@types/[email protected]":
version "4.7.8"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934"
integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA==

"@types/history-5@npm:@types/[email protected]":
version "4.7.8"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934"
integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA==
Expand Down Expand Up @@ -10879,7 +10884,16 @@ aws-ssl-profiles@^1.1.1:
resolved "https://registry.yarnpkg.com/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz#157dd77e9f19b1d123678e93f120e6f193022641"
integrity sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==

[email protected], axios@^1.0.0, axios@^1.7.7:
[email protected]:
version "1.8.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.8.2.tgz#fabe06e241dfe83071d4edfbcaa7b1c3a40f7979"
integrity sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.0.0, axios@^1.7.7:
version "1.7.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f"
integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==
Expand Down Expand Up @@ -12883,7 +12897,7 @@ commander@^8.0.0, commander@^8.3.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==

commander@^9.0.0:
commander@^9.0.0, commander@^9.3.0:
version "9.5.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30"
integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==
Expand Down Expand Up @@ -28343,7 +28357,16 @@ string-template@~0.2.1:
resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"
integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=

"string-width-cjs@npm:string-width@^4.2.0", [email protected], "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -28446,7 +28469,7 @@ stringify-object@^3.2.1:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", [email protected], strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -28474,6 +28497,13 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -28609,7 +28639,7 @@ [email protected], stylus@^0.59.0:
sax "~1.2.4"
source-map "^0.7.3"

sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills:
sucrase@^3.27.0, sucrase@^3.35.0:
version "3.36.0"
resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061"
dependencies:
Expand Down Expand Up @@ -30713,6 +30743,15 @@ w3c-xmlserializer@^4.0.0:
dependencies:
xml-name-validator "^4.0.0"

wait-port@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/wait-port/-/wait-port-1.1.0.tgz#e5d64ee071118d985e2b658ae7ad32b2ce29b6b5"
integrity sha512-3e04qkoN3LxTMLakdqeWth8nih8usyg+sf1Bgdf9wwUkp05iuK1eSY/QpLvscT/+F/gA89+LpUmmgBtesbqI2Q==
dependencies:
chalk "^4.1.2"
commander "^9.3.0"
debug "^4.3.4"

walk-sync@^0.3.0, walk-sync@^0.3.1, walk-sync@^0.3.3:
version "0.3.4"
resolved "https://registry.yarnpkg.com/walk-sync/-/walk-sync-0.3.4.tgz#cf78486cc567d3a96b5b2237c6108017a5ffb9a4"
Expand Down Expand Up @@ -31283,7 +31322,7 @@ wrangler@^3.67.1:
optionalDependencies:
fsevents "~2.3.2"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", [email protected], wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -31301,6 +31340,15 @@ wrap-ansi@^6.0.1:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading