Skip to content

Commit

Permalink
Add errors test (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhinsch authored Nov 9, 2021
1 parent 6319d59 commit 7973f5a
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 59 deletions.
16 changes: 9 additions & 7 deletions integration_tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

LOGS_WAIT_SECONDS=45

DEFAULT_NODE_LAYER_VERSION=64
DEFAULT_NODE_LAYER_VERSION=66
DEFAULT_PYTHON_LAYER_VERSION=49

set -e
Expand Down Expand Up @@ -79,12 +79,9 @@ NODE_LAYER_VERSION=${NODE_LAYER_VERSION} \
serverless deploy --stage ${stage}

# invoke functions

python_node_function_names=("enhanced-metric-node" "enhanced-metric-python" "no-enhanced-metric-node" "no-enhanced-metric-python" "timeout-python" "timeout-node")
python_node_function_names=("enhanced-metric-node" "enhanced-metric-python" "no-enhanced-metric-node" "no-enhanced-metric-python" "timeout-python" "timeout-node" "error-node" "error-python")
python_node_log_function_names=("log-node" "log-python")

go_function_names=("with-ddlambda-go" "without-ddlambda-go" "timeout-go")

trace_function_names=("simple-trace-node" "simple-trace-python" "simple-trace-go")

all_functions=("${python_node_function_names[@]}" "${python_node_log_function_names[@]}" "${go_function_names[@]}" "${trace_function_names[@]}")
Expand All @@ -98,7 +95,7 @@ for function_name in "${all_functions[@]}"; do

# Compare new return value to snapshot
diff_output=$(echo "$return_value" | diff - "./snapshots/expectedInvocationResult")
if [ $? -eq 1 ] && [ ${function_name:0:7} != timeout ]; then
if [ "$?" -eq 1 ] && [ [ "${function_name:0:7}" != timeout ] || [ "${function_name:0:5}" != error ] ]; then
echo "Failed: Return value for $function_name does not match snapshot:"
echo "$diff_output"
mismatch_found=true
Expand Down Expand Up @@ -224,9 +221,14 @@ for function_name in "${all_functions[@]}"; do

done

if [ "$mismatch_found" = true ]; then
echo
if [ "$UPDATE_SNAPSHOTS" == "true" ]; then
echo "DONE: Snapshots were updated for all functions."
exit 0
elif [ "$mismatch_found" == true ]; then
echo "FAILURE: A mismatch between new data and a snapshot was found and printed above."
exit 1
fi

echo "SUCCESS: No difference found between snapshots and new return values or logs"
echo
23 changes: 23 additions & 0 deletions integration_tests/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ functions:
DD_TAGS: tagA:valueA tagB:valueB
DD_EXTRA_TAGS: tagC:valueC tagD:valueD

error-node:
runtime: nodejs14.x
handler: src/metric.errorTest
layers:
- arn:aws:lambda:${self:provider.region}:464622532012:layer:Datadog-Node14-x:${env:NODE_LAYER_VERSION}
- { Ref: RecorderExtensionLambdaLayer }
- { Ref: DatadogExtensionIntegrationTestLambdaLayer }
environment:
DD_TAGS: tagA:valueA tagB:valueB
DD_EXTRA_TAGS: tagC:valueC tagD:valueD

enhanced-metric-python:
runtime: python3.8
handler: datadog_lambda.handler.handler
Expand All @@ -65,6 +76,18 @@ functions:
DD_EXTRA_TAGS: tagC:valueC tagD:valueD
DD_LAMBDA_HANDLER: src/metricPython.metric

error-python:
runtime: python3.8
handler: datadog_lambda.handler.handler
layers:
- arn:aws:lambda:${self:provider.region}:464622532012:layer:Datadog-Python38:${env:PYTHON_LAYER_VERSION}
- { Ref: RecorderExtensionLambdaLayer }
- { Ref: DatadogExtensionIntegrationTestLambdaLayer }
environment:
DD_TAGS: tagA:valueA tagB:valueB
DD_EXTRA_TAGS: tagC:valueC tagD:valueD
DD_LAMBDA_HANDLER: src/metricPython.error

with-ddlambda-go:
runtime: provided.al2
handler: src/bin/with-ddlambda
Expand Down
1 change: 1 addition & 0 deletions integration_tests/snapshots/enhanced-metric-node
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
[sketch] {"metric":"aws.lambda.enhanced.invocations","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","datadog_lambda:vX.X.X","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","runtime:nodejs14.x","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.max_memory_used","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.memorysize","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.runtime_duration","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:false","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.runtime_duration","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","dd_extension_version:123","dd_lambda_layer:datadog-nodevX.X.X","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-node","functionname:integration-tests-extension-XXXXXX-enhanced-metric-node","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-node","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
1 change: 1 addition & 0 deletions integration_tests/snapshots/enhanced-metric-python
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
[sketch] {"metric":"aws.lambda.enhanced.invocations","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","datadog_lambda:vX.X.X","dd_extension_version:123","dd_lambda_layer:datadog-pythonX.X.X","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","runtime:python3.8","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.max_memory_used","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.memorysize","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.runtime_duration","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:false","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":3,"max":3,"avg":3,"sum":3,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"aws.lambda.enhanced.runtime_duration","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","cold_start:true","dd_extension_version:123","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","distributions":null,"tags":["account_id:601427279990","architecture:x86_64","aws_account:601427279990","dd_extension_version:123","dd_lambda_layer:datadog-pythonX.X.X","env:integration-tests-env","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-extension-XXXXXX-enhanced-metric-python","functionname:integration-tests-extension-XXXXXX-enhanced-metric-python","memorysize:1024","region:sa-east-1","resource:integration-tests-extension-XXXXXX-enhanced-metric-python","service:integration-tests-service","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued","version:integration-tests-version"],"dogsketches":[{"ts":XXX,"cnt":1,"min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
Loading

0 comments on commit 7973f5a

Please sign in to comment.