66# To regenerate snapshots:
77# UPDATE_SNAPSHOTS=true aws-vault exec sandbox-account-admin -- ./integration_tests/run.sh
88
9- LOGS_WAIT_SECONDS=45
9+ LOGS_WAIT_SECONDS=600
1010
1111DEFAULT_NODE_LAYER_VERSION=66
1212DEFAULT_PYTHON_LAYER_VERSION=49
@@ -40,15 +40,15 @@ GOOS=linux GOARCH=amd64 go build -o extensions/recorder-extension main.go
4040zip -rq ext.zip extensions/* -x " .*" -x " __MACOSX" -x " extensions/.*"
4141cd ..
4242
43- go_test_dirs=(" with-ddlambda" " without-ddlambda" " timeout" " trace" )
43+ go_test_dirs=(" with-ddlambda" " without-ddlambda" " log-with-ddlambda " " log-without-ddlambda " " timeout" " trace" )
4444
45- # build Go Lambda function
45+ # build Go Lambda functions
4646cd src
4747for go_dir in " ${go_test_dirs[@]} " ; do
4848 env GOOS=linux go build -ldflags=" -s -w" -o bin/" $go_dir " go-tests/" $go_dir " /main.go
4949done
5050
51- # build .NET function
51+ # build .NET functions
5252cd csharp-tests
5353dotnet restore
5454set +e # set this so we don't exit if the tools are already installed
@@ -87,24 +87,25 @@ NODE_LAYER_VERSION=${NODE_LAYER_VERSION} \
8787 serverless deploy --stage ${stage}
8888
8989# invoke functions
90- metric_function_names=(" enhanced-metric-node" " enhanced-metric-python" " metric-csharp" " no-enhanced-metric-node" " no-enhanced-metric-python" " timeout-python" " timeout-node" )
91- log_function_names=(" log-node" " log-python" " log-csharp" )
9290
93- go_function_names=(" with-ddlambda-go" " without-ddlambda-go" " timeout-go" )
91+ metric_function_names=(" enhanced-metric-node" " enhanced-metric-python" " metric-csharp" " no-enhanced-metric-node" " no-enhanced-metric-python" " with-ddlambda-go" " without-ddlambda-go" " timeout-python" " timeout-node" " timeout-go" " error-python" " error-node" )
92+ log_function_names=(" log-node" " log-python" " log-csharp" " log-go-with-ddlambda" " log-go-without-ddlambda" )
9493trace_function_names=(" simple-trace-node" " simple-trace-python" " simple-trace-go" )
9594
96- all_functions=(" ${metric_function_names[@]} " " ${log_function_names[@]} " " ${go_function_names[@]} " " ${ trace_function_names[@]}" )
95+ all_functions=(" ${metric_function_names[@]} " " ${log_function_names[@]} " " ${trace_function_names[@]} " )
9796
9897set +e # Don't exit this script if an invocation fails or there's a diff
99-
10098for function_name in " ${all_functions[@]} " ; do
10199 serverless invoke --stage ${stage} -f ${function_name}
100+ done
101+ # wait 30 seconds to make sure metrics aren't merged into a single metric
102+ sleep 30
103+ for function_name in " ${all_functions[@]} " ; do
102104 # two invocations are needed since enhanced metrics are computed with the REPORT log line (which is created at the end of the first invocation)
103105 return_value=$( serverless invoke --stage ${stage} -f ${function_name} )
104-
105106 # Compare new return value to snapshot
106107 diff_output=$( echo " $return_value " | diff - " ./snapshots/expectedInvocationResult" )
107- if [ " $? " -eq 1 ] && [ [ " ${function_name: 0: 7} " != timeout ] || [ " ${function_name: 0: 5} " != error ] ] ; then
108+ if [ " $? " -eq 1 ] && { [ " ${function_name: 0: 7} " != timeout ] && [ " ${function_name: 0: 5} " != error ]; } ; then
108109 echo " Failed: Return value for $function_name does not match snapshot:"
109110 echo " $diff_output "
110111 mismatch_found=true
@@ -113,7 +114,10 @@ for function_name in "${all_functions[@]}"; do
113114 fi
114115done
115116
117+ now=$( date +" %r" )
116118echo " Sleeping $LOGS_WAIT_SECONDS seconds to wait for logs to appear in CloudWatch..."
119+ echo " This should be done in 10 minutes from $now "
120+
117121sleep $LOGS_WAIT_SECONDS
118122
119123for function_name in " ${all_functions[@]} " ; do
@@ -136,19 +140,23 @@ for function_name in "${all_functions[@]}"; do
136140 # Normalize metrics
137141 logs=$(
138142 echo " $raw_logs " |
139- grep " \[sketch\]" |
143+ perl -p -e " s/raise Exception/\n/g" |
144+ grep -v " \[log\]" |
145+ grep " \[sketch\].*" |
140146 perl -p -e " s/(ts\" :)[0-9]{10}/\1XXX/g" |
141- perl -p -e " s/(min\" :)[0-9\.e\-]{2 ,30}/\1XXX/g" |
142- perl -p -e " s/(max\" :)[0-9\.e\-]{2 ,30}/\1XXX/g" |
143- perl -p -e " s/(cnt\" :)[0-9\.e\-]{2 ,30}/\1XXX/g" |
144- perl -p -e " s/(avg\" :)[0-9\.e\-]{2 ,30}/\1XXX/g" |
145- perl -p -e " s/(sum\" :)[0-9\.e\-]{2 ,30}/\1XXX/g" |
147+ perl -p -e " s/(min\" :)[0-9\.e\-]{1 ,30}/\1XXX/g" |
148+ perl -p -e " s/(max\" :)[0-9\.e\-]{1 ,30}/\1XXX/g" |
149+ perl -p -e " s/(cnt\" :)[0-9\.e\-]{1 ,30}/\1XXX/g" |
150+ perl -p -e " s/(avg\" :)[0-9\.e\-]{1 ,30}/\1XXX/g" |
151+ perl -p -e " s/(sum\" :)[0-9\.e\-]{1 ,30}/\1XXX/g" |
146152 perl -p -e " s/(k\" :\[)[0-9\.e\-]{1,30}/\1XXX/g" |
147153 perl -p -e " s/(datadog-nodev)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
148154 perl -p -e " s/(datadog_lambda:v)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
155+ perl -p -e " s/dd_lambda_layer:datadog-go[0-9.]{1,}/dd_lambda_layer:datadog-gox.x.x/g" |
149156 perl -p -e " s/(dd_lambda_layer:datadog-python)[0-9_]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
150157 perl -p -e " s/(serverless.lambda-extension.integration-test.count)[0-9\.]+/\1/g" |
151158 perl -p -e " s/$stage /XXXXXX/g" |
159+ perl -p -e " s/[ ]$//g" |
152160 sort
153161 )
154162 elif [[ " ${log_function_names[*]} " =~ " ${function_name} " ]]; then
@@ -162,33 +170,9 @@ for function_name in "${all_functions[@]}"; do
162170 perl -p -e " s/(,\" request_id\" :\" )[a-zA-Z0-9\-,]+\" //g" |
163171 perl -p -e " s/$stage /STAGE/g" |
164172 perl -p -e " s/(\" message\" :\" ).*(XXX LOG)/\1\2\3/g" |
173+ perl -p -e " s/[ ]$//g" |
165174 grep XXX
166175 )
167- elif [[ " ${go_function_names[*]} " =~ " ${function_name} " ]]; then
168- logs=$(
169- echo " $raw_logs " |
170- grep -E " \[sketch\]|\[log\]" |
171- perl -p -e " s/(ts\" :)[0-9]{10}/\1XXX/g" |
172- perl -p -e " s/(min\" :)[0-9\.e\-]{2,30}/\1XXX/g" |
173- perl -p -e " s/(max\" :)[0-9\.e\-]{2,30}/\1XXX/g" |
174- perl -p -e " s/(cnt\" :)[0-9\.e\-]{2,30}/\1XXX/g" |
175- perl -p -e " s/(avg\" :)[0-9\.e\-]{2,30}/\1XXX/g" |
176- perl -p -e " s/(sum\" :)[0-9\.e\-]{2,30}/\1XXX/g" |
177- perl -p -e " s/(k\" :\[)[0-9\.e\-]{1,30}/\1XXX/g" |
178- perl -p -e " s/(datadog-nodev)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
179- perl -p -e " s/(datadog_lambda:v)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
180- perl -p -e " s/(dd_lambda_layer:datadog-python)[0-9_]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
181- perl -p -e " s/(serverless.lambda-extension.integration-test.count)[0-9\.]+/\1/g" |
182- perl -p -e " s/$stage /XXXXXX/g" |
183- perl -p -e " s/(timestamp\" :)[0-9]{13}/\1TIMESTAMP/g" |
184- perl -p -e " s/(\" REPORT |START |END ).*/\1XXX\" }}/g" |
185- perl -p -e " s/(\" HTTP ).*/\1\" }}/g" |
186- perl -p -e " s/(,\" request_id\" :\" )[a-zA-Z0-9\-,]+\" //g" |
187- perl -p -e " s/$stage /STAGE/g" |
188- perl -p -e " s/(\" message\" :\" ).*(XXX LOG)/\1\2\3/g" |
189- grep XXX
190-
191- )
192176 else
193177 # Normalize traces
194178 logs=$(
@@ -202,6 +186,7 @@ for function_name in "${all_functions[@]}"; do
202186 perl -p -e " s/(,\" runtime-id\" :\" )[a-zA-Z0-9\-,]+\" /\1XXX\" /g" |
203187 perl -p -e " s/(,\" system.pid\" :\" )[a-zA-Z0-9\-,]+\" /\1XXX\" /g" |
204188 perl -p -e " s/$stage /XXXXXX/g" |
189+ perl -p -e " s/[ ]$//g" |
205190 sort
206191 )
207192 fi
0 commit comments