Skip to content

Commit a83d19c

Browse files
authored
test: restore testing of Azure Functions on node >=18.x (#3307)
This changes the workaround added in #3281. The core issue with testing with node >=18.x was fixed in [email protected] However, an issue testing with node v14.0.0 was introduced. We work around this by just not testing with node v14.0.0. Testing with the latest node v14.x passes. Refs: #3281 Fixes: #3279
1 parent f6de93c commit a83d19c

File tree

3 files changed

+180
-376
lines changed

3 files changed

+180
-376
lines changed

test/instrumentation/azure-functions/azure-functions.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const treekill = require('tree-kill')
2020
const { MockAPMServer } = require('../../_mock_apm_server')
2121
const { formatForTComment } = require('../../_utils')
2222

23-
if (semver.satisfies(process.version, '>=18')) {
24-
console.log(`# SKIP azure-functions-core-tools is currently busted for node >=18.x (currently running node ${process.version}): see https://github.com/elastic/apm-agent-nodejs/issues/3279 and https://github.com/Azure/azure-functions-core-tools/issues/3335`)
25-
process.exit()
26-
} else if (!semver.satisfies(process.version, '>=14 <19')) {
23+
if (!semver.satisfies(process.version, '>=14.1.0 <19')) {
24+
// The "14.1.0" version is selected to skip testing on Node.js v14.0.0
25+
// because of the issue described here:
26+
// https://github.com/elastic/apm-agent-nodejs/issues/3279#issuecomment-1532084620
2727
console.log(`# SKIP Azure Functions runtime ~4 does not support node ${process.version} (https://aka.ms/functions-node-versions)`)
2828
process.exit()
2929
} else if (os.platform() === 'win32') {
@@ -484,6 +484,15 @@ tape.test('azure functions', function (suite) {
484484
// Allow some time for an early fail of `func start`, e.g. if there is
485485
// already a user of port 7071...
486486
const onEarlyClose = code => {
487+
// Warning/Limitation: The 'npm ci' above installs platform-specific
488+
// binaries to "$fnAppDir/node_modules/azure-functions-core-tools/...",
489+
// which means a local test run on macOS followed by an attempted test run
490+
// in Docker will result in a crash:
491+
// node_tests_1 | # ["func start" stderr] /app/test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/node_modules/azure-functions-core-tools/bin/func: 1: Syntax error: "(" unexpected
492+
// node_tests_1 | not ok 2 "func start" failed early: code=2
493+
// For now the workaround is to manually clean that tree before running
494+
// tests on a separate OS:
495+
// rm -rf test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/node_modules
487496
t.fail(`"func start" failed early: code=${code}`)
488497
fnAppProc = null
489498
clearTimeout(earlyCloseTimer)

0 commit comments

Comments
 (0)