Skip to content

Commit 7794f36

Browse files
committed
make unit tests run faster
1 parent ce592e5 commit 7794f36

File tree

4 files changed

+176
-10
lines changed

4 files changed

+176
-10
lines changed

package-lock.json

Lines changed: 150 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/node/opentelemetry-instrumentation-aws-sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@aws-sdk/client-sns": "3.85.0",
5959
"@aws-sdk/client-sqs": "3.85.0",
6060
"@aws-sdk/types": "3.78.0",
61+
"@smithy/node-http-handler": "3.1.4",
6162
"@opentelemetry/api": "^1.3.0",
6263
"@opentelemetry/contrib-test-utils": "^0.40.0",
6364
"@opentelemetry/sdk-trace-base": "^1.8.0",

plugins/node/opentelemetry-instrumentation-aws-sdk/test/kinesis.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { AttributeNames } from '../src/enums';
2323
registerInstrumentationTesting(new AwsInstrumentation());
2424

2525
import { Kinesis } from '@aws-sdk/client-kinesis';
26+
import { NodeHttpHandler } from '@smithy/node-http-handler';
2627
import * as AWS from 'aws-sdk';
2728
import { AWSError } from 'aws-sdk';
2829
import * as nock from 'nock';
@@ -88,6 +89,11 @@ describe('Kinesis - v3', () => {
8889
accessKeyId: 'abcde',
8990
secretAccessKey: 'abcde',
9091
},
92+
requestHandler: new NodeHttpHandler({
93+
connectionTimeout: 10,
94+
requestTimeout: 10,
95+
socketTimeout: 10,
96+
}),
9197
});
9298
});
9399

plugins/node/opentelemetry-instrumentation-aws-sdk/test/s3.test.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { AttributeNames } from '../src/enums';
2323
registerInstrumentationTesting(new AwsInstrumentation());
2424

2525
import { S3 } from '@aws-sdk/client-s3';
26+
import { NodeHttpHandler } from '@smithy/node-http-handler';
2627
import * as AWS from 'aws-sdk';
2728
import { AWSError } from 'aws-sdk';
2829
import * as nock from 'nock';
@@ -86,33 +87,41 @@ describe('S3 - v3', () => {
8687
accessKeyId: 'abcde',
8788
secretAccessKey: 'abcde',
8889
},
90+
requestHandler: new NodeHttpHandler({
91+
connectionTimeout: 10,
92+
requestTimeout: 10,
93+
socketAcquisitionWarningTimeout: 10,
94+
socketTimeout: 10,
95+
}),
8996
});
9097
});
9198

92-
describe('ListObjects', () => {
99+
describe('GetObjectAttributes', () => {
93100
it('adds bucket Name', async () => {
94101
const dummyBucketName = 'dummy-bucket-name';
95102

96103
nock(`https://s3.${region}.amazonaws.com/`).post('/').reply(200, 'null');
97104

98105
await s3
99-
.listObjects({
106+
.getObjectAttributes({
100107
Bucket: dummyBucketName,
108+
Key: undefined,
109+
ObjectAttributes: [],
101110
})
102111
.catch((err: any) => {});
103112

104113
const testSpans: ReadableSpan[] = getTestSpans();
105-
const listObjectsSpans: ReadableSpan[] = testSpans.filter(
114+
const getObjectAttributesSpans: ReadableSpan[] = testSpans.filter(
106115
(s: ReadableSpan) => {
107-
return s.name === 'S3.ListObjects';
116+
return s.name === 'S3.GetObjectAttributes';
108117
}
109118
);
110-
expect(listObjectsSpans.length).toBe(1);
111-
const listObjectsSpan = listObjectsSpans[0];
112-
expect(listObjectsSpan.attributes[AttributeNames.AWS_S3_BUCKET]).toBe(
113-
dummyBucketName
114-
);
115-
expect(listObjectsSpan.kind).toBe(SpanKind.CLIENT);
119+
expect(getObjectAttributesSpans.length).toBe(1);
120+
const getObjectAttributesSpan = getObjectAttributesSpans[0];
121+
expect(
122+
getObjectAttributesSpan.attributes[AttributeNames.AWS_S3_BUCKET]
123+
).toBe(dummyBucketName);
124+
expect(getObjectAttributesSpan.kind).toBe(SpanKind.CLIENT);
116125
});
117126
});
118127
});

0 commit comments

Comments
 (0)