-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE-2146 - add tap test for agent restarts
- Loading branch information
Carlo Pearson
committed
Oct 9, 2019
1 parent
55fd06a
commit 5c8560d
Showing
1 changed file
with
51 additions
and
0 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
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() | ||
}) | ||
}) | ||
}) | ||
}) |