-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: avoid test crash getting @elastic/elasticsearch version (#2351)
The tests were using `require('@elastic/elasticsearch/package.json')` which runs afoul of EOL'd folder mappings in "exports" (https://nodejs.org/api/all.html#DEP0148) with current ES client versions and the latest node v17 nightly. Fixes: #2350
- Loading branch information
Showing
4 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,11 @@ const agent = require('../../../..').start({ | |
spanFramesMinDuration: -1 // always capture stack traces with spans | ||
}) | ||
|
||
const { safeGetPackageVersion } = require('../../../_utils') | ||
|
||
// Skip (exit the process) if this package version doesn't support this version | ||
// of node. | ||
const esVersion = require('@elastic/elasticsearch/package.json').version | ||
const esVersion = safeGetPackageVersion('@elastic/elasticsearch') | ||
const semver = require('semver') | ||
if (semver.lt(process.version, '10.0.0') && semver.gte(esVersion, '7.12.0')) { | ||
console.log(`# SKIP @elastic/elasticsearch@${esVersion} does not support node ${process.version}`) | ||
|
@@ -34,7 +36,6 @@ const { MockES } = require('./_mock_es') | |
|
||
const host = (process.env.ES_HOST || 'localhost') + ':9200' | ||
const node = 'http://' + host | ||
const pkgVersion = require('@elastic/elasticsearch/package.json').version | ||
|
||
test('client.ping with promise', function (t) { | ||
resetAgent(checkDataAndEnd(t, 'HEAD', '/', null)) | ||
|
@@ -334,7 +335,7 @@ test('DeserializationError', function (t) { | |
}) | ||
}) | ||
|
||
if (semver.gte(pkgVersion, '7.14.0')) { | ||
if (semver.gte(esVersion, '7.14.0')) { | ||
test('ProductNotSupportedError', function (t) { | ||
// Create a mock Elasticsearch server that responds to "GET /" with a body | ||
// that triggers ProductNotSupportedError. | ||
|
@@ -377,7 +378,7 @@ if (semver.gte(pkgVersion, '7.14.0')) { | |
}) | ||
} | ||
|
||
if (semver.gte(pkgVersion, '7.7.0')) { | ||
if (semver.gte(esVersion, '7.7.0')) { | ||
// Abort handling was added to @elastic/[email protected]. | ||
|
||
test('request.abort() works', function (t) { | ||
|