Skip to content

Commit

Permalink
Rewrite features steps to newer version, add command pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaKunoichi committed Aug 9, 2024
1 parent 245bce0 commit 11cbd89
Show file tree
Hide file tree
Showing 34 changed files with 777 additions and 723 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
maze_output
vendor

features/fixtures/testbuild
features/fixtures/testbuild

# ignore the gemfile to prevent testing against stale versions
Gemfile.lock
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', branch: 'v1'
gem "bugsnag-maze-runner", "~> 9.9"
184 changes: 142 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,55 +1,155 @@
GIT
remote: https://github.com/bugsnag/maze-runner
revision: 7377529a77eb7585afc66cd2080fcdc4eea3306a
branch: v1
specs:
bugsnag-maze-runner (1.1.0)
cucumber (~> 3.1.0)
cucumber-expressions (= 5.0.15)
minitest (~> 5.0)
os (~> 1.0.0)
rack (~> 2.0.0)
rake (~> 12.3.3)
test-unit (~> 3.2.0)

GEM
remote: https://rubygems.org/
specs:
backports (3.21.0)
builder (3.2.4)
cucumber (3.1.0)
builder (>= 2.1.2)
cucumber-core (~> 3.1.0)
cucumber-expressions (~> 5.0.4)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 5.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (3.1.0)
backports (>= 3.8.0)
cucumber-tag_expressions (~> 1.1.0)
gherkin (>= 5.0.0)
cucumber-expressions (5.0.15)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
diff-lcs (1.4.4)
gherkin (5.1.0)
minitest (5.14.4)
multi_json (1.15.0)
appium_lib (12.0.1)
appium_lib_core (~> 5.0)
nokogiri (~> 1.8, >= 1.8.1)
tomlrb (>= 1.1, < 3.0)
appium_lib_core (5.4.0)
faye-websocket (~> 0.11.0)
selenium-webdriver (~> 4.2, < 4.6)
bugsnag (6.27.1)
concurrent-ruby (~> 1.0)
bugsnag-maze-runner (9.12.0)
appium_lib (~> 12.0.0)
appium_lib_core (~> 5.4.0)
bugsnag (~> 6.24)
cucumber (~> 7.1)
cucumber-expressions (~> 6.0.0)
curb (~> 1.0.5)
dogstatsd-ruby (~> 5.5.0)
json_schemer (~> 0.2.24)
optimist (~> 3.0.1)
os (~> 1.0.0)
rack (~> 2.2)
rake (~> 12.3.3)
rubyzip (~> 2.3.2)
selenium-webdriver (~> 4.0)
test-unit (~> 3.5.2)
webrick (~> 1.7.0)
builder (3.3.0)
childprocess (4.1.0)
concurrent-ruby (1.3.3)
cucumber (7.1.0)
builder (~> 3.2, >= 3.2.4)
cucumber-core (~> 10.1, >= 10.1.0)
cucumber-create-meta (~> 6.0, >= 6.0.1)
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
cucumber-gherkin (~> 22.0, >= 22.0.0)
cucumber-html-formatter (~> 17.0, >= 17.0.0)
cucumber-messages (~> 17.1, >= 17.1.1)
cucumber-wire (~> 6.2, >= 6.2.0)
diff-lcs (~> 1.4, >= 1.4.4)
mime-types (~> 3.3, >= 3.3.1)
multi_test (~> 0.1, >= 0.1.2)
sys-uname (~> 1.2, >= 1.2.2)
cucumber-core (10.1.1)
cucumber-gherkin (~> 22.0, >= 22.0.0)
cucumber-messages (~> 17.1, >= 17.1.1)
cucumber-tag-expressions (~> 4.1, >= 4.1.0)
cucumber-create-meta (6.0.4)
cucumber-messages (~> 17.1, >= 17.1.1)
sys-uname (~> 1.2, >= 1.2.2)
cucumber-cucumber-expressions (14.0.0)
cucumber-expressions (6.0.1)
cucumber-gherkin (22.0.0)
cucumber-messages (~> 17.1, >= 17.1.1)
cucumber-html-formatter (17.0.0)
cucumber-messages (~> 17.1, >= 17.1.0)
cucumber-messages (17.1.1)
cucumber-tag-expressions (4.1.0)
cucumber-wire (6.2.1)
cucumber-core (~> 10.1, >= 10.1.0)
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
curb (1.0.5)
diff-lcs (1.5.1)
dogstatsd-ruby (5.5.0)
ecma-re-validator (0.4.0)
regexp_parser (~> 2.2)
eventmachine (1.2.7)
faye-websocket (0.11.3)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm-linux-musl)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86-linux-musl)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
hana (1.3.7)
json_schemer (0.2.25)
ecma-re-validator (~> 0.3)
hana (~> 1.3)
regexp_parser (~> 2.0)
simpleidn (~> 0.2)
uri_template (~> 0.7)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0806)
multi_test (0.1.2)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
optimist (3.0.1)
os (1.0.1)
power_assert (2.0.0)
rack (2.0.9.3)
power_assert (2.0.3)
racc (1.8.1)
rack (2.2.9)
rake (12.3.3)
test-unit (3.2.9)
regexp_parser (2.9.2)
rexml (3.3.4)
strscan
rubyzip (2.3.2)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simpleidn (0.2.3)
strscan (3.1.0)
sys-uname (1.3.0)
ffi (~> 1.1)
test-unit (3.5.9)
power_assert
tomlrb (2.0.3)
uri_template (0.7.0)
webrick (1.7.0)
websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
ruby
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
bugsnag-maze-runner!
bugsnag-maze-runner (~> 9.9)

BUNDLED WITH
2.1.4
2.5.17
20 changes: 8 additions & 12 deletions features/apptype.feature
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
Feature: Configuring app type

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I set environment variable "APP_TYPE" to "background-queue"
And I have built the service "app"
Given I set environment variable "APP_TYPE" to "background-queue"

Scenario: An error report contains the configured app type when running a go app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I run the go service "app" with the test case "handled"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
When I start the service "app"
And I run HandledScenario
And I wait to receive an error
And the event "app.type" equals "background-queue"

Scenario: An session report contains the configured app type when running a go app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "true"
When I run the go service "app" with the test case "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.type" equals "background-queue"

When I start the service "app"
And I run SendSessionScenario
And I wait to receive a session
And the session payload field "app.type" equals "background-queue"
19 changes: 8 additions & 11 deletions features/appversion.feature
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
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 have built the service "app"

Scenario: An error report contains the configured app type when running a go app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
When I run the go service "app" with the test case "handled"
Then I wait to receive a request
And the request is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
When I start the service "app"
And I run HandledScenario
And I wait to receive an error
And the event "app.version" equals "3.1.2"

Scenario: An session report contains the configured app type when running a go app
Scenario: A session report contains the configured app type when running a go app
Given I set environment variable "AUTO_CAPTURE_SESSIONS" to "true"
When I run the go service "app" with the test case "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"
When I start the service "app"
And I run SendSessionScenario
And I wait to receive a session
And the session payload field "app.version" equals "3.1.2"
15 changes: 5 additions & 10 deletions features/autonotify.feature
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
Feature: Using auto notify

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
And I configure the bugsnag endpoint
And I have built the service "app"

Scenario: An error report is sent when an AutoNotified crash occurs which later gets recovered
When I run the go service "app" with the test case "autonotify"
Then I wait for 3 seconds
And the request 1 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
And the exception "errorClass" equals "*errors.errorString" for request 1
And the exception "message" equals "Go routine killed with auto notify" for request 1
When I start the service "app"
And I run AutonotifyPanicScenario
And I wait to receive an error
And the exception "errorClass" equals "Error"
And the exception "message" equals "Go routine killed with auto notify"
16 changes: 0 additions & 16 deletions features/endpoint.feature

This file was deleted.

14 changes: 6 additions & 8 deletions features/fixtures/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ RUN apk update && apk upgrade && apk add git bash

ENV GOPATH /app

COPY testbuild /app/src/github.com/bugsnag/bugsnag-go
WORKDIR /app/src/github.com/bugsnag/bugsnag-go/v2
COPY features /app/src/features
COPY v2 /app/src/v2
WORKDIR /app/src/v2

# Ensure subsequent steps are re-run if the GO_VERSION variable changes
ARG GO_VERSION
Expand All @@ -20,15 +21,12 @@ RUN if [[ $(echo -e "1.11\n$GO_VERSION\n1.16" | sort -V | head -2 | tail -1) ==
go install ./...; \
fi

# Copy test scenarios
COPY ./app /app/src/test
WORKDIR /app/src/test
WORKDIR /app/src/features/fixtures/app

# Create app module - avoid locking bugsnag dep by not checking it in
# Skip on old versions of Go which pre-date modules
RUN if [[ $GO_VERSION != '1.11' && $GO_VERSION != '1.12' ]]; then \
go mod init && go mod tidy; \
echo "replace github.com/bugsnag/bugsnag-go/v2 => /app/src/v2" >> go.mod; \
go mod tidy; \
fi

RUN chmod +x run.sh
CMD ["/app/src/test/run.sh"]
42 changes: 42 additions & 0 deletions features/fixtures/app/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"encoding/json"
"fmt"
"net/http"
"time"
)

const DEFAULT_MAZE_ADDRESS = "http://localhost:9339"

type Command struct {
Action string `json:"action,omitempty"`
ScenarioName string `json:"scenario_name,omitempty"`
APIKey string `json:"api_key,omitempty"`
NotifyEndpoint string `json:"notify_endpoint,omitempty"`
SessionsEndpoint string `json:"sessions_endpoint,omitempty"`
UUID string `json:"uuid,omitempty"`
RunUUID string `json:"run_uuid,omitempty"`
}

func GetCommand(mazeAddress string) Command {
var command Command
mazeURL := fmt.Sprintf("%+v/command", mazeAddress)
client := http.Client{Timeout: 2 * time.Second}
res, err := client.Get(mazeURL)
if err != nil {
fmt.Printf("[Bugsnag] Error while receiving command: %+v\n", err)
return command
}

if res != nil {
err = json.NewDecoder(res.Body).Decode(&command)
res.Body.Close()
if err != nil {
fmt.Printf("[Bugsnag] Error while decoding command: %+v\n", err)
return command
}
}

return command
}
Loading

0 comments on commit 11cbd89

Please sign in to comment.