Skip to content

Commit

Permalink
Rewrite nethttp features to new steps
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaKunoichi committed Aug 20, 2024
1 parent ea2077b commit 6ae8183
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 145 deletions.
31 changes: 15 additions & 16 deletions features/net-http/appversion.feature
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
Feature: Configuring app version

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "APP_VERSION" to "3.1.2"
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "BUGSNAG_APP_VERSION" to "3.1.2"

Scenario: A error report contains the configured app type when using a net http app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/handled"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I wait to receive an error
And I should receive no sessions
And the error is valid for the error reporting API version "4" for the "Bugsnag Go" notifier
And the event "app.version" equals "3.1.2"

Scenario: A session report contains the configured app type when using a net http app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "true"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "true"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/session"
Then I wait to receive a request after the start up session
And the request is a valid session report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the payload field "app.version" equals "3.1.2"

And I wait to receive a session
And the session is valid for the session reporting API version "1.0" for the "Bugsnag Go" notifier
And the session payload field "sessions.0.app.version" equals "3.1.2"
24 changes: 0 additions & 24 deletions features/net-http/autocapturesessions.feature

This file was deleted.

27 changes: 11 additions & 16 deletions features/net-http/autonotify.feature
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
Feature: Using auto notify

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"

Scenario: An error report is sent when an AutoNotified crash occurs which later gets recovered
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/autonotify-then-recover"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
Then I wait to receive an error
And the event "unhandled" is true
And the exception "errorClass" equals "*runtime.TypeAssertionError"
And the exception "message" matches "interface conversion: interface ({} )?is struct {}, not string"

Scenario: An error report is sent when a go routine crashes which is reported through auto notify
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/autonotify"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
Then I wait to receive an error
And the event "unhandled" is true
And the exception "errorClass" equals "*errors.errorString"
And the exception "message" equals "Go routine killed with auto notify"
And the exception "message" equals "Go routine killed with auto notify"
42 changes: 19 additions & 23 deletions features/net-http/handled.feature
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
Feature: Handled errors

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to "/app/src/features/fixtures/app/"

Scenario: A handled error sends a report
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/handled"
Then I wait to receive a request
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the event "unhandled" is false for request 0
And the event "severity" equals "warning" for request 0
And the event "severityReason.type" equals "handledError" for request 0
And the exception is a PathError for request 0
And the "file" of stack frame 0 equals "main.go" for request 0
Then I wait to receive an error
And the event "unhandled" is false
And the event "severity" equals "warning"
And the event "severityReason.type" equals "handledError"
And the exception "errorClass" equals "*os.PathError"
And the "file" of stack frame 0 equals "nethttp_scenario.go"

Scenario: A handled error sends a report with a custom name
Given I set environment variable "ERROR_CLASS" to "MyCustomErrorClass"
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/handled"
Then I wait to receive a request
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the event "unhandled" is false for request 0
And the event "severity" equals "warning" for request 0
And the event "severityReason.type" equals "handledError" for request 0
And the exception "errorClass" equals "MyCustomErrorClass" for request 0
And the "file" of stack frame 0 equals "main.go" for request 0
Then I wait to receive an error
And the event "unhandled" is false
And the event "severity" equals "warning"
And the event "severityReason.type" equals "handledError"
And the exception "errorClass" equals "MyCustomErrorClass"
And the "file" of stack frame 0 equals "nethttp_scenario.go"
20 changes: 7 additions & 13 deletions features/net-http/onbeforenotify.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
Feature: Configuring on before notify

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"

Scenario: Send three bugsnags and use on before notify to drop one and modify the message of another
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/onbeforenotify"
Then I wait to receive 2 requests
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the exception "message" equals "Don't ignore this error" for request 0
And the request 1 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the exception "message" equals "Error message was changed" for request 1
Then I wait to receive 2 errors
And the exception "message" equals "Don't ignore this error"
And I discard the oldest error
And the exception "message" equals "Error message was changed"
18 changes: 6 additions & 12 deletions features/net-http/recover.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
Feature: Using recover

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"

Scenario: An error report is sent when request crashes but is recovered
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/recover"
Then I wait to receive a request
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the exception "errorClass" equals "*errors.errorString" for request 0
And the exception "message" equals "Request killed but recovered" for request 0
Then I wait to receive an error
And the exception "errorClass" equals "*errors.errorString"
And the exception "message" equals "Request killed but recovered"
30 changes: 14 additions & 16 deletions features/net-http/releasestage.feature
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
Feature: Configuring release stage

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "RELEASE_STAGE" to "my-stage"
Given I set environment variable "BUGSNAG_RELEASE_STAGE" to "my-stage"

Scenario: An error report is sent with configured release stage
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/handled"
Then I wait to receive a request
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the event "app.releaseStage" equals "my-stage" for request 0
Then I wait to receive an error
And the event "app.releaseStage" equals "my-stage"

Scenario: A session report contains the configured app type
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "true"
When I start the service "nethttp"
And I wait for the app to open port "4512"
Given I set environment variable "BUGSNAG_AUTO_CAPTURE_SESSIONS" to "true"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/session"
Then I wait to receive a request after the start up session
And the request is a valid session report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the payload field "app.releaseStage" equals "my-stage"
Then I wait to receive a session
And I wait to receive an error
And the session payload field "sessions.0.app.releaseStage" equals "my-stage"
16 changes: 5 additions & 11 deletions features/net-http/request.feature
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
Feature: Capturing request information automatically

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"

Scenario: An error report will automatically contain request information
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/handled"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
Then I wait to receive an error
And the event "request.clientIp" is not null
And the event "request.headers.User-Agent" equals "Ruby"
And the event "request.httpMethod" equals "GET"
And the event "request.url" ends with "/handled"
And the event "request.url" starts with "http://"
And the event "request.url" starts with "http://"
19 changes: 5 additions & 14 deletions features/net-http/user.feature
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
Feature: Sending user data

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"

Scenario: An error report contains custom user data
Given I set environment variable "USER_ID" to "test-user-id"
And I set environment variable "USER_NAME" to "test-user-name"
And I set environment variable "USER_EMAIL" to "test-user-email"
When I start the service "nethttp"
And I wait for the app to open port "4512"
When I start the service "app"
And I run "HttpServerScenario"
And I wait for the host "localhost" to open port "4512"
And I wait for 2 seconds
And I open the URL "http://localhost:4512/user"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
Then I wait to receive an error
And the event "user.id" equals "test-user-id"
And the event "user.name" equals "test-user-name"
And the event "user.email" equals "test-user-email"
And the event "user.email" equals "test-user-email"

0 comments on commit 6ae8183

Please sign in to comment.