diff --git a/test/integration/utilization/aws-info.tap.js b/test/integration/utilization/aws-info.tap.js deleted file mode 100644 index 838dac8b2f..0000000000 --- a/test/integration/utilization/aws-info.tap.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict' - -const tap = require('tap') - -tap.test('pricing aws info', function (t) { - require('./vendor-info-tests')(t, 'aws') -}) diff --git a/test/integration/utilization/aws-info.test.js b/test/integration/utilization/aws-info.test.js new file mode 100644 index 0000000000..0d96c870ec --- /dev/null +++ b/test/integration/utilization/aws-info.test.js @@ -0,0 +1,13 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' + +const test = require('node:test') +const vendorTests = require('./vendor-info-tests') + +test('pricing aws info', async function (t) { + await vendorTests(t, 'aws') +}) diff --git a/test/integration/utilization/azure-info.tap.js b/test/integration/utilization/azure-info.tap.js deleted file mode 100644 index fd537e8122..0000000000 --- a/test/integration/utilization/azure-info.tap.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict' - -const tap = require('tap') - -tap.test('pricing azure info', function (t) { - require('./vendor-info-tests')(t, 'azure') -}) diff --git a/test/integration/utilization/azure-info.test.js b/test/integration/utilization/azure-info.test.js new file mode 100644 index 0000000000..d6c3546381 --- /dev/null +++ b/test/integration/utilization/azure-info.test.js @@ -0,0 +1,12 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' +const test = require('node:test') +const vendorTests = require('./vendor-info-tests') + +test('pricing azure info', async function (t) { + await vendorTests(t, 'azure') +}) diff --git a/test/integration/utilization/common.js b/test/integration/utilization/common.js new file mode 100644 index 0000000000..266841b8f1 --- /dev/null +++ b/test/integration/utilization/common.js @@ -0,0 +1,55 @@ +/* + * Copyright 2024 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' +const assert = require('node:assert') +const fs = require('fs/promises') +const glob = require('glob') +const JSONbig = require('json-bigint')({ useNativeBigInt: true }) +const path = require('path') + +function checkMetrics(agent, expectedMetrics) { + if (!expectedMetrics) { + assert.equal(agent.metrics._metrics.toJSON().length, 0, 'should not have any metrics') + return + } + + Object.keys(expectedMetrics).forEach(function (expectedMetric) { + const metric = agent.metrics.getOrCreateMetric(expectedMetric) + assert.equal( + metric.callCount, + expectedMetrics[expectedMetric].call_count, + 'should have correct metric call count (' + expectedMetric + ')' + ) + }) +} + +async function getTestCases(vendor) { + const testFile = path.resolve( + __dirname, + '../../lib/cross_agent_tests/utilization_vendor_specific', + vendor + '.json' + ) + const data = await fs.readFile(testFile) + return JSONbig.parse(data) +} + +async function getProcTests(type) { + const testDir = path.resolve(__dirname, '../../lib/cross_agent_tests', type) + return new Promise((resolve, reject) => { + glob(path.join(testDir, '*.txt'), function (err, fileList) { + if (err) { + return reject(err) + } + return resolve(fileList) + }) + }) +} + +module.exports = { + checkMetrics, + getTestCases, + getProcTests +} diff --git a/test/integration/utilization/docker-info.tap.js b/test/integration/utilization/docker-info.test.js similarity index 75% rename from test/integration/utilization/docker-info.tap.js rename to test/integration/utilization/docker-info.test.js index 248ace74d4..164f3ebecb 100644 --- a/test/integration/utilization/docker-info.tap.js +++ b/test/integration/utilization/docker-info.test.js @@ -5,7 +5,8 @@ 'use strict' -const test = require('tap').test +const test = require('node:test') +const assert = require('node:assert') const fs = require('fs/promises') const common = require('../../../lib/utilization/common') const dockerInfo = require('../../../lib/utilization/docker-info') @@ -27,7 +28,7 @@ const tests = [ tests.forEach(({ name, testsDir }) => { test(`pricing docker info ${name}`, async function (t) { const os = require('os') - t.teardown(function () { + t.after(function () { os.platform.restore() }) @@ -36,34 +37,38 @@ tests.forEach(({ name, testsDir }) => { const data = await fs.readFile(`${testsDir}/cases.json`) const cases = JSON.parse(data) - cases.forEach((testCase) => { - const testFile = path.join(testsDir, testCase.filename) - t.test(testCase.filename, makeTest(testCase, testFile, name === 'v2')) + t.beforeEach((ctx) => { + const agent = helper.loadMockedAgent() + sinon.stub(common, 'readProc') + ctx.nr = { agent } + }) + + t.afterEach((ctx) => { + helper.unloadAgent(ctx.nr.agent) + dockerInfo.clearVendorCache() + common.readProc.restore() }) - t.end() + + for (const testCase of cases) { + const testFile = path.join(testsDir, testCase.filename) + await t.test(testCase.filename, makeTest(testCase, testFile, name === 'v2')) + } }) }) function makeTest(testCase, testFile, v2) { return async function (t) { - const agent = helper.loadMockedAgent() - sinon.stub(common, 'readProc') + const { agent } = t.nr const file = await fs.readFile(testFile, { encoding: 'utf8' }) mockProcRead(file, v2) - t.teardown(function () { - helper.unloadAgent(agent) - dockerInfo.clearVendorCache() - common.readProc.restore() - }) - await new Promise((resolve) => { dockerInfo.getVendorInfo(agent, function (err, info) { if (testCase.containerId) { - t.error(err, 'should not have failed') - t.same(info, { id: testCase.containerId }, 'should have expected container id') + assert.ok(!err, 'should not have failed') + assert.deepEqual(info, { id: testCase.containerId }, 'should have expected container id') } else { - t.notOk(info, 'should not have found container id') + assert.ok(!info, 'should not have found container id') } resolve() diff --git a/test/integration/utilization/gcp-info.tap.js b/test/integration/utilization/gcp-info.tap.js deleted file mode 100644 index 88d15714d9..0000000000 --- a/test/integration/utilization/gcp-info.tap.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict' - -const tap = require('tap') - -tap.test('pricing gcp info', function (t) { - require('./vendor-info-tests')(t, 'gcp') -}) diff --git a/test/integration/utilization/gcp-info.test.js b/test/integration/utilization/gcp-info.test.js new file mode 100644 index 0000000000..fe08675706 --- /dev/null +++ b/test/integration/utilization/gcp-info.test.js @@ -0,0 +1,12 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' +const test = require('node:test') +const vendorTests = require('./vendor-info-tests') + +test('pricing gcp info', async function (t) { + await vendorTests(t, 'gcp') +}) diff --git a/test/integration/utilization/pcf-info.tap.js b/test/integration/utilization/pcf-info.tap.js deleted file mode 100644 index 2676a12211..0000000000 --- a/test/integration/utilization/pcf-info.tap.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -'use strict' - -const fs = require('fs') -const helper = require('../../lib/agent_helper') -const path = require('path') -const tap = require('tap') - -tap.test('pricing pcf info', function (t) { - const testFile = path.resolve( - __dirname, - '../../lib/cross_agent_tests/utilization_vendor_specific', - 'pcf.json' - ) - const getInfo = require('../../../lib/utilization/pcf-info') - - fs.readFile(testFile, function (err, data) { - if (err) { - throw err - } - const cases = JSON.parse(data) - - t.autoend() - t.ok(cases.length > 0, 'should have tests to run') - - for (let i = 0; i < cases.length; ++i) { - t.test(cases[i].testname, makeTest(cases[i], getInfo)) - } - }) -}) - -function makeTest(testCase, getInfo) { - return function (t) { - const agent = helper.loadMockedAgent() - t.teardown(function () { - helper.unloadAgent(agent) - }) - - Object.keys(testCase.env_vars).forEach(function (key) { - const value = testCase.env_vars[key].response - if (value == null) { - delete process.env[key] - } else { - process.env[key] = value - } - }) - - getInfo(agent, function (err, info) { - if (testCase.expected_vendors_hash) { - const expected = testCase.expected_vendors_hash.pcf - t.error(err, 'should not error getting data') - t.same(info, expected, 'should have expected info') - } else { - t.notOk(info, 'should not have received vendor info') - } - - checkMetrics(t, agent, testCase.expected_metrics) - - t.end() - }) - } -} - -function checkMetrics(t, agent, expectedMetrics) { - if (!expectedMetrics) { - t.equal(agent.metrics._metrics.toJSON().length, 0, 'should not have any metrics') - return - } - - Object.keys(expectedMetrics).forEach(function (expectedMetric) { - const metric = agent.metrics.getOrCreateMetric(expectedMetric) - t.equal( - metric.callCount, - expectedMetrics[expectedMetric].call_count, - 'should have correct metric call count (' + expectedMetric + ')' - ) - }) -} diff --git a/test/integration/utilization/pcf-info.test.js b/test/integration/utilization/pcf-info.test.js new file mode 100644 index 0000000000..afae051f90 --- /dev/null +++ b/test/integration/utilization/pcf-info.test.js @@ -0,0 +1,57 @@ +/* + * Copyright 2020 New Relic Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +'use strict' +const helper = require('../../lib/agent_helper') +const test = require('node:test') +const assert = require('node:assert') +const { checkMetrics, getTestCases } = require('./common') + +test('pricing pcf info', async function (t) { + const cases = await getTestCases('pcf') + assert.ok(cases.length > 0, 'should have tests to run') + const getInfo = require('../../../lib/utilization/pcf-info') + + t.beforeEach((ctx) => { + const agent = helper.loadMockedAgent() + ctx.nr = { agent } + }) + + t.afterEach((ctx) => { + helper.unloadAgent(ctx.nr.agent) + }) + + for (const testCase of cases) { + await t.test(testCase.testname, makeTest(testCase, getInfo)) + } +}) + +function makeTest(testCase, getInfo) { + return function (t, end) { + const { agent } = t.nr + Object.keys(testCase.env_vars).forEach(function (key) { + const value = testCase.env_vars[key].response + if (value == null) { + delete process.env[key] + } else { + process.env[key] = value + } + }) + + getInfo(agent, function (err, info) { + if (testCase.expected_vendors_hash) { + const expected = testCase.expected_vendors_hash.pcf + assert.ok(!err, 'should not error getting data') + assert.deepEqual(info, expected, 'should have expected info') + } else { + assert.ok(!info, 'should not have received vendor info') + } + + checkMetrics(agent, testCase.expected_metrics) + + end() + }) + } +} diff --git a/test/integration/utilization/proc_cpuinfo.tap.js b/test/integration/utilization/proc-cpuinfo.test.js similarity index 64% rename from test/integration/utilization/proc_cpuinfo.tap.js rename to test/integration/utilization/proc-cpuinfo.test.js index 5c4fbe8cd7..d877c095ae 100644 --- a/test/integration/utilization/proc_cpuinfo.tap.js +++ b/test/integration/utilization/proc-cpuinfo.test.js @@ -5,31 +5,26 @@ 'use strict' -const test = require('tap').test -const glob = require('glob') +const test = require('node:test') +const { tspl } = require('@matteo.collina/tspl') const fs = require('fs/promises') const parseProcCpuInfo = require('../../../lib/parse-proc-cpuinfo') -const path = require('path') +const { getProcTests } = require('./common') test('pricing proc_cpuinfo', async function (t) { - const testDir = path.resolve(__dirname, '../../lib/cross_agent_tests/proc_cpuinfo') - const data = await new Promise((resolve, reject) => { - glob(path.join(testDir, '*.txt'), function globCallback(err, fileList) { - if (err) { - return reject(err) - } - resolve(fileList) - }) - }) - t.ok(data.length > 0, 'should have tests to run') + const data = await getProcTests('proc_cpuinfo') + const plan = tspl(t, { plan: data.length + 1 }) + + plan.ok(data.length > 0, 'should have tests to run') for (const name of data) { const buffer = await fs.readFile(name) const file = buffer.toString() const expected = parseName(name) const info = parseProcCpuInfo(file) - t.same(info, expected, 'should have expected info for ' + name) + plan.deepEqual(info, expected, 'should have expected info for ' + name) } - t.end() + + await plan.completed function parseName(name) { const pattern = /^((\d+|X)pack_(\d+|X)core_(\d+|X)logical).txt$/ diff --git a/test/integration/utilization/proc_meminfo.tap.js b/test/integration/utilization/proc-meminfo.test.js similarity index 56% rename from test/integration/utilization/proc_meminfo.tap.js rename to test/integration/utilization/proc-meminfo.test.js index 0c53685912..ba6689ad3c 100644 --- a/test/integration/utilization/proc_meminfo.tap.js +++ b/test/integration/utilization/proc-meminfo.test.js @@ -5,32 +5,25 @@ 'use strict' -const test = require('tap').test -const glob = require('glob') +const test = require('node:test') +const { tspl } = require('@matteo.collina/tspl') const fs = require('fs/promises') const parseProcMemInfo = require('../../../lib/parse-proc-meminfo') -const path = require('path') +const { getProcTests } = require('./common') test('pricing proc_meminfo', async function (t) { - const testDir = path.resolve(__dirname, '../../lib/cross_agent_tests/proc_meminfo') - const data = await new Promise((resolve, reject) => { - glob(path.join(testDir, '*.txt'), function (err, fileList) { - if (err) { - return reject(err) - } - return resolve(fileList) - }) - }) - - t.ok(data.length > 0, 'should have tests to run') + const data = await getProcTests('proc_meminfo') + const plan = tspl(t, { plan: data.length + 1 }) + plan.ok(data.length > 0, 'should have tests to run') for (const name of data) { const buffer = await fs.readFile(name) const file = buffer.toString() const expected = parseName(name) const info = parseProcMemInfo(file) - t.same(info, expected, 'should have expected info for ' + name) + plan.deepEqual(info, expected, 'should have expected info for ' + name) } - t.end() + + await plan.completed function parseName(name) { const pattern = /^meminfo_(\d+)MB.txt$/ diff --git a/test/integration/utilization/system-info.tap.js b/test/integration/utilization/system-info.test.js similarity index 79% rename from test/integration/utilization/system-info.tap.js rename to test/integration/utilization/system-info.test.js index ae0b3e8b5d..1b5693d3e6 100644 --- a/test/integration/utilization/system-info.tap.js +++ b/test/integration/utilization/system-info.test.js @@ -6,17 +6,23 @@ 'use strict' const helper = require('../../lib/agent_helper') -const test = require('tap').test +const test = require('node:test') +const assert = require('node:assert') const nock = require('nock') const proxyquire = require('proxyquire') const fetchSystemInfo = require('../../../lib/system-info') -test('pricing system-info aws', function (t) { +test.beforeEach(() => { + nock.disableNetConnect() +}) + +test.afterEach(() => { + nock.enableNetConnect() +}) + +test('pricing system-info aws', function (t, end) { const awsHost = 'http://169.254.169.254' process.env.ECS_CONTAINER_METADATA_URI_V4 = awsHost + '/docker' - t.teardown(() => { - delete process.env.ECS_CONTAINER_METADATA_URI_V4 - }) const awsResponses = { 'dynamic/instance-identity/document': { @@ -43,33 +49,34 @@ test('pricing system-info aws', function (t) { detect_docker: false } }) - t.teardown(function () { + t.after(function () { helper.unloadAgent(agent) + delete process.env.ECS_CONTAINER_METADATA_URI_V4 }) fetchSystemInfo(agent, function fetchSystemInfoCb(err, systemInfo) { - t.same(systemInfo.vendors.aws, { + assert.deepEqual(systemInfo.vendors.aws, { instanceType: 'test.type', instanceId: 'test.id', availabilityZone: 'us-west-2b' }) - t.same(systemInfo.vendors.ecs, { ecsDockerId: 'ecs-container-1' }) + assert.deepEqual(systemInfo.vendors.ecs, { ecsDockerId: 'ecs-container-1' }) // This will throw an error if the sys info isn't being cached properly - t.ok(awsRedirect.isDone(), 'should exhaust nock endpoints') - t.ok(ecsScope.isDone()) + assert.ok(awsRedirect.isDone(), 'should exhaust nock endpoints') + assert.ok(ecsScope.isDone()) fetchSystemInfo(agent, function checkCache(err, cachedInfo) { - t.same(cachedInfo.vendors.aws, { + assert.deepEqual(cachedInfo.vendors.aws, { instanceType: 'test.type', instanceId: 'test.id', availabilityZone: 'us-west-2b' }) - t.end() + end() }) }) }) -test('pricing system-info azure', function (t) { +test('pricing system-info azure', function (t, end) { const azureHost = 'http://169.254.169.254' const azureResponse = { location: 'test.location', @@ -90,12 +97,12 @@ test('pricing system-info azure', function (t) { detect_docker: false } }) - t.teardown(function () { + t.after(function () { helper.unloadAgent(agent) }) fetchSystemInfo(agent, function fetchSystemInfoCb(err, systemInfo) { - t.same(systemInfo.vendors.azure, { + assert.deepEqual(systemInfo.vendors.azure, { location: 'test.location', name: 'test.name', vmId: 'test.vmId', @@ -103,26 +110,20 @@ test('pricing system-info azure', function (t) { }) // This will throw an error if the sys info isn't being cached properly - t.ok(azureRedirect.isDone(), 'should exhaust nock endpoints') + assert.ok(azureRedirect.isDone(), 'should exhaust nock endpoints') fetchSystemInfo(agent, function checkCache(err, cachedInfo) { - t.same(cachedInfo.vendors.azure, { + assert.deepEqual(cachedInfo.vendors.azure, { location: 'test.location', name: 'test.name', vmId: 'test.vmId', vmSize: 'test.vmSize' }) - t.end() + end() }) }) }) -test('pricing system-info gcp', function (t) { - nock.disableNetConnect() - - t.teardown(function () { - nock.enableNetConnect() - }) - +test('pricing system-info gcp', function (t, end) { const gcpRedirect = nock('http://metadata.google.internal', { reqheaders: { 'Metadata-Flavor': 'Google' } }) @@ -144,7 +145,7 @@ test('pricing system-info gcp', function (t) { detect_docker: false } }) - t.teardown(function () { + t.after(function () { helper.unloadAgent(agent) }) @@ -155,18 +156,18 @@ test('pricing system-info gcp', function (t) { name: 'aef-default-20170501t160547-7gh8', zone: 'us-central1-c' } - t.same(systemInfo.vendors.gcp, expectedData) + assert.deepEqual(systemInfo.vendors.gcp, expectedData) // This will throw an error if the sys info isn't being cached properly - t.ok(gcpRedirect.isDone(), 'should exhaust nock endpoints') + assert.ok(gcpRedirect.isDone(), 'should exhaust nock endpoints') fetchSystemInfo(agent, function checkCache(err, cachedInfo) { - t.same(cachedInfo.vendors.gcp, expectedData) - t.end() + assert.deepEqual(cachedInfo.vendors.gcp, expectedData) + end() }) }) }) -test('pricing system-info pcf', function (t) { +test('pricing system-info pcf', function (t, end) { const agent = helper.loadMockedAgent({ utilization: { detect_aws: false, @@ -176,7 +177,7 @@ test('pricing system-info pcf', function (t) { detect_docker: false } }) - t.teardown(function () { + t.after(function () { helper.unloadAgent(agent) }) @@ -190,12 +191,12 @@ test('pricing system-info pcf', function (t) { cf_instance_ip: '10.10.147.130', memory_limit: '1024m' } - t.same(systemInfo.vendors.pcf, expectedData) - t.end() + assert.deepEqual(systemInfo.vendors.pcf, expectedData) + end() }) }) -test('pricing system-info docker', function (t) { +test('pricing system-info docker', function (t, end) { const mockUtilization = proxyquire('../../../lib/utilization', { './docker-info': { getVendorInfo: function (agent, callback) { @@ -217,7 +218,7 @@ test('pricing system-info docker', function (t) { detect_docker: true } }) - t.teardown(function () { + t.after(function () { helper.unloadAgent(agent) }) @@ -225,7 +226,7 @@ test('pricing system-info docker', function (t) { const expectedData = { id: '47cbd16b77c50cbf71401c069cd2189f0e659af17d5a2daca3bddf59d8a870b2' } - t.same(systemInfo.vendors.docker, expectedData) - t.end() + assert.deepEqual(systemInfo.vendors.docker, expectedData) + end() }) }) diff --git a/test/integration/utilization/vendor-info-tests.js b/test/integration/utilization/vendor-info-tests.js index cedde08781..15043617cd 100644 --- a/test/integration/utilization/vendor-info-tests.js +++ b/test/integration/utilization/vendor-info-tests.js @@ -4,42 +4,36 @@ */ 'use strict' - -const path = require('path') const nock = require('nock') -const fs = require('fs') +const assert = require('node:assert') const helper = require('../../lib/agent_helper') +const { checkMetrics, getTestCases } = require('./common') const JSONbig = require('json-bigint')({ useNativeBigInt: true }) -module.exports = function (t, vendor) { - const testFile = path.resolve( - __dirname, - '../../lib/cross_agent_tests/utilization_vendor_specific', - vendor + '.json' - ) - const getInfo = require('../../../lib/utilization/' + vendor + '-info') +module.exports = async function (t, vendor) { + const cases = await getTestCases(vendor) + assert.ok(cases.length > 0, 'should have tests to run') + const getInfo = require(`../../../lib/utilization/${vendor}-info`) - nock.disableNetConnect() - t.teardown(function () { - nock.enableNetConnect() + t.beforeEach((ctx) => { + nock.disableNetConnect() + const agent = helper.loadMockedAgent() + ctx.nr = { agent } }) - fs.readFile(testFile, function (err, data) { - if (!t.error(err, 'should not error loading tests')) { - t.fail('Could not load tests!') - t.end() - return - } - - const cases = JSONbig.parse(data) - - t.autoend() - t.ok(cases.length > 0, 'should have tests to run') + t.afterEach((ctx) => { + helper.unloadAgent(ctx.nr.agent) + getInfo.clearCache() + nock.cleanAll() + }) - for (let i = 0; i < cases.length; ++i) { - t.test(cases[i].testname, makeTest(cases[i], vendor, getInfo)) - } + t.after(function () { + nock.enableNetConnect() }) + + for (const testCase of cases) { + await t.test(testCase.testname, makeTest(testCase, vendor, getInfo)) + } } function makeTest(testCase, vendor, getInfo) { @@ -47,15 +41,8 @@ function makeTest(testCase, vendor, getInfo) { // let's be efficient as possible and assign a lower // timeout to aws tests const timeout = vendor === 'aws' ? 501 : 1001 - let agent = null - return function (t) { - agent = helper.loadMockedAgent() - t.teardown(function () { - helper.unloadAgent(agent) - getInfo.clearCache() - nock.cleanAll() - }) - + return function (t, end) { + const { agent } = t.nr let redirection = null const uris = Object.keys(testCase.uri) @@ -84,41 +71,25 @@ function makeTest(testCase, vendor, getInfo) { getInfo(agent, function (err, info) { if (testCase.expected_vendors_hash) { const expected = testCase.expected_vendors_hash[vendor] - t.error(err, 'should not error getting data') - t.same(info, expected, 'should have expected info') + assert.ok(!err, 'should not error getting data') + assert.deepEqual(info, expected, 'should have expected info') } else { - t.notOk(info, 'should not have received vendor info') + assert.ok(!info, 'should not have received vendor info') } - checkMetrics(t, testCase.expected_metrics) + checkMetrics(agent, testCase.expected_metrics) if (info) { // There are no mocks currently active, but the module should cache the // results. - t.ok(host.isDone(), 'should have no mocked endpoints') + assert.ok(host.isDone(), 'should have no mocked endpoints') getInfo(agent, function getCachedInfo(err, cached) { - t.same(cached, info, 'should have same data cached') - t.end() + assert.deepEqual(cached, info, 'should have same data cached') + end() }) } else { - t.end() + end() } }) } - - function checkMetrics(t, expectedMetrics) { - if (!expectedMetrics) { - t.equal(agent.metrics._metrics.toJSON().length, 0, 'should not have any metrics') - return - } - - Object.keys(expectedMetrics).forEach(function (expectedMetric) { - const metric = agent.metrics.getOrCreateMetric(expectedMetric) - t.equal( - metric.callCount, - expectedMetrics[expectedMetric].call_count, - 'should have correct metric call count (' + expectedMetric + ')' - ) - }) - } }