Skip to content

chore: remove httpbinorg request from integration tests #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class MyFunctionBase {
return Promise.all([
dynamoDBv2.put({ TableName: testTableName, Item: { id: `${serviceName}-${event.invocation}-sdkv2` } }).promise(),
dynamoDBv3.send(new PutItemCommand({ TableName: testTableName, Item: { id: { 'S': `${serviceName}-${event.invocation}-sdkv3` } } })),
axios.get('https://httpbin.org/status/200'),
axios.get('https://awslabs.github.io/aws-lambda-powertools-typescript/latest/', { timeout: 5000 }),
new Promise((resolve, reject) => {
setTimeout(() => {
const res = this.myMethod();
Expand Down
24 changes: 12 additions & 12 deletions packages/tracer/tests/e2e/allFeatures.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -216,7 +216,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* '## index.handler' subsegment should have 4 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
* 4. '### myMethod' (method decorator)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
Expand All @@ -226,9 +226,9 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org', '### myMethod' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io', '### myMethod' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('### myMethod')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

Expand Down Expand Up @@ -289,7 +289,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -299,7 +299,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* '## index.handler' subsegment should have 4 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
* 4. '### myMethod' (method decorator)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
Expand All @@ -309,9 +309,9 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org', '### myMethod' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io', '### myMethod' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('### myMethod')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

Expand Down Expand Up @@ -343,7 +343,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -353,7 +353,7 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
* '## index.handler' subsegment should have 4 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
* 4. '### myMethod' (method decorator)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
Expand All @@ -363,9 +363,9 @@ describe(`Tracer E2E tests, all features with decorator instantiation for runtim
if (!handlerSubsegment.subsegments) {
fail('"## index.handlerWithCaptureResponseFalse" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org', '### myMethod' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io', '### myMethod' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('### myMethod')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandard
const customAnnotationKey = process.env.EXPECTED_CUSTOM_ANNOTATION_KEY ?? 'myAnnotation';
const customAnnotationValue = process.env.EXPECTED_CUSTOM_ANNOTATION_VALUE ?? 'myValue';
const customMetadataKey = process.env.EXPECTED_CUSTOM_METADATA_KEY ?? 'myMetadata';
const customMetadataValue = JSON.parse(process.env.EXPECTED_CUSTOM_METADATA_VALUE) ?? { bar: 'baz' };
const customResponseValue = JSON.parse(process.env.EXPECTED_CUSTOM_RESPONSE_VALUE) ?? { foo: 'bar' };
const customMetadataValue = process.env.EXPECTED_CUSTOM_METADATA_VALUE ? JSON.parse(process.env.EXPECTED_CUSTOM_METADATA_VALUE) : { bar: 'baz' };
const customResponseValue = process.env.EXPECTED_CUSTOM_RESPONSE_VALUE ? JSON.parse(process.env.EXPECTED_CUSTOM_RESPONSE_VALUE) : { foo: 'bar' };
const customErrorMessage = process.env.EXPECTED_CUSTOM_ERROR_MESSAGE ?? 'An error has occurred';
const testTableName = process.env.TEST_TABLE_NAME ?? 'TestTable';

Expand Down Expand Up @@ -58,7 +58,7 @@ export const handler = async (event: CustomEvent, _context: Context): Promise<vo
try {
await dynamoDBv2.put({ TableName: testTableName, Item: { id: `${serviceName}-${event.invocation}-sdkv2` } }).promise();
await dynamoDBv3.send(new PutItemCommand({ TableName: testTableName, Item: { id: { 'S': `${serviceName}-${event.invocation}-sdkv3` } } }));
await axios.get('https://httpbin.org/status/200');
await axios.get('https://awslabs.github.io/aws-lambda-powertools-typescript/latest/', { timeout: 5000 });

const res = customResponseValue;
if (event.throw) {
Expand Down
8 changes: 4 additions & 4 deletions packages/tracer/tests/e2e/allFeatures.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe(`Tracer E2E tests, all features with manual instantiation for runtime:
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -138,7 +138,7 @@ describe(`Tracer E2E tests, all features with manual instantiation for runtime:
* '## index.handler' subsegment should have 3 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
expect(handlerSubsegment.name).toBe('## index.handler');
Expand All @@ -147,9 +147,9 @@ describe(`Tracer E2E tests, all features with manual instantiation for runtime:
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

const shouldThrowAnError = (i === (invocations - 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandard
const customAnnotationKey = process.env.EXPECTED_CUSTOM_ANNOTATION_KEY ?? 'myAnnotation';
const customAnnotationValue = process.env.EXPECTED_CUSTOM_ANNOTATION_VALUE ?? 'myValue';
const customMetadataKey = process.env.EXPECTED_CUSTOM_METADATA_KEY ?? 'myMetadata';
const customMetadataValue = JSON.parse(process.env.EXPECTED_CUSTOM_METADATA_VALUE) ?? { bar: 'baz' };
const customResponseValue = JSON.parse(process.env.EXPECTED_CUSTOM_RESPONSE_VALUE) ?? { foo: 'bar' };
const customMetadataValue = process.env.EXPECTED_CUSTOM_METADATA_VALUE ? JSON.parse(process.env.EXPECTED_CUSTOM_METADATA_VALUE) : { bar: 'baz' };
const customResponseValue = process.env.EXPECTED_CUSTOM_RESPONSE_VALUE ? JSON.parse(process.env.EXPECTED_CUSTOM_RESPONSE_VALUE) : { foo: 'bar' };
const customErrorMessage = process.env.EXPECTED_CUSTOM_ERROR_MESSAGE ?? 'An error has occurred';
const testTableName = process.env.TEST_TABLE_NAME ?? 'TestTable';

Expand Down Expand Up @@ -52,7 +52,7 @@ const testHandler = async (event: CustomEvent, _context: Context): Promise<void>
try {
await dynamoDBv2.put({ TableName: testTableName, Item: { id: `${serviceName}-${event.invocation}-sdkv2` } }).promise();
await dynamoDBv3.send(new PutItemCommand({ TableName: testTableName, Item: { id: { 'S': `${serviceName}-${event.invocation}-sdkv3` } } }));
await axios.get('https://httpbin.org/status/200');
await axios.get('https://awslabs.github.io/aws-lambda-powertools-typescript/latest/', { timeout: 5000 });

const res = customResponseValue;
if (event.throw) {
Expand Down
24 changes: 12 additions & 12 deletions packages/tracer/tests/e2e/allFeatures.middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -216,7 +216,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* '## index.handler' subsegment should have 3 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
expect(handlerSubsegment.name).toBe('## index.handler');
Expand All @@ -225,9 +225,9 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

const shouldThrowAnError = (i === (invocations - 1));
Expand Down Expand Up @@ -287,7 +287,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -297,7 +297,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* '## index.handler' subsegment should have 3 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
expect(handlerSubsegment.name).toBe('## index.handler');
Expand All @@ -306,9 +306,9 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

const shouldThrowAnError = (i === (invocations - 1));
Expand Down Expand Up @@ -339,7 +339,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -349,7 +349,7 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
* '## index.handlerWithNoCaptureResponseViaMiddlewareOption' subsegment should have 3 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
expect(handlerSubsegment.name).toBe('## index.handlerWithNoCaptureResponseViaMiddlewareOption');
Expand All @@ -358,9 +358,9 @@ describe(`Tracer E2E tests, all features with middy instantiation for runtime: $
if (!handlerSubsegment.subsegments) {
fail('"## index.handlerWithNoCaptureResponseViaMiddlewareOption" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

const shouldThrowAnError = (i === (invocations - 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class MyFunctionBase {
try {
await dynamoDBv2.put({ TableName: testTableName, Item: { id: `${serviceName}-${event.invocation}-sdkv2` } }).promise();
await dynamoDBv3.send(new PutItemCommand({ TableName: testTableName, Item: { id: { 'S': `${serviceName}-${event.invocation}-sdkv3` } } }));
await axios.get('https://httpbin.org/status/200');
await axios.get('https://awslabs.github.io/aws-lambda-powertools-typescript/latest/', { timeout: 5000 });

const res = this.myMethod();
if (event.throw) {
Expand Down
16 changes: 8 additions & 8 deletions packages/tracer/tests/e2e/asyncHandler.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -165,7 +165,7 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
* '## index.handler' subsegment should have 4 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
* 4. '### myMethod' (method decorator)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
Expand All @@ -175,9 +175,9 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org', '### myMethod' ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io', '### myMethod' ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get('### myMethod')?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

Expand Down Expand Up @@ -238,7 +238,7 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
* 2. Lambda Function (AWS::Lambda::Function)
* 3. DynamoDB (AWS::DynamoDB)
* 4. DynamoDB Table (AWS::DynamoDB::Table)
* 5. Remote call (httpbin.org)
* 5. Remote call (awslabs.github.io)
*/
expect(trace.Segments.length).toBe(5);
const invocationSubsegment = getInvocationSubsegment(trace);
Expand All @@ -248,7 +248,7 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
* '## index.handler' subsegment should have 4 subsegments
* 1. DynamoDB (PutItem on the table)
* 2. DynamoDB (PutItem overhead)
* 3. httpbin.org (Remote call)
* 3. awslabs.github.io (Remote call)
* 4. '### mySubsegment' (method decorator with custom name)
*/
const handlerSubsegment = getFirstSubsegment(invocationSubsegment);
Expand All @@ -258,9 +258,9 @@ describe(`Tracer E2E tests, asynchronous handler with decorator instantiation fo
if (!handlerSubsegment.subsegments) {
fail('"## index.handler" subsegment should have subsegments');
}
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'httpbin.org', expectedCustomSubSegmentName ]);
const subsegments = splitSegmentsByName(handlerSubsegment.subsegments, [ 'DynamoDB', 'awslabs.github.io', expectedCustomSubSegmentName ]);
expect(subsegments.get('DynamoDB')?.length).toBe(2);
expect(subsegments.get('httpbin.org')?.length).toBe(1);
expect(subsegments.get('awslabs.github.io')?.length).toBe(1);
expect(subsegments.get(expectedCustomSubSegmentName)?.length).toBe(1);
expect(subsegments.get('other')?.length).toBe(0);

Expand Down