|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const { |
| 4 | + FakeAgent, |
| 5 | + sandboxCwd, |
| 6 | + useSandbox, |
| 7 | + checkSpansForServiceName, |
| 8 | + spawnPluginIntegrationTestProc |
| 9 | +} = require('../../../../integration-tests/helpers') |
| 10 | +const { withVersions } = require('../../../dd-trace/test/setup/mocha') |
| 11 | + |
| 12 | +const assert = require('node:assert') |
| 13 | + |
| 14 | +describe('recursion regression test', () => { |
| 15 | + let agent |
| 16 | + let proc |
| 17 | + |
| 18 | + withVersions('aws-sdk', ['@aws-sdk/smithy-client'], version => { |
| 19 | + useSandbox([`'@aws-sdk/client-sqs'@${version}'`], false, [ |
| 20 | + './packages/datadog-plugin-aws-sdk/test/integration-test/*']) |
| 21 | + |
| 22 | + beforeEach(async () => { |
| 23 | + agent = await new FakeAgent().start() |
| 24 | + }) |
| 25 | + |
| 26 | + afterEach(async () => { |
| 27 | + proc && proc.kill() |
| 28 | + await agent.stop() |
| 29 | + }) |
| 30 | + |
| 31 | + it('does not cause a recursion error when many commands are sent', async () => { |
| 32 | + const res = agent.assertMessageReceived(({ headers, payload }) => { |
| 33 | + assert.equal(headers.host, `127.0.0.1:${agent.port}`) |
| 34 | + assert.ok(Array.isArray(payload)) |
| 35 | + assert.strictEqual(checkSpansForServiceName(payload, 'aws.request'), true) |
| 36 | + }) |
| 37 | + |
| 38 | + proc = await spawnPluginIntegrationTestProc(sandboxCwd(), 'recursion.mjs', agent.port, undefined, |
| 39 | + { |
| 40 | + AWS_SECRET_ACCESS_KEY: '0000000000/00000000000000000000000000000', |
| 41 | + AWS_ACCESS_KEY_ID: '00000000000000000000', |
| 42 | + execArgv: ['--stack-size=128'] |
| 43 | + } |
| 44 | + ) |
| 45 | + |
| 46 | + await res |
| 47 | + }).timeout(20000) |
| 48 | + }) |
| 49 | +}) |
0 commit comments