11#! /bin/bash
22
3- # Stop execution if any command has errors
3+ # Usage:
4+ # To check if new changes to the layer cause changes to any snapshots:
5+ # BUILD_LAYERS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests
6+ # To regenerate snapshots:
7+ # UPDATE_SNAPSHOTS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests
8+
49set -e
510
611# These values need to be in sync with serverless.yml, where there needs to be a function
@@ -21,15 +26,15 @@ mismatch_found=false
2126
2227echo " Start time is $script_start_time "
2328
24- if [ -n " $UPDATE_SNAPSHOTS " ]; then
25- echo " Overwriting snapshots in this execution"
26- fi
27-
2829if [ -z " $DD_API_KEY " ]; then
2930 echo " No DD_API_KEY env var set, exiting"
3031 exit 1
3132fi
3233
34+ if [ -n " $UPDATE_SNAPSHOTS " ]; then
35+ echo " Overwriting snapshots in this execution"
36+ fi
37+
3338if [ -n " $BUILD_LAYERS " ]; then
3439 echo " Building layers that will be deployed with our test functions"
3540 source $scripts_dir /build_layers.sh
@@ -42,7 +47,7 @@ cd $integration_tests_dir
4247serverless deploy
4348
4449echo " Invoking functions"
45- set +e # Don't exit this script if an invocation fails
50+ set +e # Don't immediately exit this script if an invocation fails or there's a diff
4651for handler_name in " ${LAMBDA_HANDLERS[@]} " ; do
4752 for runtime in " ${RUNTIMES[@]} " ; do
4853 function_name=" $handler_name -$runtime "
@@ -52,6 +57,7 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
5257
5358 if [ -n " $UPDATE_SNAPSHOTS " ] || [ ! -f $function_snapshot_path ]; then
5459 # If $UPDATE_SNAPSHOTS is set to true, write the new logs over the current snapshot
60+ # If the snapshot file doesn't exist yet, we create it
5561 echo " Writing return value snapshot for $function_name "
5662 echo " $return_value " > $function_snapshot_path
5763 else
@@ -67,7 +73,6 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
6773 fi
6874 done
6975done
70-
7176set -e
7277
7378echo " Sleeping $LOGS_WAIT_SECONDS seconds to wait for logs to appear in CloudWatch..."
0 commit comments