From 8ca76776fff308c133e30aa45edc916aa079f7ee Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Thu, 23 Jan 2025 11:39:55 +0100 Subject: [PATCH 1/3] remove checks --- integration-tests/automatic-log-submission.spec.js | 5 +---- integration-tests/cucumber/cucumber.spec.js | 4 +--- integration-tests/selenium/selenium.spec.js | 5 +---- packages/datadog-plugin-cucumber/test/index.spec.js | 4 ---- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/integration-tests/automatic-log-submission.spec.js b/integration-tests/automatic-log-submission.spec.js index eade717dcf1..e8d005de538 100644 --- a/integration-tests/automatic-log-submission.spec.js +++ b/integration-tests/automatic-log-submission.spec.js @@ -12,9 +12,6 @@ const { } = require('./helpers') const { FakeCiVisIntake } = require('./ci-visibility-intake') const webAppServer = require('./ci-visibility/web-app-server') -const { NODE_MAJOR } = require('../version') - -const cucumberVersion = NODE_MAJOR <= 16 ? '9' : 'latest' describe('test visibility automatic log submission', () => { let sandbox, cwd, receiver, childProcess, webAppPort @@ -23,7 +20,7 @@ describe('test visibility automatic log submission', () => { before(async () => { sandbox = await createSandbox([ 'mocha', - `@cucumber/cucumber@${cucumberVersion}`, + '@cucumber/cucumber', 'jest', 'winston', 'chai@4' diff --git a/integration-tests/cucumber/cucumber.spec.js b/integration-tests/cucumber/cucumber.spec.js index 00102734b28..ebda279f8c6 100644 --- a/integration-tests/cucumber/cucumber.spec.js +++ b/integration-tests/cucumber/cucumber.spec.js @@ -3,7 +3,6 @@ const { exec } = require('child_process') const getPort = require('get-port') -const semver = require('semver') const { assert } = require('chai') const { @@ -47,8 +46,7 @@ const { } = require('../../packages/dd-trace/src/plugins/util/test') const { DD_HOST_CPU_COUNT } = require('../../packages/dd-trace/src/plugins/util/env') -const isOldNode = semver.satisfies(process.version, '<=16') -const versions = ['7.0.0', isOldNode ? '9' : 'latest'] +const versions = ['7.0.0', 'latest'] const runTestsCommand = './node_modules/.bin/cucumber-js ci-visibility/features/*.feature' const runTestsWithCoverageCommand = './node_modules/nyc/bin/nyc.js -r=text-summary ' + diff --git a/integration-tests/selenium/selenium.spec.js b/integration-tests/selenium/selenium.spec.js index 50fc9d19568..74738967c9a 100644 --- a/integration-tests/selenium/selenium.spec.js +++ b/integration-tests/selenium/selenium.spec.js @@ -16,9 +16,6 @@ const { TEST_IS_RUM_ACTIVE, TEST_TYPE } = require('../../packages/dd-trace/src/plugins/util/test') -const { NODE_MAJOR } = require('../../version') - -const cucumberVersion = NODE_MAJOR <= 16 ? '9' : 'latest' const webAppServer = require('../ci-visibility/web-app-server') @@ -36,7 +33,7 @@ versionRange.forEach(version => { sandbox = await createSandbox([ 'mocha', 'jest', - `@cucumber/cucumber@${cucumberVersion}`, + '@cucumber/cucumber', 'chai@v4', `selenium-webdriver@${version}` ]) diff --git a/packages/datadog-plugin-cucumber/test/index.spec.js b/packages/datadog-plugin-cucumber/test/index.spec.js index a43a2a53509..863d5703063 100644 --- a/packages/datadog-plugin-cucumber/test/index.spec.js +++ b/packages/datadog-plugin-cucumber/test/index.spec.js @@ -1,7 +1,6 @@ 'use strict' const path = require('path') const { PassThrough } = require('stream') -const semver = require('semver') const proxyquire = require('proxyquire').noPreserveCache() const nock = require('nock') @@ -24,7 +23,6 @@ const { TEST_SOURCE_START } = require('../../dd-trace/src/plugins/util/test') -const { NODE_MAJOR } = require('../../../version') const { version: ddTraceVersion } = require('../../../package.json') const runCucumber = (version, Cucumber, requireName, featureName, testName) => { @@ -56,8 +54,6 @@ describe('Plugin', function () { let Cucumber this.timeout(10000) withVersions('cucumber', '@cucumber/cucumber', (version, _, specificVersion) => { - if (NODE_MAJOR <= 16 && semver.satisfies(specificVersion, '>=10')) return - afterEach(() => { // > If you want to run tests multiple times, you may need to clear Node's require cache // before subsequent calls in whichever manner best suits your needs. From 79abd4e07192bd511894cccb8807658dacc0f7dc Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Fri, 24 Jan 2025 16:21:09 +0100 Subject: [PATCH 2/3] PR feedback - remove other usages --- integration-tests/init.spec.js | 40 ++++++++----------- .../test/integration-test/client.spec.js | 6 +-- .../datadog-plugin-next/test/index.spec.js | 11 +---- .../test/integration-test/client.spec.js | 16 ++------ .../test/appsec/index.next.plugin.spec.js | 11 +---- 5 files changed, 24 insertions(+), 60 deletions(-) diff --git a/integration-tests/init.spec.js b/integration-tests/init.spec.js index fc274fb1480..c8c6a848ba8 100644 --- a/integration-tests/init.spec.js +++ b/integration-tests/init.spec.js @@ -7,7 +7,6 @@ const { } = require('./helpers') const path = require('path') const fs = require('fs') -const { DD_MAJOR } = require('../version') const DD_INJECTION_ENABLED = 'tracing' const DD_INJECT_FORCE = 'true' @@ -104,13 +103,13 @@ function testRuntimeVersionChecks (arg, filename) { it('should not initialize the tracer', () => doTest(`Aborting application instrumentation due to incompatible_runtime. Found incompatible runtime nodejs ${process.versions.node}, Supported runtimes: nodejs \ ->=${DD_MAJOR === 4 ? '16' : '18'}. +>=18. false `, ...telemetryAbort)) it('should initialize the tracer, if DD_INJECT_FORCE', () => doTestForced(`Aborting application instrumentation due to incompatible_runtime. Found incompatible runtime nodejs ${process.versions.node}, Supported runtimes: nodejs \ ->=${DD_MAJOR === 4 ? '16' : '18'}. +>=18. DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing. Application instrumentation bootstrapping complete true @@ -167,26 +166,19 @@ describe('init.js', () => { testRuntimeVersionChecks('require', 'init.js') }) -// ESM is not supportable prior to Node.js 12.17.0, 14.13.1 on the 14.x line, -// or on 18.0.0 in particular. -if ( - semver.satisfies(process.versions.node, '>=12.17.0') && - semver.satisfies(process.versions.node, '>=14.13.1') -) { - describe('initialize.mjs', () => { - useSandbox() - stubTracerIfNeeded() - - context('as --loader', () => { - testInjectionScenarios('loader', 'initialize.mjs', - process.versions.node !== '18.0.0') +describe('initialize.mjs', () => { + useSandbox() + stubTracerIfNeeded() + + context('as --loader', () => { + testInjectionScenarios('loader', 'initialize.mjs', + process.versions.node !== '18.0.0') + testRuntimeVersionChecks('loader', 'initialize.mjs') + }) + if (semver.satisfies(process.versions.node, '>=20.6.0')) { + context('as --import', () => { + testInjectionScenarios('import', 'initialize.mjs', true) testRuntimeVersionChecks('loader', 'initialize.mjs') }) - if (semver.satisfies(process.versions.node, '>=20.6.0')) { - context('as --import', () => { - testInjectionScenarios('import', 'initialize.mjs', true) - testRuntimeVersionChecks('loader', 'initialize.mjs') - }) - } - }) -} + } +}) diff --git a/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js b/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js index da680b7fa25..b23376bb3df 100644 --- a/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js @@ -7,10 +7,6 @@ const { spawnPluginIntegrationTestProc } = require('../../../../integration-tests/helpers') const { assert } = require('chai') -const { NODE_MAJOR } = require('../../../../version') - -// newer packages are not supported on older node versions -const range = NODE_MAJOR < 16 ? '<3' : '>=4.4.0' describe('esm', () => { let agent @@ -18,7 +14,7 @@ describe('esm', () => { let sandbox // test against later versions because server.mjs uses newer package syntax - withVersions('cassandra-driver', 'cassandra-driver', range, version => { + withVersions('cassandra-driver', 'cassandra-driver', '>=4.4.0', version => { before(async function () { this.timeout(20000) sandbox = await createSandbox([`'cassandra-driver@${version}'`], false, [ diff --git a/packages/datadog-plugin-next/test/index.spec.js b/packages/datadog-plugin-next/test/index.spec.js index caec28e3b1a..3fa35e4e280 100644 --- a/packages/datadog-plugin-next/test/index.spec.js +++ b/packages/datadog-plugin-next/test/index.spec.js @@ -9,15 +9,8 @@ const { execSync, spawn } = require('child_process') const agent = require('../../dd-trace/test/plugins/agent') const { writeFileSync, readdirSync } = require('fs') const { satisfies } = require('semver') -const { DD_MAJOR, NODE_MAJOR } = require('../../../version') const { rawExpectedSchema } = require('./naming') -const BUILD_COMMAND = NODE_MAJOR < 18 - ? 'yarn exec next build' - : 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build' -let VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1' -VERSIONS_TO_TEST = DD_MAJOR >= 4 ? VERSIONS_TO_TEST : '>=9.5 <11.1' - describe('Plugin', function () { let server let port @@ -26,7 +19,7 @@ describe('Plugin', function () { const satisfiesStandalone = version => satisfies(version, '>=12.0.0') // TODO: Figure out why 10.x tests are failing. - withVersions('next', 'next', VERSIONS_TO_TEST, version => { + withVersions('next', 'next', '>=11.1', version => { const pkg = require(`../../../versions/next@${version}/node_modules/next/package.json`) const startServer = ({ withConfig, standalone }, schemaVersion = 'v0', defaultToGlobalService = false) => { @@ -110,7 +103,7 @@ describe('Plugin', function () { } // building in-process makes tests fail for an unknown reason - execSync(BUILD_COMMAND, { + execSync('NODE_OPTIONS=--openssl-legacy-provider yarn exec next build', { cwd, env: { ...process.env, diff --git a/packages/datadog-plugin-next/test/integration-test/client.spec.js b/packages/datadog-plugin-next/test/integration-test/client.spec.js index 5bd4825ce93..841e9402584 100644 --- a/packages/datadog-plugin-next/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-next/test/integration-test/client.spec.js @@ -8,31 +8,21 @@ const { spawnPluginIntegrationTestProc } = require('../../../../integration-tests/helpers') const { assert } = require('chai') -const { NODE_MAJOR } = require('../../../../version') const hookFile = 'dd-trace/loader-hook.mjs' -const BUILD_COMMAND = NODE_MAJOR < 18 - ? 'yarn exec next build' - : 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build' -const NODE_OPTIONS = NODE_MAJOR < 18 - ? `--loader=${hookFile} --require dd-trace/init` - : `--loader=${hookFile} --require dd-trace/init --openssl-legacy-provider` - -const VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1' - describe('esm', () => { let agent let proc let sandbox // match versions tested with unit tests - withVersions('next', 'next', VERSIONS_TO_TEST, version => { + withVersions('next', 'next', '>=11.1', version => { before(async function () { // next builds slower in the CI, match timeout with unit tests this.timeout(120 * 1000) sandbox = await createSandbox([`'next@${version}'`, 'react@^18.2.0', 'react-dom@^18.2.0'], false, ['./packages/datadog-plugin-next/test/integration-test/*'], - BUILD_COMMAND) + 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build') }) after(async () => { @@ -50,7 +40,7 @@ describe('esm', () => { it('is instrumented', async () => { proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, { - NODE_OPTIONS + NODE_OPTIONS: `--loader=${hookFile} --require dd-trace/init --openssl-legacy-provider` }) return curlAndAssertMessage(agent, proc, ({ headers, payload }) => { assert.propertyVal(headers, 'host', `127.0.0.1:${agent.port}`) diff --git a/packages/dd-trace/test/appsec/index.next.plugin.spec.js b/packages/dd-trace/test/appsec/index.next.plugin.spec.js index 38cac8f375c..de711c5ff94 100644 --- a/packages/dd-trace/test/appsec/index.next.plugin.spec.js +++ b/packages/dd-trace/test/appsec/index.next.plugin.spec.js @@ -8,22 +8,15 @@ const { writeFileSync } = require('fs') const { satisfies } = require('semver') const path = require('path') -const { DD_MAJOR, NODE_MAJOR } = require('../../../../version') const agent = require('../plugins/agent') -const BUILD_COMMAND = NODE_MAJOR < 18 - ? 'yarn exec next build' - : 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build' -let VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1' -VERSIONS_TO_TEST = DD_MAJOR >= 4 ? VERSIONS_TO_TEST : '>=9.5 <11.1' - describe('test suite', () => { let server let port const satisfiesStandalone = version => satisfies(version, '>=12.0.0') - withVersions('next', 'next', VERSIONS_TO_TEST, version => { + withVersions('next', 'next', '>=11.1', version => { const realVersion = require(`../../../../versions/next@${version}`).version() function initApp (appName) { @@ -58,7 +51,7 @@ describe('test suite', () => { } // building in-process makes tests fail for an unknown reason - execSync(BUILD_COMMAND, { + execSync('NODE_OPTIONS=--openssl-legacy-provider yarn exec next build', { cwd, env: { ...process.env, From 8df66b6b9971f362458af38dffee8dbf09017dac Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Fri, 24 Jan 2025 17:20:23 +0100 Subject: [PATCH 3/3] undo part of changes in guardrails --- integration-tests/init.spec.js | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/integration-tests/init.spec.js b/integration-tests/init.spec.js index c8c6a848ba8..d9738a8160b 100644 --- a/integration-tests/init.spec.js +++ b/integration-tests/init.spec.js @@ -166,19 +166,26 @@ describe('init.js', () => { testRuntimeVersionChecks('require', 'init.js') }) -describe('initialize.mjs', () => { - useSandbox() - stubTracerIfNeeded() - - context('as --loader', () => { - testInjectionScenarios('loader', 'initialize.mjs', - process.versions.node !== '18.0.0') - testRuntimeVersionChecks('loader', 'initialize.mjs') - }) - if (semver.satisfies(process.versions.node, '>=20.6.0')) { - context('as --import', () => { - testInjectionScenarios('import', 'initialize.mjs', true) +// ESM is not supportable prior to Node.js 12.17.0, 14.13.1 on the 14.x line, +// or on 18.0.0 in particular. +if ( + semver.satisfies(process.versions.node, '>=12.17.0') && + semver.satisfies(process.versions.node, '>=14.13.1') +) { + describe('initialize.mjs', () => { + useSandbox() + stubTracerIfNeeded() + + context('as --loader', () => { + testInjectionScenarios('loader', 'initialize.mjs', + process.versions.node !== '18.0.0') testRuntimeVersionChecks('loader', 'initialize.mjs') }) - } -}) + if (semver.satisfies(process.versions.node, '>=20.6.0')) { + context('as --import', () => { + testInjectionScenarios('import', 'initialize.mjs', true) + testRuntimeVersionChecks('loader', 'initialize.mjs') + }) + } + }) +}