@@ -5,18 +5,14 @@ import { publishVersion, waitForSnapStartReady } from './utils/lambda';
55describe ( 'Snapstart Integration Tests' , ( ) => {
66 const identifier = getIdentifier ( ) ;
77
8- const java = {
9- invocation1 : null as LambdaInvocationDatadogData | null ,
10- invocation2 : null as LambdaInvocationDatadogData | null ,
8+ const results = {
9+ javaInvocation1 : null as LambdaInvocationDatadogData | null ,
10+ javaInvocation2 : null as LambdaInvocationDatadogData | null ,
11+ dotnetInvocation1 : null as LambdaInvocationDatadogData | null ,
12+ dotnetInvocation2 : null as LambdaInvocationDatadogData | null ,
13+ pythonInvocation1 : null as LambdaInvocationDatadogData | null ,
14+ pythonInvocation2 : null as LambdaInvocationDatadogData | null ,
1115 } ;
12- const dotnet = {
13- invocation1 : null as LambdaInvocationDatadogData | null ,
14- invocation2 : null as LambdaInvocationDatadogData | null ,
15- } ;
16- const python = {
17- invocation1 : null as LambdaInvocationDatadogData | null ,
18- invocation2 : null as LambdaInvocationDatadogData | null ,
19- }
2016
2117 beforeAll ( async ( ) => {
2218 const javaBaseFunctionName = `integ-${ identifier } -snapstart-java-lambda` ;
@@ -39,49 +35,59 @@ describe('Snapstart Integration Tests', () => {
3935 const javaFunctionName = `${ javaBaseFunctionName } :${ javaVersion } ` ;
4036 const dotnetFunctionName = `${ dotnetBaseFunctionName } :${ dotnetVersion } ` ;
4137 const pythonFunctionName = `${ pythonBaseFunctionName } :${ pythonVersion } ` ;
42- const results = await Promise . all ( [
38+ const invocationResults = await Promise . all ( [
4339 invokeLambdaAndGetDatadogData ( javaFunctionName , { } , false ) ,
4440 invokeLambdaAndGetDatadogData ( javaFunctionName , { } , false ) ,
4541 invokeLambdaAndGetDatadogData ( dotnetFunctionName , { } , false ) ,
4642 invokeLambdaAndGetDatadogData ( dotnetFunctionName , { } , false ) ,
4743 invokeLambdaAndGetDatadogData ( pythonFunctionName , { } , false ) ,
4844 invokeLambdaAndGetDatadogData ( pythonFunctionName , { } , false ) ,
4945 ] ) ;
50- [ java . invocation1 , java . invocation2 , dotnet . invocation1 , dotnet . invocation2 , python . invocation1 , python . invocation2 ] = results ;
5146
47+ results . javaInvocation1 = invocationResults [ 0 ] ;
48+ results . javaInvocation2 = invocationResults [ 1 ] ;
49+ results . dotnetInvocation1 = invocationResults [ 2 ] ;
50+ results . dotnetInvocation2 = invocationResults [ 3 ] ;
51+ results . pythonInvocation1 = invocationResults [ 4 ] ;
52+ results . pythonInvocation2 = invocationResults [ 5 ] ;
53+
54+ console . log ( 'All Snapstart Lambda invocations and data fetching completed' ) ;
5255 } , 900000 ) ;
5356
5457 describe ( 'Java Runtime with SnapStart' , ( ) => {
55- testSnapStartInvocation ( java . invocation1 ! )
56- testSnapStartInvocation ( java . invocation2 ! )
57- testTraceIsolation ( java . invocation1 ! , java . invocation2 ! )
58- } )
58+ testSnapStartInvocation ( ( ) => results . javaInvocation1 ! ) ;
59+ testSnapStartInvocation ( ( ) => results . javaInvocation2 ! ) ;
60+ testTraceIsolation ( ( ) => results . javaInvocation1 ! , ( ) => results . javaInvocation2 ! ) ;
61+ } ) ;
5962
6063 describe ( '.NET Runtime with SnapStart' , ( ) => {
61- testSnapStartInvocation ( dotnet . invocation1 ! )
62- testSnapStartInvocation ( dotnet . invocation2 ! )
63- testTraceIsolation ( dotnet . invocation1 ! , dotnet . invocation2 ! )
64- } )
64+ testSnapStartInvocation ( ( ) => results . dotnetInvocation1 ! ) ;
65+ testSnapStartInvocation ( ( ) => results . dotnetInvocation2 ! ) ;
66+ testTraceIsolation ( ( ) => results . dotnetInvocation1 ! , ( ) => results . dotnetInvocation2 ! ) ;
67+ } ) ;
6568
6669 describe ( 'Python Runtime with SnapStart' , ( ) => {
67- testSnapStartInvocation ( python . invocation1 ! )
68- testSnapStartInvocation ( python . invocation2 ! )
70+ testSnapStartInvocation ( ( ) => results . pythonInvocation1 ! ) ;
71+ testSnapStartInvocation ( ( ) => results . pythonInvocation2 ! ) ;
6972 // SVLS-5988 - Doesn't completely work as expected.
70- // testTraceIsolation(python.invocation1 !, python.invocation2!)
71- } )
73+ // testTraceIsolation(() => results.pythonInvocation1 !, () => results.pythonInvocation2!);
74+ } ) ;
7275
7376} ) ;
7477
75- function testSnapStartInvocation ( invocation : LambdaInvocationDatadogData ) {
78+ function testSnapStartInvocation ( getInvocation : ( ) => LambdaInvocationDatadogData ) {
7679 it ( 'should invoke successfully' , ( ) => {
80+ const invocation = getInvocation ( ) ;
7781 expect ( invocation . statusCode ) . toBe ( 200 ) ;
7882 } ) ;
7983
8084 it ( 'should send one trace to Datadog' , ( ) => {
85+ const invocation = getInvocation ( ) ;
8186 expect ( invocation . traces ?. length ) . toEqual ( 1 ) ;
8287 } ) ;
8388
8489 it ( 'should have aws.lambda span with Snapstart properties' , ( ) => {
90+ const invocation = getInvocation ( ) ;
8591 const trace = invocation . traces ! [ 0 ] ;
8692 const awsLambdaSpan = trace . spans . find ( ( span : any ) =>
8793 span . attributes . operation_name === 'aws.lambda'
@@ -91,11 +97,11 @@ function testSnapStartInvocation(invocation: LambdaInvocationDatadogData) {
9197 } ) ;
9298
9399 it ( 'should have aws.lambda.snapstart_restore span' , ( ) => {
100+ const invocation = getInvocation ( ) ;
94101 const trace = invocation . traces ! [ 0 ] ;
95102 const awsLambdaSpan = trace . spans . find ( ( span : any ) =>
96103 span . attributes . operation_name === 'aws.lambda'
97104 ) ;
98- expect ( awsLambdaSpan ?. attributes . custom . cold_start ) . toBe ( 'true' ) ;
99105
100106 const restoreSpan = trace . spans . find ( ( span : any ) =>
101107 span . attributes . operation_name === 'aws.lambda.snapstart_restore'
@@ -110,6 +116,7 @@ function testSnapStartInvocation(invocation: LambdaInvocationDatadogData) {
110116 } ) ;
111117
112118 it ( 'should NOT have aws.lambda.cold_start span (replaced by restore span)' , ( ) => {
119+ const invocation = getInvocation ( ) ;
113120 const trace = invocation . traces ! [ 0 ] ;
114121 const coldStartSpan = trace . spans . find ( ( span : any ) =>
115122 span . attributes . operation_name === 'aws.lambda.cold_start'
@@ -118,42 +125,20 @@ function testSnapStartInvocation(invocation: LambdaInvocationDatadogData) {
118125 } ) ;
119126}
120127
121- function testWarmInvocation ( invocation : LambdaInvocationDatadogData ) {
122- it ( 'should invoke successfully' , ( ) => {
123- expect ( invocation . statusCode ) . toBe ( 200 ) ;
124- } ) ;
125-
126- it ( 'should send one trace to Datadog' , ( ) => {
127- expect ( invocation . traces ?. length ) . toEqual ( 1 ) ;
128- } ) ;
129-
130- it ( 'should NOT have aws.lambda.snapstart_restore span' , ( ) => {
131- const trace = invocation . traces ! [ 0 ] ;
132- const restoreSpan = trace . spans . find ( ( span : any ) =>
133- span . attributes . operation_name === 'aws.lambda.snapstart_restore'
134- ) ;
135- expect ( restoreSpan ) . toBeUndefined ( ) ;
136- } ) ;
137-
138- it ( 'should NOT have aws.lambda.cold_start span' , ( ) => {
139- const trace = invocation . traces ! [ 0 ] ;
140- const coldStartSpan = trace . spans . find ( ( span : any ) =>
141- span . attributes . operation_name === 'aws.lambda.cold_start'
142- ) ;
143- expect ( coldStartSpan ) . toBeUndefined ( ) ;
144- } ) ;
145- }
146-
147- function testTraceIsolation ( invocation1 : LambdaInvocationDatadogData , invocation2 : LambdaInvocationDatadogData ) {
128+ function testTraceIsolation ( getInvocation1 : ( ) => LambdaInvocationDatadogData , getInvocation2 : ( ) => LambdaInvocationDatadogData ) {
148129 describe ( 'Trace Isolation Between Concurrent Invocations' , ( ) => {
149130 it ( 'should have different trace IDs for each invocation' , ( ) => {
131+ const invocation1 = getInvocation1 ( ) ;
132+ const invocation2 = getInvocation2 ( ) ;
150133 const trace1 = invocation1 . traces ! [ 0 ] ;
151134 const trace2 = invocation2 . traces ! [ 0 ] ;
152135
153136 expect ( trace1 . trace_id ) . not . toEqual ( trace2 . trace_id ) ;
154137 } ) ;
155138
156139 it ( 'should NOT have traces linked together' , ( ) => {
140+ const invocation1 = getInvocation1 ( ) ;
141+ const invocation2 = getInvocation2 ( ) ;
157142 const trace1 = invocation1 . traces ! [ 0 ] ;
158143 const trace2 = invocation2 . traces ! [ 0 ] ;
159144
0 commit comments