Skip to content

Commit f25b889

Browse files
committed
Setup Maze Runner
This includes two basic tests — one for an unhandled error and one for a handled error
1 parent 0de2634 commit f25b889

File tree

13 files changed

+260
-1
lines changed

13 files changed

+260
-1
lines changed

.github/workflows/license-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333
docker run -v $PWD:/scan licensefinder/license_finder /bin/bash -lc "
3434
cd /scan &&
3535
pip3 install -r requirements.txt --quiet &&
36-
license_finder --decisions-file decisions.yml --python-version 3
36+
license_finder --decisions-file decisions.yml --python-version 3 --enabled-package-managers=pip
3737
"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
maze-runner.log
2+
maze_output
3+
14
*.py[co]
25

36
# Packages

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem 'bugsnag-maze-runner', '~> 9.6'

Gemfile.lock

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
appium_lib (12.0.1)
5+
appium_lib_core (~> 5.0)
6+
nokogiri (~> 1.8, >= 1.8.1)
7+
tomlrb (>= 1.1, < 3.0)
8+
appium_lib_core (5.4.0)
9+
faye-websocket (~> 0.11.0)
10+
selenium-webdriver (~> 4.2, < 4.6)
11+
bugsnag (6.26.4)
12+
concurrent-ruby (~> 1.0)
13+
bugsnag-maze-runner (9.6.0)
14+
appium_lib (~> 12.0.0)
15+
appium_lib_core (~> 5.4.0)
16+
bugsnag (~> 6.24)
17+
cucumber (~> 7.1)
18+
cucumber-expressions (~> 6.0.0)
19+
curb (~> 0.9.6)
20+
dogstatsd-ruby (~> 5.5.0)
21+
json_schemer (~> 0.2.24)
22+
optimist (~> 3.0.1)
23+
os (~> 1.0.0)
24+
rack (~> 2.2)
25+
rake (~> 12.3.3)
26+
rubyzip (~> 2.3.2)
27+
selenium-webdriver (~> 4.0)
28+
test-unit (~> 3.5.2)
29+
webrick (~> 1.7.0)
30+
builder (3.2.4)
31+
childprocess (4.1.0)
32+
concurrent-ruby (1.2.3)
33+
cucumber (7.1.0)
34+
builder (~> 3.2, >= 3.2.4)
35+
cucumber-core (~> 10.1, >= 10.1.0)
36+
cucumber-create-meta (~> 6.0, >= 6.0.1)
37+
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
38+
cucumber-gherkin (~> 22.0, >= 22.0.0)
39+
cucumber-html-formatter (~> 17.0, >= 17.0.0)
40+
cucumber-messages (~> 17.1, >= 17.1.1)
41+
cucumber-wire (~> 6.2, >= 6.2.0)
42+
diff-lcs (~> 1.4, >= 1.4.4)
43+
mime-types (~> 3.3, >= 3.3.1)
44+
multi_test (~> 0.1, >= 0.1.2)
45+
sys-uname (~> 1.2, >= 1.2.2)
46+
cucumber-core (10.1.1)
47+
cucumber-gherkin (~> 22.0, >= 22.0.0)
48+
cucumber-messages (~> 17.1, >= 17.1.1)
49+
cucumber-tag-expressions (~> 4.1, >= 4.1.0)
50+
cucumber-create-meta (6.0.4)
51+
cucumber-messages (~> 17.1, >= 17.1.1)
52+
sys-uname (~> 1.2, >= 1.2.2)
53+
cucumber-cucumber-expressions (14.0.0)
54+
cucumber-expressions (6.0.1)
55+
cucumber-gherkin (22.0.0)
56+
cucumber-messages (~> 17.1, >= 17.1.1)
57+
cucumber-html-formatter (17.0.0)
58+
cucumber-messages (~> 17.1, >= 17.1.0)
59+
cucumber-messages (17.1.1)
60+
cucumber-tag-expressions (4.1.0)
61+
cucumber-wire (6.2.1)
62+
cucumber-core (~> 10.1, >= 10.1.0)
63+
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
64+
curb (0.9.11)
65+
diff-lcs (1.5.1)
66+
dogstatsd-ruby (5.5.0)
67+
ecma-re-validator (0.4.0)
68+
regexp_parser (~> 2.2)
69+
eventmachine (1.2.7)
70+
faye-websocket (0.11.3)
71+
eventmachine (>= 0.12.0)
72+
websocket-driver (>= 0.5.1)
73+
ffi (1.16.3)
74+
hana (1.3.7)
75+
json_schemer (0.2.25)
76+
ecma-re-validator (~> 0.3)
77+
hana (~> 1.3)
78+
regexp_parser (~> 2.0)
79+
simpleidn (~> 0.2)
80+
uri_template (~> 0.7)
81+
mime-types (3.5.2)
82+
mime-types-data (~> 3.2015)
83+
mime-types-data (3.2024.0305)
84+
multi_test (0.1.2)
85+
nokogiri (1.16.3-aarch64-linux)
86+
racc (~> 1.4)
87+
nokogiri (1.16.3-arm-linux)
88+
racc (~> 1.4)
89+
nokogiri (1.16.3-arm64-darwin)
90+
racc (~> 1.4)
91+
nokogiri (1.16.3-x86-linux)
92+
racc (~> 1.4)
93+
nokogiri (1.16.3-x86_64-darwin)
94+
racc (~> 1.4)
95+
nokogiri (1.16.3-x86_64-linux)
96+
racc (~> 1.4)
97+
optimist (3.0.1)
98+
os (1.0.1)
99+
power_assert (2.0.3)
100+
racc (1.7.3)
101+
rack (2.2.9)
102+
rake (12.3.3)
103+
regexp_parser (2.9.0)
104+
rexml (3.2.6)
105+
rubyzip (2.3.2)
106+
selenium-webdriver (4.5.0)
107+
childprocess (>= 0.5, < 5.0)
108+
rexml (~> 3.2, >= 3.2.5)
109+
rubyzip (>= 1.2.2, < 3.0)
110+
websocket (~> 1.0)
111+
simpleidn (0.2.1)
112+
unf (~> 0.1.4)
113+
sys-uname (1.2.3)
114+
ffi (~> 1.1)
115+
test-unit (3.5.9)
116+
power_assert
117+
tomlrb (2.0.3)
118+
unf (0.1.4)
119+
unf_ext
120+
unf_ext (0.0.9.1)
121+
uri_template (0.7.0)
122+
webrick (1.7.0)
123+
websocket (1.2.10)
124+
websocket-driver (0.7.6)
125+
websocket-extensions (>= 0.1.0)
126+
websocket-extensions (0.1.5)
127+
128+
PLATFORMS
129+
aarch64-linux
130+
arm-linux
131+
arm64-darwin
132+
x86-linux
133+
x86_64-darwin
134+
x86_64-linux
135+
136+
DEPENDENCIES
137+
bugsnag-maze-runner (~> 9.6)
138+
139+
BUNDLED WITH
140+
2.5.1

features/fixtures/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
temp-bugsnag-python/

features/fixtures/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "3.8"
2+
3+
services:
4+
plain:
5+
build:
6+
context: plain
7+
args:
8+
- PYTHON_TEST_VERSION
9+
environment:
10+
- BUGSNAG_API_KEY
11+
- BUGSNAG_ERROR_ENDPOINT
12+
- BUGSNAG_SESSION_ENDPOINT
13+
extra_hosts:
14+
- "host.docker.internal:host-gateway"

features/fixtures/plain/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ARG PYTHON_TEST_VERSION
2+
FROM python:$PYTHON_TEST_VERSION
3+
4+
COPY app/ /usr/src/app
5+
COPY temp-bugsnag-python/ /usr/src/bugsnag
6+
7+
WORKDIR /usr/src/app
8+
9+
RUN pip install --no-cache-dir -r requirements.txt
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
import bugsnag
3+
4+
bugsnag.configure(
5+
api_key=os.environ["BUGSNAG_API_KEY"],
6+
endpoint=os.environ["BUGSNAG_ERROR_ENDPOINT"],
7+
session_endpoint=os.environ["BUGSNAG_SESSION_ENDPOINT"],
8+
)
9+
10+
bugsnag.notify(RuntimeError("uh oh :o"))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../bugsnag
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
import bugsnag
3+
4+
bugsnag.configure(
5+
api_key=os.environ["BUGSNAG_API_KEY"],
6+
endpoint=os.environ["BUGSNAG_ERROR_ENDPOINT"],
7+
session_endpoint=os.environ["BUGSNAG_SESSION_ENDPOINT"],
8+
)
9+
10+
raise Exception("OH NO!")

features/plain/handled.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Handled exceptions
2+
3+
Scenario: Handled exceptions are delivered
4+
Given I run the service "plain" with the command "python handled.py"
5+
And I wait to receive an error
6+
Then the error is valid for the error reporting API version "4.0" for the "Python Bugsnag Notifier" notifier
7+
And the exception "errorClass" equals "RuntimeError"
8+
And the exception "message" equals "uh oh :o"
9+
And the event "unhandled" is false
10+
And the event "severity" equals "warning"
11+
And the event "severityReason.type" equals "handledException"

features/plain/unhandled.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: Unhandled exceptions
2+
3+
Scenario: Unhandled exceptions are delivered
4+
Given I run the service "plain" with the command "python unhandled.py"
5+
And I wait to receive an error
6+
Then the error is valid for the error reporting API version "4.0" for the "Python Bugsnag Notifier" notifier
7+
And the exception "errorClass" equals "Exception"
8+
And the exception "message" equals "OH NO!"
9+
And the event "unhandled" is true
10+
And the event "severity" equals "error"
11+
And the event "severityReason.type" equals "unhandledException"

features/support/env.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require "fileutils"
2+
3+
Maze.hooks.before_all do
4+
# log to console, not the filesystem
5+
Maze.config.file_log = false
6+
Maze.config.log_requests = true
7+
8+
# don't wait so long for requests/not to receive requests
9+
Maze.config.receive_requests_wait = 10
10+
Maze.config.receive_no_requests_wait = 10
11+
12+
# warn if a test takes more than 5 seconds to send a request
13+
Maze.config.receive_requests_slow_threshold = 5
14+
15+
# bugsnag-python doesn't need to send the integrity header
16+
Maze.config.enforce_bugsnag_integrity = false
17+
18+
# install bugsnag into each fixture
19+
Dir.each_child("features/fixtures") do |path|
20+
fixture_directory = "#{Dir.pwd}/features/fixtures/#{path}"
21+
22+
next unless File.directory?(fixture_directory)
23+
24+
destination = "#{fixture_directory}/temp-bugsnag-python"
25+
26+
FileUtils.mkdir(destination) unless File.exist?(destination)
27+
28+
FileUtils.cp_r(
29+
["bugsnag", "setup.py"],
30+
destination,
31+
remove_destination: true # delete destination before copying
32+
)
33+
34+
at_exit do
35+
FileUtils.rm_rf(destination)
36+
end
37+
end
38+
end
39+
40+
Maze.hooks.before do
41+
host = "host.docker.internal"
42+
43+
Maze::Runner.environment["BUGSNAG_API_KEY"] = $api_key
44+
Maze::Runner.environment["BUGSNAG_ERROR_ENDPOINT"] = "http://#{host}:#{Maze.config.port}/notify"
45+
Maze::Runner.environment["BUGSNAG_SESSION_ENDPOINT"] = "http://#{host}:#{Maze.config.port}/sessions"
46+
end

0 commit comments

Comments
 (0)