Skip to content

Commit 840f7cd

Browse files
committed
Deploy, invoke, fetch logs, and compare to snapshot
1 parent 34f27a9 commit 840f7cd

13 files changed

+315
-749
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ nosetests.xml
3636
.eggs/
3737
.env/
3838
.idea/
39+
40+
41+
**/.serverless/

scripts/run_integration_tests.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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

tests/integration/.serverless/cloudformation-template-create-stack.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)