-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test optimization] Remove node 16 checks in tests #5149
base: master
Are you sure you want to change the base?
Conversation
Overall package sizeSelf size: 8.52 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | @datadog/libdatadog | 0.4.0 | 29.44 MB | 29.44 MB | | @datadog/native-appsec | 8.4.0 | 19.25 MB | 19.26 MB | | @datadog/native-iast-taint-tracking | 3.2.0 | 13.9 MB | 13.91 MB | | @datadog/pprof | 5.4.1 | 9.76 MB | 10.13 MB | | protobufjs | 7.2.5 | 2.77 MB | 5.16 MB | | @datadog/native-iast-rewriter | 2.6.1 | 2.59 MB | 2.73 MB | | @opentelemetry/core | 1.14.0 | 872.87 kB | 1.47 MB | | @datadog/native-metrics | 3.1.0 | 1.06 MB | 1.46 MB | | @opentelemetry/api | 1.8.0 | 1.21 MB | 1.21 MB | | import-in-the-middle | 1.11.2 | 112.74 kB | 826.22 kB | | source-map | 0.7.4 | 226 kB | 226 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | lru-cache | 7.18.3 | 133.92 kB | 133.92 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | @datadog/sketches-js | 2.1.0 | 109.9 kB | 109.9 kB | | semver | 7.6.3 | 95.82 kB | 95.82 kB | | lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB | | ignore | 5.3.1 | 51.46 kB | 51.46 kB | | shell-quote | 1.8.1 | 44.96 kB | 44.96 kB | | istanbul-lib-coverage | 3.2.0 | 29.34 kB | 29.34 kB | | rfdc | 1.3.1 | 25.21 kB | 25.21 kB | | @isaacs/ttlcache | 1.4.1 | 25.2 kB | 25.2 kB | | tlhunter-sorted-set | 0.1.0 | 24.94 kB | 24.94 kB | | limiter | 1.1.5 | 23.17 kB | 23.17 kB | | dc-polyfill | 0.1.4 | 23.1 kB | 23.1 kB | | retry | 0.13.1 | 18.85 kB | 18.85 kB | | jest-docblock | 29.7.0 | 8.99 kB | 12.76 kB | | crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB | | ttl-set | 1.0.0 | 4.61 kB | 9.69 kB | | path-to-regexp | 0.1.12 | 6.6 kB | 6.6 kB | | koalas | 1.0.2 | 6.47 kB | 6.47 kB | | module-details-from-path | 1.0.3 | 4.47 kB | 4.47 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2025-01-23 10:53:09 Comparing candidate commit 8ca7677 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 907 metrics, 26 unstable metrics. |
I found a bunch of other places like this. Feel free to include it in this PR, or I can also just make a follow up PR afterwards. This is the diff: diff --git a/integration-tests/init.spec.js b/integration-tests/init.spec.js
index fc274fb14..4dee942e4 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,18 @@ 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-next/test/index.spec.js b/packages/datadog-plugin-next/test/index.spec.js
index caec28e3b..3fa35e4e2 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 5bd4825ce..841e94025 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 38cac8f37..de711c5ff 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, |
What does this PR do?
Remove checks for node 16
Motivation
We're not running tests in node 16 any more
Plugin Checklist
No tests needed, just the ones we already have.