diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 94ae4c43..492a8431 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -55,6 +55,13 @@ input_event_files=($(for file_name in ${input_event_files[@]}; do echo $file_nam # Generate a random 8-character ID to avoid collisions with other runs run_id=$(xxd -l 4 -c 4 -p < /dev/random) +# Always remove the stack before exiting, no matter what +function remove_stack() { + echo "Removing functions" + serverless remove --stage $run_id +} +trap remove_stack EXIT + echo "Deploying functions" serverless deploy --stage $run_id @@ -125,9 +132,6 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do echo "Error from final attempt to retrieve logs:" echo $raw_logs - echo "Removing functions" - serverless remove --stage $run_id - exit 1 fi @@ -191,9 +195,6 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do done set -e -echo "Removing functions" -serverless remove --stage $run_id - if [ "$mismatch_found" = true ]; then echo "FAILURE: A mismatch between new data and a snapshot was found and printed above." echo "If the change is expected, generate new snapshots by running 'UPDATE_SNAPSHOTS=true DD_API_KEY=XXXX ./scripts/run_integration_tests.sh'"