Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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 @@ -50,6 +50,7 @@
"graphql": "^16.3.0",
"http-terminator": "^3.2.0",
"ioredis": "^5.4.1",
"is-port-reachable": "^4.0.0",
"kafkajs": "2.2.4",
"knex": "^2.5.1",
"lru-memoizer": "2.3.0",
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
59 changes: 30 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 isPortReachable from 'is-port-reachable';

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,32 @@ 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 isPortReachable(port, {
host: 'localhost',
timeout: 75_000,
}),
};
}),
).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
56 changes: 50 additions & 6 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 @@ -19208,6 +19222,11 @@ is-plain-object@^5.0.0:
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==

is-port-reachable@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-port-reachable/-/is-port-reachable-4.0.0.tgz#dac044091ef15319c8ab2f34604d8794181f8c2d"
integrity sha512-9UoipoxYmSk6Xy7QFgRv2HDyaysmgSG75TFQs6S+3pDM7ZhKTF/bskZV+0UlABHzKjNVhPjYCLfeZUEg1wXxig==

is-potential-custom-element-name@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5"
Expand Down Expand Up @@ -28343,7 +28362,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 +28474,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 +28502,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 +28644,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 @@ -31283,7 +31318,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 +31336,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