Skip to content

Commit bbe4d5d

Browse files
committed
fix/troubleshooting
1 parent 135ad3b commit bbe4d5d

File tree

1 file changed

+61
-19
lines changed

1 file changed

+61
-19
lines changed

Diff for: packages/tracing/tests/e2e/tracer.test.ts

+61-19
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,25 @@ describe('Tracer integration tests', () => {
151151
// Assert that there are three subsegments
152152
expect(handlerSubsegment?.subsegments?.length).toBe(3);
153153

154-
const [ AWSSDKSubsegment1, AWSSDKSubsegment2, HTTPSegment ] = handlerSubsegment?.subsegments;
155-
// Assert that the subsegment names are the expected ones
156-
expect(AWSSDKSubsegment1.name).toBe('DynamoDB');
157-
expect(AWSSDKSubsegment2.name).toBe('DynamoDB');
158-
expect(HTTPSegment.name).toBe('httpbin.org');
154+
// Sort the subsegments by name
155+
const dynamoDBSubsegments: ParsedDocument[] = [];
156+
const httpSubsegment: ParsedDocument[] = [];
157+
const otherSegments: ParsedDocument[] = [];
158+
handlerSubsegment?.subsegments.forEach(subsegment => {
159+
if (subsegment.name === 'DynamoDB') {
160+
dynamoDBSubsegments.push(subsegment);
161+
} else if (subsegment.name === 'httpbin.org') {
162+
httpSubsegment.push(subsegment);
163+
} else {
164+
otherSegments.push(subsegment);
165+
}
166+
});
167+
// Assert that there are exactly two subsegment with the name 'DynamoDB'
168+
expect(dynamoDBSubsegments.length).toBe(2);
169+
// Assert that there is exactly one subsegment with the name 'httpbin.org'
170+
expect(httpSubsegment.length).toBe(1);
171+
// Assert that there are exactly zero other subsegments
172+
expect(otherSegments.length).toBe(0);
159173

160174
const { annotations, metadata } = handlerSubsegment;
161175

@@ -222,11 +236,25 @@ describe('Tracer integration tests', () => {
222236
// Assert that there're two subsegments
223237
expect(handlerSubsegment?.subsegments?.length).toBe(3);
224238

225-
const [ AWSSDKSubsegment1, AWSSDKSubsegment2, HTTPSegment ] = handlerSubsegment?.subsegments;
226-
// Assert that the subsegment names is the expected ones
227-
expect(AWSSDKSubsegment1.name).toBe('DynamoDB');
228-
expect(AWSSDKSubsegment2.name).toBe('DynamoDB');
229-
expect(HTTPSegment.name).toBe('httpbin.org');
239+
// Sort the subsegments by name
240+
const dynamoDBSubsegments: ParsedDocument[] = [];
241+
const httpSubsegment: ParsedDocument[] = [];
242+
const otherSegments: ParsedDocument[] = [];
243+
handlerSubsegment?.subsegments.forEach(subsegment => {
244+
if (subsegment.name === 'DynamoDB') {
245+
dynamoDBSubsegments.push(subsegment);
246+
} else if (subsegment.name === 'httpbin.org') {
247+
httpSubsegment.push(subsegment);
248+
} else {
249+
otherSegments.push(subsegment);
250+
}
251+
});
252+
// Assert that there are exactly two subsegment with the name 'DynamoDB'
253+
expect(dynamoDBSubsegments.length).toBe(2);
254+
// Assert that there is exactly one subsegment with the name 'httpbin.org'
255+
expect(httpSubsegment.length).toBe(1);
256+
// Assert that there are exactly zero other subsegments
257+
expect(otherSegments.length).toBe(0);
230258

231259
const { annotations, metadata } = handlerSubsegment;
232260

@@ -293,11 +321,25 @@ describe('Tracer integration tests', () => {
293321
// Assert that there're two subsegments
294322
expect(handlerSubsegment?.subsegments?.length).toBe(3);
295323

296-
const [ AWSSDKSubsegment1, AWSSDKSubsegment2, HTTPSegment ] = handlerSubsegment?.subsegments;
297-
// Assert that the subsegment names are the expected ones
298-
expect(AWSSDKSubsegment1.name).toBe('DynamoDB');
299-
expect(AWSSDKSubsegment2.name).toBe('DynamoDB');
300-
expect(HTTPSegment.name).toBe('httpbin.org');
324+
// Sort the subsegments by name
325+
const dynamoDBSubsegments: ParsedDocument[] = [];
326+
const httpSubsegment: ParsedDocument[] = [];
327+
const otherSegments: ParsedDocument[] = [];
328+
handlerSubsegment?.subsegments.forEach(subsegment => {
329+
if (subsegment.name === 'DynamoDB') {
330+
dynamoDBSubsegments.push(subsegment);
331+
} else if (subsegment.name === 'httpbin.org') {
332+
httpSubsegment.push(subsegment);
333+
} else {
334+
otherSegments.push(subsegment);
335+
}
336+
});
337+
// Assert that there are exactly two subsegment with the name 'DynamoDB'
338+
expect(dynamoDBSubsegments.length).toBe(2);
339+
// Assert that there is exactly one subsegment with the name 'httpbin.org'
340+
expect(httpSubsegment.length).toBe(1);
341+
// Assert that there are exactly zero other subsegments
342+
expect(otherSegments.length).toBe(0);
301343

302344
const { annotations, metadata } = handlerSubsegment;
303345

@@ -384,7 +426,7 @@ describe('Tracer integration tests', () => {
384426
// Assert that the subsegment name is the expected one
385427
expect(handlerSubsegment.name).toBe('## index.handler');
386428
if (handlerSubsegment?.subsegments !== undefined) {
387-
// Assert that there're three subsegments
429+
// Assert that there are four subsegments
388430
expect(handlerSubsegment?.subsegments?.length).toBe(4);
389431

390432
// Sort the subsegments by name
@@ -486,7 +528,7 @@ describe('Tracer integration tests', () => {
486528
// Assert that the subsegment name is the expected one
487529
expect(handlerSubsegment.name).toBe('## index.handler');
488530
if (handlerSubsegment?.subsegments !== undefined) {
489-
// Assert that there're three subsegments
531+
// Assert that there are four subsegments
490532
expect(handlerSubsegment?.subsegments?.length).toBe(4);
491533

492534
// Sort the subsegments by name
@@ -588,8 +630,8 @@ describe('Tracer integration tests', () => {
588630
// Assert that the subsegment name is the expected one
589631
expect(handlerSubsegment.name).toBe('## index.handler');
590632
if (handlerSubsegment?.subsegments !== undefined) {
591-
// Assert that there're three subsegments
592-
expect(handlerSubsegment?.subsegments?.length).toBe(5);
633+
// Assert that there are four subsegments
634+
expect(handlerSubsegment?.subsegments?.length).toBe(4);
593635

594636
// Sort the subsegments by name
595637
const dynamoDBSubsegments: ParsedDocument[] = [];

0 commit comments

Comments
 (0)