88
99LOGS_WAIT_SECONDS=45
1010
11+ DEFAULT_NODE_LAYER_VERSION=64
12+ DEFAULT_PYTHON_LAYER_VERSION=49
13+
1114set -e
1215
1316script_utc_start_time=$( date -u +" %Y%m%dT%H%M%S" )
@@ -18,10 +21,13 @@ if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
1821 exit 1
1922fi
2023
21- if [ -n " $BUILD_EXTENSION " ]; then
24+ if [ " $BUILD_EXTENSION " == " true " ]; then
2225 echo " Building extension that will be deployed with our test functions"
26+
2327 # This version number is arbitrary and won't be used by AWS
24- VERSION=123 ./scripts/build_binary_and_layer_dockerized.sh
28+ PLACEHOLDER_EXTENSION_VERSION=123
29+
30+ ARCHITECTURE=amd64 VERSION=$PLACEHOLDER_EXTENSION_VERSION ./scripts/build_binary_and_layer_dockerized.sh
2531else
2632 echo " Not building extension, ensure it has already been built or re-run with 'BUILD_EXTENSION=true'"
2733fi
@@ -39,48 +45,36 @@ cd src
3945env GOOS=linux go build -ldflags=" -s -w" -o ../bootstrap traceGo.go
4046cd ..
4147
42- function getLatestLayerVersion() {
43- layerName=$1
44- lastVersion=$( aws lambda list-layer-versions --layer-name $layerName --region sa-east-1 | jq -r " .LayerVersions | .[0] | .Version" )
45- if [ lastVersion == " null" ]; then
46- exit 1
47- else
48- echo $lastVersion
49- fi
50- }
51-
5248if [ -z " $NODE_LAYER_VERSION " ]; then
53- echo " NODE_LAYER_VERSION not found, getting the latest one"
54- export NODE_LAYER_VERSION=$( getLatestLayerVersion " Datadog-Node14-x" )
55- echo " NODE_LAYER_VERSION set to: $NODE_LAYER_VERSION "
49+ echo " NODE_LAYER_VERSION not found, using the default"
50+ export NODE_LAYER_VERSION=$DEFAULT_NODE_LAYER_VERSION
5651fi
5752
5853if [ -z " $PYTHON_LAYER_VERSION " ]; then
59- echo " PYTHON_LAYER_VERSION not found, getting the latest one"
60- export PYTHON_LAYER_VERSION=$( getLatestLayerVersion " Datadog-Python38" )
61- echo " PYTHON_LAYER_VERSION set to: $PYTHON_LAYER_VERSION "
54+ echo " PYTHON_LAYER_VERSION not found, using the default"
55+ export PYTHON_LAYER_VERSION=$DEFAULT_PYTHON_LAYER_VERSION
6256fi
6357
58+ echo " NODE_LAYER_VERSION set to: $NODE_LAYER_VERSION "
59+ echo " PYTHON_LAYER_VERSION set to: $PYTHON_LAYER_VERSION "
60+
6461# random 8-character ID to avoid collisions with other runs
6562stage=$( xxd -l 4 -c 4 -p < /dev/random)
6663
67- # always remove the stacks before exiting, no matter what
6864function remove_stack() {
6965 echo " Removing stack for stage : ${stage} "
70- NODE_LAYER_VERSION=${NODE_LAYER_VERSION} \
71- PYTHON_LAYER_VERSION=${PYTHON_LAYER_VERSION} \
7266 serverless remove --stage ${stage}
7367}
7468
75- # making sure the remove_stack function will be called no matter what
69+ # always remove the stacks before exiting, no matter what
7670trap remove_stack EXIT
7771
78- # deploying the stack
72+ # deploy the stack
7973NODE_LAYER_VERSION=${NODE_LAYER_VERSION} \
8074PYTHON_LAYER_VERSION=${PYTHON_LAYER_VERSION} \
8175serverless deploy --stage ${stage}
8276
83- # invoking functions
77+ # invoke functions
8478metric_function_names=(" enhanced-metric-node" " enhanced-metric-python" " no-enhanced-metric-node" " no-enhanced-metric-python" " timeout-node" " timeout-python" )
8579log_function_names=(" log-node" " log-python" )
8680trace_function_names=(" simple-trace-node" " simple-trace-python" " simple-trace-go" )
@@ -90,10 +84,8 @@ all_functions=("${metric_function_names[@]}" "${log_function_names[@]}" "${trace
9084set +e # Don't exit this script if an invocation fails or there's a diff
9185
9286for function_name in " ${all_functions[@]} " ; do
93- NODE_LAYER_VERSION=${NODE_LAYER_VERSION} \
94- PYTHON_LAYER_VERSION=${PYTHON_LAYER_VERSION} \
9587 serverless invoke --stage ${stage} -f ${function_name}
96- # two invocations are needed since enhanced metrics are computed with the REPORT log line (which is trigered at the end of the first invocation)
88+ # two invocations are needed since enhanced metrics are computed with the REPORT log line (which is created at the end of the first invocation)
9789 return_value=$( serverless invoke --stage ${stage} -f ${function_name} )
9890
9991 # Compare new return value to snapshot
@@ -181,7 +173,7 @@ for function_name in "${all_functions[@]}"; do
181173 # If no snapshot file exists yet, we create one
182174 echo " Writing logs to $function_snapshot_path because no snapshot exists yet"
183175 echo " $logs " > $function_snapshot_path
184- elif [ -n " $UPDATE_SNAPSHOTS " ]; then
176+ elif [ " $UPDATE_SNAPSHOTS " == " true " ]; then
185177 # If $UPDATE_SNAPSHOTS is set to true write the new logs over the current snapshot
186178 echo " Overwriting log snapshot for $function_snapshot_path "
187179 echo " $logs " > $function_snapshot_path
0 commit comments