newrelic 7.0.2 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,8 @@ const RemoteMethod = require('./remote-method')
12
12
 
13
13
  const NAMES = require('../metrics/names')
14
14
 
15
+ const DEFAULT_PORT = 443
16
+
15
17
  // just to make clear what's going on
16
18
  const TO_MILLIS = 1e3
17
19
 
@@ -54,22 +56,41 @@ function CollectorAPI(agent) {
54
56
  this._agent = agent
55
57
  this._reqHeadersMap = null
56
58
 
59
+ const initialEndpoint = {
60
+ host: agent.config.host,
61
+ port: agent.config.port
62
+ }
63
+
57
64
  /* RemoteMethods can be reused and have little per-object state, so why not
58
65
  * save some GC time?
59
66
  */
60
67
  this._methods = {
61
- redirect: new RemoteMethod('preconnect', agent.config),
62
- handshake: new RemoteMethod('connect', agent.config),
63
- settings: new RemoteMethod('agent_settings', agent.config),
64
- errors: new RemoteMethod('error_data', agent.config),
65
- metrics: new RemoteMethod('metric_data', agent.config),
66
- traces: new RemoteMethod('transaction_sample_data', agent.config),
67
- shutdown: new RemoteMethod('shutdown', agent.config),
68
- events: new RemoteMethod('analytic_event_data', agent.config),
69
- customEvents: new RemoteMethod('custom_event_data', agent.config),
70
- queryData: new RemoteMethod('sql_trace_data', agent.config),
71
- errorEvents: new RemoteMethod('error_event_data', agent.config),
72
- spanEvents: new RemoteMethod('span_event_data', agent.config)
68
+ preconnect: new RemoteMethod('preconnect', agent.config, initialEndpoint),
69
+ connect: new RemoteMethod('connect', agent.config, initialEndpoint),
70
+ settings: new RemoteMethod('agent_settings', agent.config, initialEndpoint),
71
+ errors: new RemoteMethod('error_data', agent.config, initialEndpoint),
72
+ metrics: new RemoteMethod('metric_data', agent.config, initialEndpoint),
73
+ traces: new RemoteMethod('transaction_sample_data', agent.config, initialEndpoint),
74
+ shutdown: new RemoteMethod('shutdown', agent.config, initialEndpoint),
75
+ events: new RemoteMethod('analytic_event_data', agent.config, initialEndpoint),
76
+ customEvents: new RemoteMethod('custom_event_data', agent.config, initialEndpoint),
77
+ queryData: new RemoteMethod('sql_trace_data', agent.config, initialEndpoint),
78
+ errorEvents: new RemoteMethod('error_event_data', agent.config, initialEndpoint),
79
+ spanEvents: new RemoteMethod('span_event_data', agent.config, initialEndpoint)
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Updates all methods except preconnect w/ new host/port pairs sent down from server
85
+ * during preconnect (via redirect_host). Preconnect does not update.
86
+ */
87
+ CollectorAPI.prototype._updateEndpoints = function _updateEndpoints(endpoint) {
88
+ logger.trace('Updating endpoints to: ', endpoint)
89
+ for (const [key, remoteMethod] of Object.entries(this._methods)) {
90
+ // Preconnect should always use configured options, not updates from server.
91
+ if (key !== 'preconnect') {
92
+ remoteMethod.updateEndpoint(endpoint)
93
+ }
73
94
  }
74
95
  }
75
96
 
@@ -160,7 +181,7 @@ CollectorAPI.prototype._login = function _login(callback) {
160
181
 
161
182
  const payload = [preconnectData]
162
183
 
163
- methods.redirect.invoke(payload, onPreConnect)
184
+ methods.preconnect.invoke(payload, onPreConnect)
164
185
 
165
186
  function onPreConnect(error, response) {
166
187
  if (error || !SUCCESS.has(response.status)) {
@@ -188,8 +209,13 @@ CollectorAPI.prototype._login = function _login(callback) {
188
209
  res.redirect_host
189
210
  )
190
211
 
191
- agent.config.host = parts[0]
192
- agent.config.port = parts[1] || 443
212
+ const [host, port] = parts
213
+ const newEndpoint = {
214
+ host: host,
215
+ port: port || DEFAULT_PORT
216
+ }
217
+
218
+ self._updateEndpoints(newEndpoint)
193
219
  }
194
220
  }
195
221
 
@@ -226,7 +252,7 @@ CollectorAPI.prototype._connect = function _connect(env, callback) {
226
252
  const methods = this._methods
227
253
  const agent = this._agent
228
254
 
229
- methods.handshake.invoke(env, onConnect)
255
+ methods.connect.invoke(env, onConnect)
230
256
 
231
257
  function onConnect(error, res) {
232
258
  if (error || !SUCCESS.has(res.status)) {
@@ -239,10 +265,11 @@ CollectorAPI.prototype._connect = function _connect(env, callback) {
239
265
  }
240
266
 
241
267
  agent.setState('connected')
268
+
242
269
  logger.info(
243
270
  'Connected to %s:%d with agent run ID %s.',
244
- agent.config.host,
245
- agent.config.port,
271
+ methods.connect.endpoint.host,
272
+ methods.connect.endpoint.port,
246
273
  config.agent_run_id
247
274
  )
248
275
 
@@ -29,15 +29,24 @@ const USER_AGENT_FORMAT = 'NewRelic-NodeAgent/%s (nodejs %s %s-%s)'
29
29
  const ENCODING_HEADER = 'CONTENT-ENCODING'
30
30
  const DEFAULT_ENCODING = 'identity'
31
31
 
32
- function RemoteMethod(name, config) {
32
+ function RemoteMethod(name, config, endpoint) {
33
33
  if (!name) {
34
34
  throw new TypeError('Must include name of method to invoke on collector.')
35
35
  }
36
36
 
37
37
  this.name = name
38
38
  this._config = config
39
-
40
39
  this._protocolVersion = 17
40
+
41
+ this.endpoint = endpoint
42
+ }
43
+
44
+ RemoteMethod.prototype.updateEndpoint = function updateEndpoint(endpoint) {
45
+ if (!endpoint) {
46
+ return
47
+ }
48
+
49
+ this.endpoint = endpoint
41
50
  }
42
51
 
43
52
  RemoteMethod.prototype.serialize = function serialize(payload, callback) {
@@ -88,8 +97,8 @@ RemoteMethod.prototype.invoke = function invoke(payload, nrHeaders, callback) {
88
97
  RemoteMethod.prototype._post = function _post(data, nrHeaders, callback) {
89
98
  var method = this
90
99
  var options = {
91
- port: this._config.port,
92
- host: this._config.host,
100
+ port: this.endpoint.port,
101
+ host: this.endpoint.host,
93
102
  compressed: this._shouldCompress(data),
94
103
  path: this._path(),
95
104
  onError: callback,
@@ -317,7 +326,7 @@ RemoteMethod.prototype._headers = function _headers(options) {
317
326
 
318
327
  var headers = {
319
328
  // select the virtual host on the server end
320
- 'Host': this._config.host,
329
+ 'Host': this.endpoint.host,
321
330
  'User-Agent': agent,
322
331
  'Connection': 'Keep-Alive',
323
332
  'Content-Length': byteLength(options.body),
package/lib/config/env.js CHANGED
@@ -157,7 +157,9 @@ const ENV_MAPPING = {
157
157
  host: 'NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST',
158
158
  port: 'NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_PORT'
159
159
  },
160
- queue_size: 'NEW_RELIC_INFINITE_TRACING_QUEUE_SIZE'
160
+ span_events: {
161
+ queue_size: 'NEW_RELIC_INFINITE_TRACING_SPAN_EVENTS_QUEUE_SIZE'
162
+ }
161
163
  }
162
164
  }
163
165
 
@@ -1188,6 +1188,20 @@ Config.prototype._DTManuallySet = function _DTManuallySet(inputConfig) {
1188
1188
  */
1189
1189
  Config.prototype._enforceServerless = function _enforceServerless(inputConfig) {
1190
1190
  if (this.serverless_mode.enabled) {
1191
+ // Application name is not currently leveraged by our Lambda product (March 2021).
1192
+ // Defaulting the name removes burden on customers to set while avoiding
1193
+ // breaking should it be used in the future.
1194
+ if (!this.app_name || this.app_name.length === 0) {
1195
+ const namingSource = process.env.AWS_LAMBDA_FUNCTION_NAME
1196
+ ? 'process.env.AWS_LAMBDA_FUNCTION_NAME'
1197
+ : 'DEFAULT'
1198
+
1199
+ const name = process.env.AWS_LAMBDA_FUNCTION_NAME || 'Serverless Application'
1200
+ this.app_name = [name]
1201
+
1202
+ logger.info('Auto-naming serverless application to [\'%s\'] from: %s', name, namingSource)
1203
+ }
1204
+
1191
1205
  // Explicitly disable old CAT in serverless_mode
1192
1206
  if (this.cross_application_tracer.enabled) {
1193
1207
  this.cross_application_tracer.enabled = false
@@ -1667,17 +1681,20 @@ function _noConfigFile() {
1667
1681
 
1668
1682
  let locations = mainpath
1669
1683
  if (mainpath !== altpath) {
1670
- locations += ' or\n' + altpath
1684
+ locations += ' or ' + altpath
1671
1685
  }
1672
1686
 
1673
- /* eslint-disable no-console */
1674
- console.error([
1687
+ const errorMessage = [
1675
1688
  'Unable to find New Relic module configuration. A base configuration file',
1676
1689
  `can be copied from ${BASE_CONFIG_PATH}`,
1677
1690
  `and put at ${locations}.`,
1678
1691
  'If you are not using file-based configuration, please set the environment',
1679
1692
  'variable `NEW_RELIC_NO_CONFIG_FILE=true`.'
1680
- ].join('\n'))
1693
+ ].join(' ')
1694
+
1695
+ logger.error(errorMessage)
1696
+ /* eslint-disable no-console */
1697
+ console.error(errorMessage)
1681
1698
  /* eslint-enable no-console */
1682
1699
  }
1683
1700
 
@@ -22,9 +22,8 @@ function SlowQuery(segment, type, query, trace) {
22
22
  }
23
23
 
24
24
  function normalizedHash(value) {
25
- // We leverage the last 16 hex digits of which would mostly fit in a long and
26
- // rely on parseInt to drop bits that do not fit in a JS number
27
- return parseInt(crypto.createHash('sha1').update(value).digest('hex').slice(-16), 16)
25
+ // We leverage the last 15 hex digits which will fit in a signed long
26
+ return parseInt(crypto.createHash('sha1').update(value).digest('hex').slice(-15), 16)
28
27
  }
29
28
 
30
29
  function formatTrace(trace) {
@@ -233,12 +233,14 @@ class GrpcConnection extends EventEmitter {
233
233
  * @param {ClientDuplexStreamImpl} stream
234
234
  */
235
235
  _setupSpanStreamObservers(stream) {
236
- // listen for responses from server and log
237
- if (logger.traceEnabled()) {
238
- stream.on('data', function data(response) {
236
+ // Node streams require all data sent by the server to be read before the end
237
+ // (or status in this case) event gets fired. As such, we have to subscribe even
238
+ // if we are not going to use the data.
239
+ stream.on('data', function data(response) {
240
+ if (logger.traceEnabled()) {
239
241
  logger.trace("gRPC span response stream: %s", JSON.stringify(response))
240
- })
241
- }
242
+ }
243
+ })
242
244
 
243
245
  // listen for status that indicate stream has ended,
244
246
  // and we need to disconnect
@@ -61,7 +61,12 @@ function initialize(agent, timers, moduleName, shim) {
61
61
 
62
62
  function wrapSetImmediate(shim, fn) {
63
63
  return function wrappedSetImmediate() {
64
- const args = shim.argsToArray.apply(shim, arguments)
64
+ const segment = shim.getActiveSegment()
65
+ if (!segment) {
66
+ return fn.apply(this, arguments)
67
+ }
68
+
69
+ const args = shim.argsToArray.apply(shim, arguments, segment)
65
70
  shim.bindSegment(args, shim.FIRST)
66
71
 
67
72
  return fn.apply(this, args)
@@ -1,4 +1,5 @@
1
1
  'use strict'
2
+ const semver = require('semver')
2
3
  const {
3
4
  buildMiddlewareSpecForRouteHandler,
4
5
  buildMiddlewareSpecForMiddlewareFunction
@@ -37,6 +38,12 @@ const setupRouteHandler = (shim, fastify) => {
37
38
  }
38
39
 
39
40
  const setupMiddlewareHandlers = (shim, fastify) => {
41
+ // Don't wrap use() in fastify v3+
42
+ const fastifyVersion = shim.require('./package.json').version
43
+ if (semver.satisfies(fastifyVersion, '>=3.0.0')) {
44
+ return
45
+ }
46
+
40
47
  shim.wrap(fastify, 'use', function wrapFastifyUse(shim, fn) {
41
48
  return function wrappedFastifyUser() {
42
49
  const args = shim.argsToArray.apply(shim, arguments)
@@ -22,7 +22,8 @@ const SUPPORTABILITY = {
22
22
  NODEJS: 'Supportability/Nodejs',
23
23
  REGISTRATION: 'Supportability/Registration',
24
24
  EVENT_HARVEST: 'Supportability/EventHarvest',
25
- INFINITE_TRACING: 'Supportability/InfiniteTracing'
25
+ INFINITE_TRACING: 'Supportability/InfiniteTracing',
26
+ FEATURES: 'Supportability/Features'
26
27
  }
27
28
 
28
29
  const ERRORS = {
@@ -249,6 +250,10 @@ const INFINITE_TRACING = {
249
250
  DRAIN_DURATION: SUPPORTABILITY.INFINITE_TRACING + '/Drain/Duration',
250
251
  }
251
252
 
253
+ const FEATURES = {
254
+ CERTIFICATES: SUPPORTABILITY.FEATURES + '/Certificates'
255
+ }
256
+
252
257
  module.exports = {
253
258
  ACTION_DELIMITER: '/',
254
259
  ALL: ALL,
@@ -266,6 +271,7 @@ module.exports = {
266
271
  EVENT_HARVEST: EVENT_HARVEST,
267
272
  EXPRESS: EXPRESS,
268
273
  EXTERNAL: EXTERNAL,
274
+ FEATURES,
269
275
  FS: FS,
270
276
  FUNCTION: FUNCTION,
271
277
  GC: GC,
@@ -55,10 +55,8 @@ class StreamingSpanEventAggregator extends Aggregator {
55
55
  }
56
56
 
57
57
  send() {
58
- // Only log once started. This will get invoked on initial harvest
59
- // prior to start which we'll just ignore.
60
58
  if (this.started) {
61
- logger.warnOnce(SEND_WARNING)
59
+ logger.warnOnce('SEND_WARNING', SEND_WARNING)
62
60
  }
63
61
 
64
62
  this.emit(`finished ${this.method} data send.`)
@@ -879,6 +879,13 @@ Transaction.prototype.getIntrinsicAttributes = function getIntrinsicAttributes()
879
879
  */
880
880
  Transaction.prototype.acceptDistributedTraceHeaders = acceptDistributedTraceHeaders
881
881
  function acceptDistributedTraceHeaders(transportType, headers) {
882
+ if (headers == null || typeof headers !== 'object') {
883
+ logger.trace(
884
+ 'Ignoring distributed trace headers for transaction %s. Headers not passed in as object.',
885
+ this.id)
886
+ return
887
+ }
888
+
882
889
  const transport = TRANSPORT_TYPES_SET[transportType] ? transportType : TRANSPORT_TYPES.UNKNOWN
883
890
 
884
891
  // assumes header keys already lowercase
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "7.0.2",
3
+ "version": "7.1.3",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -136,15 +136,16 @@
136
136
  "unit": "rm -f newrelic_agent.log && time tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.js)$' --timeout=180 --no-coverage",
137
137
  "update-cross-agent-tests": "./bin/update-cats.sh",
138
138
  "versioned-tests": "./bin/run-versioned-tests.sh",
139
+ "update-changelog-version": "node ./bin/update-changelog-version",
139
140
  "versioned": "npm run prepare-test && time ./bin/run-versioned-tests.sh"
140
141
  },
141
142
  "bin": {
142
143
  "newrelic-naming-rules": "./bin/test-naming-rules.js"
143
144
  },
144
145
  "dependencies": {
145
- "@grpc/grpc-js": "1.2.0",
146
+ "@grpc/grpc-js": "^1.2.7",
146
147
  "@grpc/proto-loader": "^0.5.5",
147
- "@newrelic/aws-sdk": "^3.0.0",
148
+ "@newrelic/aws-sdk": "^3.1.0",
148
149
  "@newrelic/koa": "^5.0.0",
149
150
  "@newrelic/superagent": "^4.0.0",
150
151
  "@tyriar/fibonacci-heap": "^2.0.7",
@@ -161,10 +162,13 @@
161
162
  "devDependencies": {
162
163
  "@newrelic/proxy": "^2.0.0",
163
164
  "@newrelic/test-utilities": "^5.0.0",
165
+ "@octokit/rest": "^18.0.15",
166
+ "JSV": "~4.0.2",
164
167
  "architect": "*",
165
168
  "benchmark": "^2.1.4",
166
169
  "bluebird": "^3.4.7",
167
170
  "chai": "^4.1.2",
171
+ "commander": "^7.0.0",
168
172
  "eslint": "^6.8.0",
169
173
  "express": "*",
170
174
  "fastify": "^2.14.1",
@@ -173,7 +177,6 @@
173
177
  "got": "^8.0.1",
174
178
  "http-errors": "^1.7.3",
175
179
  "jsdoc": "^3.6.3",
176
- "JSV": "~4.0.2",
177
180
  "memcached": ">=0.2.8",
178
181
  "minami": "^1.1.1",
179
182
  "mongodb": "^3.3.3",
@@ -1,18 +1,18 @@
1
1
  {
2
- "lastUpdated": "Tue Nov 17 2020 14:58:13 GMT-0800 (Pacific Standard Time)",
2
+ "lastUpdated": "Tue Feb 23 2021 13:40:18 GMT-0800 (Pacific Standard Time)",
3
3
  "projectName": "New Relic Node Agent",
4
4
  "projectUrl": "https://github.com/newrelic/node-newrelic",
5
5
  "includeDev": true,
6
6
  "dependencies": {
7
- "@grpc/grpc-js@1.2.0": {
7
+ "@grpc/grpc-js@1.2.5": {
8
8
  "name": "@grpc/grpc-js",
9
- "version": "1.2.0",
10
- "range": "1.2.0",
9
+ "version": "1.2.5",
10
+ "range": "^1.2.5",
11
11
  "licenses": "Apache-2.0",
12
12
  "repoUrl": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
13
- "versionedRepoUrl": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.2.0",
13
+ "versionedRepoUrl": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.2.5",
14
14
  "licenseFile": "node_modules/@grpc/grpc-js/LICENSE",
15
- "licenseUrl": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.2.0/LICENSE",
15
+ "licenseUrl": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.2.5/LICENSE",
16
16
  "licenseTextSource": "file",
17
17
  "publisher": "Google Inc."
18
18
  },
@@ -28,15 +28,15 @@
28
28
  "licenseTextSource": "file",
29
29
  "publisher": "Google Inc."
30
30
  },
31
- "@newrelic/aws-sdk@3.0.0": {
31
+ "@newrelic/aws-sdk@3.1.0": {
32
32
  "name": "@newrelic/aws-sdk",
33
- "version": "3.0.0",
34
- "range": "^3.0.0",
33
+ "version": "3.1.0",
34
+ "range": "^3.1.0",
35
35
  "licenses": "Apache-2.0",
36
36
  "repoUrl": "https://github.com/newrelic/node-newrelic-aws-sdk",
37
- "versionedRepoUrl": "https://github.com/newrelic/node-newrelic-aws-sdk/tree/v3.0.0",
37
+ "versionedRepoUrl": "https://github.com/newrelic/node-newrelic-aws-sdk/tree/v3.1.0",
38
38
  "licenseFile": "node_modules/@newrelic/aws-sdk/LICENSE",
39
- "licenseUrl": "https://github.com/newrelic/node-newrelic-aws-sdk/blob/v3.0.0/LICENSE",
39
+ "licenseUrl": "https://github.com/newrelic/node-newrelic-aws-sdk/blob/v3.1.0/LICENSE",
40
40
  "licenseTextSource": "file",
41
41
  "publisher": "New Relic Node.js agent team",
42
42
  "email": "nodejs@newrelic.com"
@@ -184,6 +184,17 @@
184
184
  "publisher": "New Relic Node.js agent team",
185
185
  "email": "nodejs@newrelic.com"
186
186
  },
187
+ "@octokit/rest@18.0.15": {
188
+ "name": "@octokit/rest",
189
+ "version": "18.0.15",
190
+ "range": "^18.0.15",
191
+ "licenses": "MIT",
192
+ "repoUrl": "https://github.com/octokit/rest.js",
193
+ "versionedRepoUrl": "https://github.com/octokit/rest.js/tree/v18.0.15",
194
+ "licenseFile": "node_modules/@octokit/rest/LICENSE",
195
+ "licenseUrl": "https://github.com/octokit/rest.js/blob/v18.0.15/LICENSE",
196
+ "licenseTextSource": "file"
197
+ },
187
198
  "JSV@4.0.2": {
188
199
  "name": "JSV",
189
200
  "version": "4.0.2",
@@ -1,13 +0,0 @@
1
- #! /bin/bash
2
-
3
- # Copyright 2020 New Relic Corporation. All rights reserved.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- set -x # echo commands as executed
7
-
8
- sudo apt-get install -qq gcc-5 g++-5
9
- sudo update-alternatives \
10
- --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 \
11
- --slave /usr/bin/g++ g++ /usr/bin/g++-5
12
- sudo update-alternatives --auto gcc
13
- export CXX="g++-5" CC="gcc-5"
@@ -1,16 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Copyright 2020 New Relic Corporation. All rights reserved.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- set -xev # -x echo commands as executed
7
- # -e exit as soon as something goes wrong
8
- # -v when considering whether to say something or not say something
9
- # take the appraoch that provide as much information as possible
10
- # which human beings something describe as being verbose
11
-
12
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz
13
- mkdir -p /tmp/mongodb/data
14
- tar -xf /tmp/mongodb.tgz -C /tmp/mongodb
15
- /tmp/mongodb/mongodb-linux-x86_64-${MONGODB}/bin/mongod --version
16
- /tmp/mongodb/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath /tmp/mongodb/data --bind_ip 127.0.0.1 --noauth &> /dev/null &
@@ -1,57 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Copyright 2020 New Relic Corporation. All rights reserved.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- # https://stackoverflow.com/questions/16989598/bash-comparing-version-numbers/24067243
7
- # tests version strings using `sort`'s -V option
8
- function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
9
-
10
- sudo apt-get update
11
-
12
- # so dumb that we need python-software-properties
13
- # to get add-apt-repository
14
- sudo apt-get -y install build-essential libssl-dev curl python-software-properties time sudo
15
-
16
- # update gcc to something that will install pg-native module
17
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
18
- sudo apt-get -y update
19
- sudo apt-get -y install gcc-4.9 g++-4.9
20
- sudo rm /usr/bin/g++
21
- sudo rm /usr/bin/gcc
22
- sudo ln -s /usr/bin/g++-4.9 /usr/bin/g++
23
- sudo ln -s /usr/bin/gcc-4.9 /usr/bin/gcc
24
-
25
- # Where is ppa:ubuntu-toolchain-r/test?
26
- # sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
27
- # sudo apt-get -y update
28
- # sudo apt-get -y install libstdc++6-4.7-dev
29
-
30
- # only do for NODE 12 AND for old glibc
31
-
32
- GLIBC_VERSION_CHECK=`ldd --version | head -n 1 | awk '{print $NF}'`
33
-
34
- if [ -z $NR_NODE_VERSION ]; then
35
- echo "please define NR_NODE_VERSION in local env"
36
- exit 1
37
- fi
38
-
39
- version=$NR_NODE_VERSION
40
- major=${version/.*}
41
- echo $major
42
- if [ $major -gt 11 ] && version_gt 2.17 $GLIBC_VERSION_CHECK;then
43
- echo "Installing updated glibc\n"
44
- # can we get this from an actual repository?
45
- curl -LO 'http://launchpadlibrarian.net/130794928/libc6_2.17-0ubuntu4_amd64.deb'
46
- sudo dpkg -i libc6_2.17-0ubuntu4_amd64.deb
47
- else
48
- echo "Skipping glibc update\n"
49
- fi
50
-
51
- # install nvm
52
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
53
- export NVM_DIR="$HOME/.nvm"
54
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
55
- [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
56
-
57
- nvm install $NR_NODE_VERSION
@@ -1,52 +0,0 @@
1
- #! /bin/bash
2
-
3
- # Copyright 2020 New Relic Corporation. All rights reserved.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- function get_version {
7
- local num='[[:digit:]][[:digit:]]*' # Grep doesn't have `+` operator.
8
- local version=`$1 --version 2>/dev/null | grep -o "$num\.$num\.$num" | head -1`
9
- echo $version | grep -o "$num" | head -1
10
- }
11
-
12
- TOOLCHAIN_ADDED="false"
13
- function add_toolchain {
14
- if [ "$TOOLCHAIN_ADDED" == "false" ]; then
15
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
16
- sudo apt-get update -qq
17
- fi
18
- TOOLCHAIN_ADDED="true"
19
- }
20
-
21
- # npm 5 introduced 'ci' and 6 introduce 'audit', so just default to latest
22
- if (("$(get_version npm)" < "6" )); then
23
- echo " --- upgrading npm to 6 --- "
24
- npm install -g npm@6
25
- else
26
- echo " --- not upgrading npm ($(npm --version)) --- "
27
- fi
28
-
29
- if [ "$SUITE" = "versioned" ]; then
30
- echo " --- installing cassandra --- "
31
- ./bin/cassandra-setup.sh
32
-
33
- # GCC 5 is the lowest version of GCC we can use.
34
- if [ "$(get_version gcc)" == "4" ]; then
35
- echo " --- upgrading GCC --- "
36
- add_toolchain
37
- ./bin/travis-install-gcc5.sh > /dev/null
38
- else
39
- echo " --- not upgrading GCC ($(gcc --version)) --- "
40
- fi
41
-
42
- echo " --- installing $SUITE requirements --- "
43
-
44
- # MongoDB is always installed in integrations and versioned.
45
- echo " --- installing mongodb --- "
46
- add_toolchain
47
- ./bin/travis-install-mongo.sh
48
-
49
- echo " --- done installing $SUITE requirements --- "
50
- else
51
- echo " --- no $SUITE installation requirements --- "
52
- fi