Skip to content

Commit 94e261b

Browse files
committed
chore: aws-sdk in node18 e2e tests
1 parent 4589d92 commit 94e261b

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

Diff for: package-lock.json

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/tracer/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"devDependencies": {
3434
"@aws-sdk/client-dynamodb": "^3.231.0",
3535
"@types/promise-retry": "^1.1.3",
36+
"aws-sdk": "^2.1276.0",
3637
"axios": "^1.2.1",
3738
"promise-retry": "^2.0.1"
3839
},
@@ -59,4 +60,4 @@
5960
"serverless",
6061
"nodejs"
6162
]
62-
}
63+
}

Diff for: packages/tracer/tests/e2e/allFeatures.manual.test.functionCode.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { Context } from 'aws-lambda';
33
import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb';
44
import axios from 'axios';
55
// eslint-disable-next-line @typescript-eslint/no-var-requires
6-
let AWS = require('aws-sdk');
6+
// let AWS = require('aws-sdk');
7+
import AWS from 'aws-sdk';
8+
import { default as AWS2 } from 'aws-sdk';
79

810
const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandardHandler';
911
const customAnnotationKey = process.env.EXPECTED_CUSTOM_ANNOTATION_KEY ?? 'myAnnotation';
@@ -21,7 +23,7 @@ interface CustomEvent {
2123
}
2224

2325
// Function that refreshes imports to ensure that we are instrumenting only one version of the AWS SDK v2 at a time.
24-
const refreshAWSSDKImport = (): void => {
26+
/* const refreshAWSSDKImport = (): void => {
2527
// Clean up the require cache to ensure we're using a newly imported version of the AWS SDK v2
2628
for (const key in require.cache) {
2729
if (key.indexOf('/aws-sdk/') !== -1) {
@@ -30,7 +32,7 @@ const refreshAWSSDKImport = (): void => {
3032
}
3133
// eslint-disable-next-line @typescript-eslint/no-var-requires
3234
AWS = require('aws-sdk');
33-
};
35+
}; */
3436

3537
const tracer = new Tracer({ serviceName: serviceName });
3638
const dynamoDBv3 = tracer.captureAWSv3Client(new DynamoDBClient({}));
@@ -48,12 +50,12 @@ export const handler = async (event: CustomEvent, _context: Context): Promise<vo
4850
tracer.putMetadata(customMetadataKey, customMetadataValue);
4951

5052
let dynamoDBv2;
51-
refreshAWSSDKImport();
53+
// refreshAWSSDKImport();
5254
if (event.sdkV2 === 'client') {
5355
dynamoDBv2 = tracer.captureAWSClient(new AWS.DynamoDB.DocumentClient());
5456
} else if (event.sdkV2 === 'all') {
55-
AWS = tracer.captureAWS(AWS);
56-
dynamoDBv2 = new AWS.DynamoDB.DocumentClient();
57+
tracer.captureAWS(AWS2);
58+
dynamoDBv2 = new AWS2.DynamoDB.DocumentClient();
5759
}
5860
try {
5961
await dynamoDBv2.put({ TableName: testTableName, Item: { id: `${serviceName}-${event.invocation}-sdkv2` } }).promise();

Diff for: packages/tracer/tests/e2e/allFeatures.manual.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let sortedTraces: ParsedTrace[];
6060
const integTestApp = new App();
6161
let stack: Stack;
6262

63-
describe(`Tracer E2E tests, all features with manual instantiation for runtime: ${runtime}`, () => {
63+
describe(`Tracer E2E tests, all features with manual instantiation for runtime: nodejs18x`, () => {
6464

6565
beforeAll(async () => {
6666

Diff for: packages/tracer/tests/helpers/tracesUtils.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ const createTracerTestFunction = (params: TracerTestFunctionParams): NodejsFunct
252252
EXPECTED_CUSTOM_ERROR_MESSAGE: expectedCustomErrorMessage,
253253
...environmentParams,
254254
},
255-
timeout: Duration.seconds(30), // Default value (3 seconds) will time out
256-
bundling: {
257-
// Exclude aws-sdk and use the default one provided by Lambda
258-
externalModules: ['aws-sdk'],
259-
},
255+
timeout: Duration.seconds(30), // Default value (3 seconds) will time out
260256
runtime: TEST_RUNTIMES[runtime as TestRuntimesKey],
261257
});
262258

0 commit comments

Comments
 (0)