|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# These values need to be in sync with serverless.yml, where there needs to be a function |
| 6 | +# defined for every handler-runtime combination |
| 7 | +LAMBDA_HANDLERS=("async-metrics") |
| 8 | +RUNTIMES=("python27" "python36" "python37" "python38") |
| 9 | + |
| 10 | +LOGS_WAIT_SECONDS=20 |
| 11 | + |
| 12 | +script_path=${BASH_SOURCE[0]} |
| 13 | +scripts_dir=$(dirname $script_path) |
| 14 | +repo_dir=$(dirname $scripts_dir) |
| 15 | +integration_tests_dir="$repo_dir/tests/integration" |
| 16 | + |
| 17 | +script_start_time=$(date --iso-8601=seconds) |
| 18 | + |
| 19 | +echo "Start time is $script_start_time" |
| 20 | + |
| 21 | +echo "Building new layers that will be uploaded with our test functions" |
| 22 | +# source $scripts_dir/build_layers.sh |
| 23 | + |
| 24 | +echo "Deploying functions" |
| 25 | +cd $integration_tests_dir |
| 26 | +serverless deploy |
| 27 | + |
| 28 | +echo "Invoking functions" |
| 29 | +for handler_name in "${LAMBDA_HANDLERS[@]}"; do |
| 30 | + for runtime in "${RUNTIMES[@]}"; do |
| 31 | + echo "Invoking $handler_name-$runtime" |
| 32 | + serverless invoke -f "$handler_name-$runtime" |
| 33 | + done |
| 34 | +done |
| 35 | + |
| 36 | +echo "Sleeping for $LOGS_WAIT_SECONDS seconds to wait for logs to appear in CloudWatch..." |
| 37 | +sleep $LOGS_WAIT_SECONDS |
| 38 | + |
| 39 | +echo "Fetching logs for invocations and comparing to snapshots" |
| 40 | +for handler_name in "${LAMBDA_HANDLERS[@]}"; do |
| 41 | + for runtime in "${RUNTIMES[@]}"; do |
| 42 | + logs=$(serverless logs -f "$handler_name-$runtime" --startTime $script_start_time) |
| 43 | + python compare_to_snapshots.py "$handler_name-$runtime" "$logs" |
| 44 | + done |
| 45 | +done |
| 46 | + |
| 47 | +# Go back to the repo root |
| 48 | +cd $repo_dir |
| 49 | + |
| 50 | +# Download the new CloudWatch logs for each Lambda |
| 51 | + |
| 52 | +# Filter out all logs that aren't metrics and traces and compare to the snapshots in this repo |
0 commit comments