Skip to content

Commit

Permalink
NODE-2146 - add tap test for agent restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Pearson committed Oct 9, 2019
1 parent 55fd06a commit 5c8560d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/integration/agent/agent-restart-listener.tap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict'

const tap = require('tap')
const configurator = require('../../../lib/config')
const Agent = require('../../../lib/agent')


tap.test('Collector API should connect to staging-collector.newrelic.com', (t) => {
const config = configurator.initialize({
app_name: 'node.js Tests',
license_key: 'd67afc830dab717fd163bfcb0b8b88423e9a1a3b',
host: 'staging-collector.newrelic.com',
port: 443,
ssl: true,
utilization: {
detect_aws: true,
detect_pcf: true,
detect_gcp: true,
detect_docker: true
},
logging: {
level: 'trace'
}
})
const agent = new Agent(config)

agent.start((error, returned) => {
console.log('Listeners:')
console.log('started: ', agent.listenerCount('started'))
console.log('stopped: ', agent.listenerCount('stopped'))
console.log('disconnected: ', agent.listenerCount('disconnected'))
t.notOk(error, 'connected without error')
t.ok(returned, 'got boot configuration')
t.ok(returned.agent_run_id, 'got run ID')

const initialStoppedListeners = agent.listenerCount('stopped')

agent.collector.restart(() => {
const currentStoppedListeners = agent.listenerCount('stopped')
t.equal(
currentStoppedListeners,
initialStoppedListeners,
'should not have extra listeners'
)

agent.stop(() => {
t.end()
})
})
})
})

0 comments on commit 5c8560d

Please sign in to comment.