@@ -24,6 +24,27 @@ script_utc_start_time=$(date -u +"%Y%m%dT%H%M%S")
24
24
25
25
mismatch_found=false
26
26
27
+ # Format :
28
+ # [0]: serverless runtime name
29
+ # [1]: python version
30
+ # [2]: random 8-character ID to avoid collisions with other runs
31
+ python27=(" python2.7" " 2.7" $( xxd -l 4 -c 4 -p < /dev/random) )
32
+ python36=(" python3.6" " 3.6" $( xxd -l 4 -c 4 -p < /dev/random) )
33
+ python37=(" python3.7" " 3.7" $( xxd -l 4 -c 4 -p < /dev/random) )
34
+ python38=(" python3.8" " 3.8" $( xxd -l 4 -c 4 -p < /dev/random) )
35
+
36
+ PARAMETERS_SETS=(" python27" " python36" " python37" " python38" )
37
+
38
+ if [ -z " $RUNTIME_PARAM " ]; then
39
+ echo " Python version not specified, running for all python versions."
40
+ else
41
+ RUNTIME_PARAM_NO_DOT=$( echo $RUNTIME_PARAM | sed ' s/\.//' )
42
+ echo " Python version is specified: $RUNTIME_PARAM "
43
+ PARAMETERS_SETS=(python${RUNTIME_PARAM_NO_DOT} )
44
+ BUILD_LAYER_VERSION=python$RUNTIME_PARAM_NO_DOT [1]
45
+ fi
46
+
47
+
27
48
if [ -z " $AWS_SECRET_ACCESS_KEY " ]; then
28
49
echo " No AWS credentials were found in the environment."
29
50
echo " Note that only Datadog employees can run these integration tests."
41
62
42
63
if [ -n " $BUILD_LAYERS " ]; then
43
64
echo " Building layers that will be deployed with our test functions"
44
- source $scripts_dir /build_layers.sh
65
+ PYTHON_VERSION= ${ ! BUILD_LAYER_VERSION} source $scripts_dir /build_layers.sh
45
66
else
46
67
echo " Not building layers, ensure they've already been built or re-run with 'BUILD_LAYERS=true DD_API_KEY=XXXX ./scripts/run_integration_tests.sh'"
47
68
fi
@@ -52,32 +73,48 @@ input_event_files=$(ls ./input_events)
52
73
# Sort event files by name so that snapshots stay consistent
53
74
input_event_files=($( for file_name in ${input_event_files[@]} ; do echo $file_name ; done | sort) )
54
75
55
- # Generate a random 8-character ID to avoid collisions with other runs
56
- run_id=$( xxd -l 4 -c 4 -p < /dev/random)
57
-
58
- # Always remove the stack before exiting, no matter what
76
+ # Always remove the stack(s) before exiting, no matter what
59
77
function remove_stack() {
60
- echo " Removing functions"
61
- serverless remove --stage $run_id
78
+ for parameters_set in " ${PARAMETERS_SETS[@]} " ; do
79
+ serverless_runtime=$parameters_set [0]
80
+ python_version=$parameters_set [1]
81
+ run_id=$parameters_set [2]
82
+ echo " Removing stack for stage : ${! run_id} "
83
+ PYTHON_VERSION=${! python_version} RUNTIME=$parameters_set SERVERLESS_RUNTIME=${! serverless_runtime} \
84
+ serverless remove --stage ${! run_id}
85
+ done
62
86
}
87
+
88
+
89
+
63
90
trap remove_stack EXIT
64
91
65
- echo " Deploying functions"
66
- serverless deploy --stage $run_id
92
+ for parameters_set in " ${PARAMETERS_SETS[@]} " ; do
93
+
94
+ serverless_runtime=$parameters_set [0]
95
+ python_version=$parameters_set [1]
96
+ run_id=$parameters_set [2]
67
97
68
- echo " Invoking functions"
69
- set +e # Don't exit this script if an invocation fails or there's a diff
70
- for handler_name in " ${LAMBDA_HANDLERS[@]} " ; do
71
- for runtime in " ${RUNTIMES[@]} " ; do
72
- function_name= " ${handler_name} _ ${runtime} "
98
+ echo " Deploying functions for runtime : $parameters_set , serverless runtime : ${ ! serverless_runtime} , \
99
+ python version : ${ ! python_version} and run id : ${ ! run_id} "
100
+
101
+ PYTHON_VERSION= ${ ! python_version} RUNTIME= $parameters_set SERVERLESS_RUNTIME= ${ ! serverless_runtime} \
102
+ serverless deploy --stage ${ ! run_id}
73
103
104
+ echo " Invoking functions for runtime $parameters_set "
105
+ set +e # Don't exit this script if an invocation fails or there's a diff
106
+ for handler_name in " ${LAMBDA_HANDLERS[@]} " ; do
107
+
108
+ function_name=" ${handler_name} _python"
109
+ echo " $function_name "
74
110
# Invoke function once for each input event
75
111
for input_event_file in " ${input_event_files[@]} " ; do
76
112
# Get event name without trailing ".json" so we can build the snapshot file name
77
113
input_event_name=$( echo " $input_event_file " | sed " s/.json//" )
78
- snapshot_path=" ./snapshots/return_values/${function_name } _${input_event_name} .json"
114
+ snapshot_path=" ./snapshots/return_values/${handler_name} _ ${parameters_set } _${input_event_name} .json"
79
115
80
- return_value=$( serverless invoke -f $function_name --stage $run_id --path " ./input_events/$input_event_file " )
116
+ return_value=$( PYTHON_VERSION=${! python_version} RUNTIME=$parameters_set SERVERLESS_RUNTIME=${! serverless_runtime} \
117
+ serverless invoke --stage ${! run_id} -f " $function_name " --path " ./input_events/$input_event_file " )
81
118
82
119
if [ ! -f $snapshot_path ]; then
83
120
# If the snapshot file doesn't exist yet, we create it
@@ -109,14 +146,17 @@ sleep $LOGS_WAIT_SECONDS
109
146
set +e # Don't exit this script if there is a diff or the logs endpoint fails
110
147
echo " Fetching logs for invocations and comparing to snapshots"
111
148
for handler_name in " ${LAMBDA_HANDLERS[@]} " ; do
112
- for runtime in " ${RUNTIMES[@]} " ; do
113
- function_name=" ${handler_name} _${runtime} "
114
- function_snapshot_path=" ./snapshots/logs/$function_name .log"
115
-
149
+ for parameters_set in " ${PARAMETERS_SETS[@]} " ; do
150
+ function_name=" ${handler_name} _python"
151
+ function_snapshot_path=" ./snapshots/logs/${handler_name} _${parameters_set} .log"
152
+ serverless_runtime=$parameters_set [0]
153
+ python_version=$parameters_set [1]
154
+ run_id=$parameters_set [2]
116
155
# Fetch logs with serverless cli, retrying to avoid AWS account-wide rate limit error
117
156
retry_counter=0
118
157
while [ $retry_counter -lt 10 ]; do
119
- raw_logs=$( serverless logs -f $function_name --stage $run_id --startTime $script_utc_start_time )
158
+ raw_logs=$( PYTHON_VERSION=${! python_version} RUNTIME=$parameters_set SERVERLESS_RUNTIME=${! serverless_runtime} \
159
+ serverless logs --stage ${! run_id} -f $function_name --startTime $script_utc_start_time )
120
160
fetch_logs_exit_code=$?
121
161
if [ $fetch_logs_exit_code -eq 1 ]; then
122
162
echo " Retrying fetch logs for $function_name ..."
@@ -158,7 +198,7 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
158
198
sed -E " s/(dd_lambda_layer:datadog-python[0-9]+_)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
159
199
sed -E " s/(datadog_lambda:v)([0-9]+\.[0-9]+\.[0-9])/\1XX/g" |
160
200
# Strip out run ID (from function name, resource, etc.)
161
- sed -E " s/$run_id /XXXX/g" |
201
+ sed -E " s/${ ! run_id} /XXXX/g" |
162
202
# Strip out trace/span/parent/timestamps
163
203
sed -E " s/(\" trace_id\" \: \" )[A-Z0-9\.\-]+/\1XXXX/g" |
164
204
sed -E " s/(\" span_id\" \: \" )[A-Z0-9\.\-]+/\1XXXX/g" |
0 commit comments