Skip to content

Commit bf28ddd

Browse files
[test optimization] Remove node 16 checks in tests (#5149)
1 parent 29c26b0 commit bf28ddd

File tree

9 files changed

+13
-54
lines changed

9 files changed

+13
-54
lines changed

integration-tests/automatic-log-submission.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ const {
1212
} = require('./helpers')
1313
const { FakeCiVisIntake } = require('./ci-visibility-intake')
1414
const webAppServer = require('./ci-visibility/web-app-server')
15-
const { NODE_MAJOR } = require('../version')
16-
17-
const cucumberVersion = NODE_MAJOR <= 16 ? '9' : 'latest'
1815

1916
describe('test visibility automatic log submission', () => {
2017
let sandbox, cwd, receiver, childProcess, webAppPort
@@ -23,7 +20,7 @@ describe('test visibility automatic log submission', () => {
2320
before(async () => {
2421
sandbox = await createSandbox([
2522
'mocha',
26-
`@cucumber/cucumber@${cucumberVersion}`,
23+
'@cucumber/cucumber',
2724
'jest',
2825
'winston',
2926
'chai@4'

integration-tests/cucumber/cucumber.spec.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const { exec } = require('child_process')
44

55
const getPort = require('get-port')
6-
const semver = require('semver')
76
const { assert } = require('chai')
87

98
const {
@@ -47,8 +46,7 @@ const {
4746
} = require('../../packages/dd-trace/src/plugins/util/test')
4847
const { DD_HOST_CPU_COUNT } = require('../../packages/dd-trace/src/plugins/util/env')
4948

50-
const isOldNode = semver.satisfies(process.version, '<=16')
51-
const versions = ['7.0.0', isOldNode ? '9' : 'latest']
49+
const versions = ['7.0.0', 'latest']
5250

5351
const runTestsCommand = './node_modules/.bin/cucumber-js ci-visibility/features/*.feature'
5452
const runTestsWithCoverageCommand = './node_modules/nyc/bin/nyc.js -r=text-summary ' +

integration-tests/init.spec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
} = require('./helpers')
88
const path = require('path')
99
const fs = require('fs')
10-
const { DD_MAJOR } = require('../version')
1110

1211
const DD_INJECTION_ENABLED = 'tracing'
1312
const DD_INJECT_FORCE = 'true'
@@ -104,13 +103,13 @@ function testRuntimeVersionChecks (arg, filename) {
104103
it('should not initialize the tracer', () =>
105104
doTest(`Aborting application instrumentation due to incompatible_runtime.
106105
Found incompatible runtime nodejs ${process.versions.node}, Supported runtimes: nodejs \
107-
>=${DD_MAJOR === 4 ? '16' : '18'}.
106+
>=18.
108107
false
109108
`, ...telemetryAbort))
110109
it('should initialize the tracer, if DD_INJECT_FORCE', () =>
111110
doTestForced(`Aborting application instrumentation due to incompatible_runtime.
112111
Found incompatible runtime nodejs ${process.versions.node}, Supported runtimes: nodejs \
113-
>=${DD_MAJOR === 4 ? '16' : '18'}.
112+
>=18.
114113
DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing.
115114
Application instrumentation bootstrapping complete
116115
true

integration-tests/selenium/selenium.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ const {
1616
TEST_IS_RUM_ACTIVE,
1717
TEST_TYPE
1818
} = require('../../packages/dd-trace/src/plugins/util/test')
19-
const { NODE_MAJOR } = require('../../version')
20-
21-
const cucumberVersion = NODE_MAJOR <= 16 ? '9' : 'latest'
2219

2320
const webAppServer = require('../ci-visibility/web-app-server')
2421

@@ -36,7 +33,7 @@ versionRange.forEach(version => {
3633
sandbox = await createSandbox([
3734
'mocha',
3835
'jest',
39-
`@cucumber/cucumber@${cucumberVersion}`,
36+
'@cucumber/cucumber',
4037
'chai@v4',
4138
`selenium-webdriver@${version}`
4239
])

packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ const {
77
spawnPluginIntegrationTestProc
88
} = require('../../../../integration-tests/helpers')
99
const { assert } = require('chai')
10-
const { NODE_MAJOR } = require('../../../../version')
11-
12-
// newer packages are not supported on older node versions
13-
const range = NODE_MAJOR < 16 ? '<3' : '>=4.4.0'
1410

1511
describe('esm', () => {
1612
let agent
1713
let proc
1814
let sandbox
1915

2016
// test against later versions because server.mjs uses newer package syntax
21-
withVersions('cassandra-driver', 'cassandra-driver', range, version => {
17+
withVersions('cassandra-driver', 'cassandra-driver', '>=4.4.0', version => {
2218
before(async function () {
2319
this.timeout(20000)
2420
sandbox = await createSandbox([`'cassandra-driver@${version}'`], false, [

packages/datadog-plugin-cucumber/test/index.spec.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22
const path = require('path')
33
const { PassThrough } = require('stream')
4-
const semver = require('semver')
54

65
const proxyquire = require('proxyquire').noPreserveCache()
76
const nock = require('nock')
@@ -24,7 +23,6 @@ const {
2423
TEST_SOURCE_START
2524
} = require('../../dd-trace/src/plugins/util/test')
2625

27-
const { NODE_MAJOR } = require('../../../version')
2826
const { version: ddTraceVersion } = require('../../../package.json')
2927

3028
const runCucumber = (version, Cucumber, requireName, featureName, testName) => {
@@ -56,8 +54,6 @@ describe('Plugin', function () {
5654
let Cucumber
5755
this.timeout(10000)
5856
withVersions('cucumber', '@cucumber/cucumber', (version, _, specificVersion) => {
59-
if (NODE_MAJOR <= 16 && semver.satisfies(specificVersion, '>=10')) return
60-
6157
afterEach(() => {
6258
// > If you want to run tests multiple times, you may need to clear Node's require cache
6359
// before subsequent calls in whichever manner best suits your needs.

packages/datadog-plugin-next/test/index.spec.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ const { execSync, spawn } = require('child_process')
99
const agent = require('../../dd-trace/test/plugins/agent')
1010
const { writeFileSync, readdirSync } = require('fs')
1111
const { satisfies } = require('semver')
12-
const { DD_MAJOR, NODE_MAJOR } = require('../../../version')
1312
const { rawExpectedSchema } = require('./naming')
1413

15-
const BUILD_COMMAND = NODE_MAJOR < 18
16-
? 'yarn exec next build'
17-
: 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build'
18-
let VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1'
19-
VERSIONS_TO_TEST = DD_MAJOR >= 4 ? VERSIONS_TO_TEST : '>=9.5 <11.1'
20-
2114
describe('Plugin', function () {
2215
let server
2316
let port
@@ -26,7 +19,7 @@ describe('Plugin', function () {
2619
const satisfiesStandalone = version => satisfies(version, '>=12.0.0')
2720

2821
// TODO: Figure out why 10.x tests are failing.
29-
withVersions('next', 'next', VERSIONS_TO_TEST, version => {
22+
withVersions('next', 'next', '>=11.1', version => {
3023
const pkg = require(`../../../versions/next@${version}/node_modules/next/package.json`)
3124

3225
const startServer = ({ withConfig, standalone }, schemaVersion = 'v0', defaultToGlobalService = false) => {
@@ -110,7 +103,7 @@ describe('Plugin', function () {
110103
}
111104

112105
// building in-process makes tests fail for an unknown reason
113-
execSync(BUILD_COMMAND, {
106+
execSync('NODE_OPTIONS=--openssl-legacy-provider yarn exec next build', {
114107
cwd,
115108
env: {
116109
...process.env,

packages/datadog-plugin-next/test/integration-test/client.spec.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,21 @@ const {
88
spawnPluginIntegrationTestProc
99
} = require('../../../../integration-tests/helpers')
1010
const { assert } = require('chai')
11-
const { NODE_MAJOR } = require('../../../../version')
1211

1312
const hookFile = 'dd-trace/loader-hook.mjs'
1413

15-
const BUILD_COMMAND = NODE_MAJOR < 18
16-
? 'yarn exec next build'
17-
: 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build'
18-
const NODE_OPTIONS = NODE_MAJOR < 18
19-
? `--loader=${hookFile} --require dd-trace/init`
20-
: `--loader=${hookFile} --require dd-trace/init --openssl-legacy-provider`
21-
22-
const VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1'
23-
2414
describe('esm', () => {
2515
let agent
2616
let proc
2717
let sandbox
2818
// match versions tested with unit tests
29-
withVersions('next', 'next', VERSIONS_TO_TEST, version => {
19+
withVersions('next', 'next', '>=11.1', version => {
3020
before(async function () {
3121
// next builds slower in the CI, match timeout with unit tests
3222
this.timeout(120 * 1000)
3323
sandbox = await createSandbox([`'next@${version}'`, 'react@^18.2.0', 'react-dom@^18.2.0'],
3424
false, ['./packages/datadog-plugin-next/test/integration-test/*'],
35-
BUILD_COMMAND)
25+
'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build')
3626
})
3727

3828
after(async () => {
@@ -50,7 +40,7 @@ describe('esm', () => {
5040

5141
it('is instrumented', async () => {
5242
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, {
53-
NODE_OPTIONS
43+
NODE_OPTIONS: `--loader=${hookFile} --require dd-trace/init --openssl-legacy-provider`
5444
})
5545
return curlAndAssertMessage(agent, proc, ({ headers, payload }) => {
5646
assert.propertyVal(headers, 'host', `127.0.0.1:${agent.port}`)

packages/dd-trace/test/appsec/index.next.plugin.spec.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,15 @@ const { writeFileSync } = require('fs')
88
const { satisfies } = require('semver')
99
const path = require('path')
1010

11-
const { DD_MAJOR, NODE_MAJOR } = require('../../../../version')
1211
const agent = require('../plugins/agent')
1312

14-
const BUILD_COMMAND = NODE_MAJOR < 18
15-
? 'yarn exec next build'
16-
: 'NODE_OPTIONS=--openssl-legacy-provider yarn exec next build'
17-
let VERSIONS_TO_TEST = NODE_MAJOR < 18 ? '>=11.1 <13.2' : '>=11.1'
18-
VERSIONS_TO_TEST = DD_MAJOR >= 4 ? VERSIONS_TO_TEST : '>=9.5 <11.1'
19-
2013
describe('test suite', () => {
2114
let server
2215
let port
2316

2417
const satisfiesStandalone = version => satisfies(version, '>=12.0.0')
2518

26-
withVersions('next', 'next', VERSIONS_TO_TEST, version => {
19+
withVersions('next', 'next', '>=11.1', version => {
2720
const realVersion = require(`../../../../versions/next@${version}`).version()
2821

2922
function initApp (appName) {
@@ -58,7 +51,7 @@ describe('test suite', () => {
5851
}
5952

6053
// building in-process makes tests fail for an unknown reason
61-
execSync(BUILD_COMMAND, {
54+
execSync('NODE_OPTIONS=--openssl-legacy-provider yarn exec next build', {
6255
cwd,
6356
env: {
6457
...process.env,

0 commit comments

Comments
 (0)