Skip to content

Commit eeab14c

Browse files
authored
test(aws-sdk): stabilize DynamoDB trace assertions (#9675)
## Summary Use the existing 5s LocalStack window for DynamoDB trace assertions. ## Why LocalStack may respond after the mock agent's 1s default expires, which removes the observer before the SDK callback completes.
1 parent b9b4e0b commit eeab14c

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/datadog-plugin-aws-sdk/test/dynamodb.spec.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const agent = require('../../dd-trace/test/plugins/agent')
1212
const DynamoDb = require('../src/services/dynamodb')
1313
const { generatePointerHash } = require('../src/util')
1414
const { setup, withAwsSdkVersions } = require('./spec_helpers')
15+
16+
const LOCALSTACK_TIMEOUT_MS = 5000
17+
1518
/* eslint-disable no-console */
1619
async function resetLocalStackDynamo () {
1720
try {
@@ -168,7 +171,7 @@ describe('Plugin', () => {
168171
'aws.request.body.Item.name': 'redacted',
169172
'aws.request.body.Item.data.S': 'test-data',
170173
},
171-
})
174+
}, { timeoutMs: LOCALSTACK_TIMEOUT_MS })
172175

173176
const operation = () => promisify(dynamo.putItem)({
174177
TableName: oneKeyTableName,
@@ -193,7 +196,7 @@ describe('Plugin', () => {
193196
'aws.request.body.Key.name.S': 'test-name',
194197
'aws.request.body.AttributeUpdates.data.Value.S': 'updated-data',
195198
},
196-
})
199+
}, { timeoutMs: LOCALSTACK_TIMEOUT_MS })
197200

198201
const operation = () => promisify(dynamo.updateItem)({
199202
TableName: oneKeyTableName,
@@ -222,7 +225,7 @@ describe('Plugin', () => {
222225
'aws.request.body.TableName': oneKeyTableName,
223226
'aws.request.body.Key.name.S': 'test-name',
224227
},
225-
})
228+
}, { timeoutMs: LOCALSTACK_TIMEOUT_MS })
226229

227230
const operation = () => promisify(dynamo.deleteItem)({
228231
TableName: oneKeyTableName,
@@ -259,7 +262,7 @@ describe('Plugin', () => {
259262
'aws.response.body.Item.name.S': 'test-get-name',
260263
'aws.response.body.Item.data': 'redacted',
261264
},
262-
})
265+
}, { timeoutMs: LOCALSTACK_TIMEOUT_MS })
263266

264267
const operation = () => promisify(dynamo.getItem)({
265268
TableName: oneKeyTableName,
@@ -312,7 +315,7 @@ describe('Plugin', () => {
312315
})
313316
}
314317
}
315-
})
318+
}, { timeoutMs: LOCALSTACK_TIMEOUT_MS })
316319

317320
DynamoDb.dynamoPrimaryKeyConfig = null
318321

0 commit comments

Comments
 (0)