-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! [wip] Add tests using AWS' SAM CLI
- Loading branch information
1 parent
2534389
commit cb22ffe
Showing
14 changed files
with
76 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
Feature: Handled exceptions in AWS Lambda | ||
|
||
@not-python-3.5 | ||
@not-python-3.6 | ||
@not-python-3.7 | ||
@not-python-3.8 | ||
@not-python-3.10 | ||
@not-python-3.11 | ||
@not-python-3.12 | ||
# 3.9 is currently the minimum python version with a lambda runtime | ||
@not-python-3.5 @not-python-3.6 @not-python-3.7 @not-python-3.8 | ||
Scenario: Handled exceptions are delivered in an AWS Lambda app | ||
Given I build the "HelloWorldFunction" lambda in "features/fixtures/aws-lambda" | ||
And I invoke the "HelloWorldFunction" lambda in "features/fixtures/aws-lambda" with the "events/event.json" event | ||
Then the lambda response "body.message" equals "Did not crash!" | ||
And the lambda response "statusCode" equals 200 | ||
And the SAM exit code equals 0 | ||
When I wait to receive an error | ||
Then the error is valid for the error reporting API version "4.0" for the "Python Bugsnag Notifier" notifier | ||
And the event "unhandled" is false | ||
And the event "severity" equals "warning" | ||
And the event "severityReason.type" equals "handledException" | ||
And the exception "errorClass" equals "Exception" | ||
And the exception "message" equals "hello there" | ||
And the exception "type" equals "python" | ||
And the "file" of stack frame 0 equals "app.py" | ||
And the event "metaData.AWS Lambda Context.function_name" equals "HelloWorldFunction" | ||
And the event "metaData.AWS Lambda Context.aws_request_id" is not null | ||
And the event "metaData.AWS Lambda Event.path" equals "/hello" | ||
And the event "metaData.AWS Lambda Event.httpMethod" equals "GET" | ||
When I wait to receive a session | ||
Then the session is valid for the session reporting API version "4.0" for the "Python Bugsnag Notifier" notifier | ||
And the session payload has a valid sessions array | ||
And the sessionCount "sessionsStarted" equals 1 | ||
Given I run the "HelloWorldFunction" lambda | ||
When I wait to receive an error | ||
Then the error is valid for the error reporting API version "4.0" for the "Python Bugsnag Notifier" notifier | ||
And the event "unhandled" is false | ||
And the event "severity" equals "warning" | ||
And the event "severityReason.type" equals "handledException" | ||
And the exception "errorClass" equals "Exception" | ||
And the exception "message" equals "hello there" | ||
And the exception "type" equals "python" | ||
And the "file" of stack frame 0 equals "handled.py" | ||
And the event "metaData.AWS Lambda Context.function_name" equals "HelloWorldFunction" | ||
And the event "metaData.AWS Lambda Context.aws_request_id" is not null | ||
And the event "metaData.AWS Lambda Event.path" equals "/hello" | ||
And the event "metaData.AWS Lambda Event.httpMethod" equals "GET" | ||
When I wait to receive a session | ||
Then the session is valid for the session reporting API version "4.0" for the "Python Bugsnag Notifier" notifier | ||
And the session payload has a valid sessions array | ||
And the sessionCount "sessionsStarted" equals 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ARG PYTHON_TEST_VERSION | ||
FROM python:$PYTHON_TEST_VERSION | ||
|
||
# install the SAM CLI | ||
ENV SAM_CLI_TELEMETRY=0 | ||
RUN pip install --upgrade pip && pip install aws-sam-cli | ||
|
||
COPY temp-bugsnag-python/ /usr/src/bugsnag | ||
|
||
WORKDIR /usr/src/app |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/src/bugsnag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
Given("I build the {string} lambda in {string}") do |name, path| | ||
command = "sam build #{name}" | ||
# PYTHON_TEST_VERSION is defined in env.rb | ||
PARAMETER_OVERRIDES = "--parameter-overrides ParameterKey=Runtime,ParameterValue=python#{PYTHON_TEST_VERSION}" | ||
|
||
_, exit_code = Maze::Runner.run_command("cd #{path} && #{command}") | ||
Given("I build the {string} lambda") do |lambda_name| | ||
step(%Q{I run the service "aws-lambda" with the command "sam build #{lambda_name} #{PARAMETER_OVERRIDES}"}) | ||
end | ||
|
||
Given("I invoke the {string} lambda") do |lambda_name| | ||
command = [ | ||
"sam local invoke #{lambda_name}", | ||
"--container-host host.docker.internal", | ||
"--docker-volume-basedir $PWD/features/fixtures/aws-lambda/app/.aws-sam/build", | ||
PARAMETER_OVERRIDES, | ||
] | ||
|
||
step(%Q{I run the service "aws-lambda" with the command "#{command.join(" ")}"}) | ||
end | ||
|
||
raise "Unable to build #{name}" unless exit_code.zero? | ||
Given("I run the {string} lambda") do |lambda_name| | ||
steps(" | ||
Given I build the '#{lambda_name}' lambda | ||
And I invoke the '#{lambda_name}' lambda | ||
") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters