55
66# These values need to be in sync with serverless.yml, where there needs to be a function
77# defined for every handler-runtime combination
8- LAMBDA_HANDLERS=(" async-metrics" " sync-metrics" )
8+ LAMBDA_HANDLERS=(" async-metrics" " sync-metrics" " http-requests " )
99RUNTIMES=(" python27" " python36" " python37" " python38" )
1010
1111LOGS_WAIT_SECONDS=20
2828if [ -z " $DD_API_KEY " ]; then
2929 echo " No DD_API_KEY env var set, exiting"
3030 exit 1
31- else
32- echo " The API key is $DD_API_KEY "
3331fi
3432
35- echo " Building layers that will be deployed with our test functions"
36- # source $scripts_dir/build_layers.sh
33+ if [ -n " $BUILD_LAYERS " ]; then
34+ echo " Building layers that will be deployed with our test functions"
35+ source $scripts_dir /build_layers.sh
36+ else
37+ echo " Not building layers, ensure they've already been built or re-run with 'REBUILD_LAYERS=true ./scripts/run_integration_tests.sh'"
38+ fi
3739
3840echo " Deploying functions"
3941cd $integration_tests_dir
@@ -48,9 +50,9 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
4850
4951 return_value=$( serverless invoke -f $function_name )
5052
51- if [ -n " $UPDATE_SNAPSHOTS " ]; then
53+ if [ -n " $UPDATE_SNAPSHOTS " ] || [ ! -f $function_snapshot_path ] ; then
5254 # If $UPDATE_SNAPSHOTS is set to true, write the new logs over the current snapshot
53- echo " Overwriting return value snapshot for $function_name "
55+ echo " Writing return value snapshot for $function_name "
5456 echo " $return_value " > $function_snapshot_path
5557 else
5658 # Compare new return value to snapshot
@@ -87,24 +89,25 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
8789 # Normalize Lambda runtime report logs
8890 logs=$( echo " $logs " | sed -E ' s/(RequestId|TraceId|SegmentId|Duration|Memory Used|"e"): [a-z0-9\.\-]+/\1: XXXX/g' )
8991 # Normalize DD APM headers
90- logs=$( echo " $logs " | sed -E " s/(' x-datadog-parent-id': '|' x-datadog-trace-id': ' )[0-9]+/\1XXXX/g" )
91- # Normalize timestamps logged requests
92+ logs=$( echo " $logs " | sed -E " s/(x-datadog-parent-id:| x-datadog-trace-id: )[0-9]+/\1XXXX/g" )
93+ # Normalize timestamps in datapoints POSTed to DD
9294 logs=$( echo " $logs " | sed -E ' s/"points": \[\[[0-9\.]+,/"points": \[\[XXXX,/g' )
93- # Normalize the invocation IDs used in requests to the Lambda runtime
94- logs=$( echo " $logs " | sed -E ' s/\/2018-06-01\/runtime\/invocation\/[a-z0-9-]+/\/2018-06-01\/runtime\/invocation\/XXXX/g' )
95+ # # Normalize invocation IDs used in requests to the Lambda runtime
96+ # logs=$(echo "$logs" | sed -E 's/\/2018-06-01\/runtime\/invocation\/[a-z0-9-]+/\/2018-06-01\/runtime\/invocation\/XXXX/g')
9597 # Strip API key from logged requests
9698 logs=$( echo " $logs " | sed -E " s/(api_key=|'api_key': ')[a-z0-9\.\-]+/\1XXXX/g" )
9799
98- if [ -n " $UPDATE_SNAPSHOTS " ]; then
99- # If $UPDATE_SNAPSHOTS is set to true, write the new logs over the current snapshot
100- echo " Overwriting log snapshot for $function_name "
100+ if [ -n " $UPDATE_SNAPSHOTS " ] || [ ! -f $function_snapshot_path ]; then
101+ # If $UPDATE_SNAPSHOTS is set to true write the new logs over the current snapshot
102+ # If no file exists yet, we create one
103+ echo " Writing log snapshot for $function_name "
101104 echo " $logs " > $function_snapshot_path
102105 else
103106 # Compare new logs to snapshots
104107 set +e # Don't exit this script if there is a diff
105108 diff_output=$( echo " $logs " | diff - $function_snapshot_path )
106109 if [ $? -eq 1 ]; then
107- echo " Failed: Mismatch found between new $function_name logs and snapshot:"
110+ echo " Failed: Mismatch found between new $function_name logs (first) and snapshot (second) :"
108111 echo " $diff_output "
109112 mismatch_found=true
110113 else
0 commit comments