bugsnag-maze-runner 7.24.0 → 7.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/maze-runner +1 -0
- data/lib/features/steps/network_steps.rb +28 -19
- data/lib/features/steps/trace_steps.rb +20 -3
- data/lib/features/support/internal_hooks.rb +3 -0
- data/lib/maze/metrics_processor.rb +71 -0
- data/lib/maze/request_list.rb +1 -1
- data/lib/maze/server.rb +10 -0
- data/lib/maze.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2740400fc6ee5bd904dc3a82f334967f6a154eb5bd99a343f324ef68da800461
|
4
|
+
data.tar.gz: '0787ae4e578768564cf8e377b4e3626afd8b8b637a26c9077401f2093e81747b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc58669b1cc0d59f7b1a3762e34ac489f174e997a2fa313dd50f7b18c6f863bdab8550090019a007f96c23e908cb9a2d9417f7142afb45cc8f9f52e79cd755d8
|
7
|
+
data.tar.gz: 0c8d117361004c964f759459e2f3433701277633b518bb7afca0a831bdc40cc86a3127eec04fbfcfab4136d05e700ab1231084dee0316508b25330cfa5f9c111
|
data/bin/maze-runner
CHANGED
@@ -38,6 +38,7 @@ require_relative '../lib/maze/http_request'
|
|
38
38
|
require_relative '../lib/maze/logger'
|
39
39
|
require_relative '../lib/maze/macos_utils'
|
40
40
|
require_relative '../lib/maze/maze_output'
|
41
|
+
require_relative '../lib/maze/metrics_processor'
|
41
42
|
require_relative '../lib/maze/network'
|
42
43
|
require_relative '../lib/maze/proxy'
|
43
44
|
require_relative '../lib/maze/retry_handler'
|
@@ -8,29 +8,17 @@ When('I wait for the host {string} to open port {string}') do |host, port|
|
|
8
8
|
Maze::Network.wait_for_port(host, port)
|
9
9
|
end
|
10
10
|
|
11
|
-
# Sets the HTTP status code to be used for
|
12
|
-
#
|
13
|
-
# @step_input status_code [Integer] The status code to return
|
14
|
-
When('I set the HTTP status code to {int}') do |status_code|
|
15
|
-
Maze::Server.set_status_code_generator(Maze::Generator.new [status_code].cycle)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Sets the HTTP status code to be used for the next request
|
19
|
-
#
|
20
|
-
# @step_input status_code [Integer] The status code to return
|
21
|
-
When('I set the HTTP status code for the next request to {int}') do |status_code|
|
22
|
-
Maze::Server.set_status_code_generator(create_defaulting_generator([status_code], Maze::Server::DEFAULT_STATUS_CODE))
|
23
|
-
end
|
24
|
-
|
25
|
-
# Sets the HTTP status code to be used for the next set of requests
|
11
|
+
# Sets the HTTP status code to be used for the next set of requests for a given connection type
|
26
12
|
#
|
13
|
+
# @step_input http_verb [String] The type of request this code will be used for
|
27
14
|
# @step_input status_codes [String] A comma separated list of status codes to return
|
28
|
-
When('I set the HTTP status code for the next requests to {string}') do |status_codes|
|
15
|
+
When('I set the HTTP status code for the next {string} requests to {string}') do |http_verb, status_codes|
|
16
|
+
raise("Invalid HTTP verb: #{http_verb}") unless Maze::Server::ALLOWED_HTTP_VERBS.include?(http_verb)
|
29
17
|
codes = status_codes.split(',').map(&:strip)
|
30
|
-
Maze::Server.set_status_code_generator(create_defaulting_generator(codes, Maze::Server::DEFAULT_STATUS_CODE))
|
18
|
+
Maze::Server.set_status_code_generator(create_defaulting_generator(codes, Maze::Server::DEFAULT_STATUS_CODE), http_verb)
|
31
19
|
end
|
32
20
|
|
33
|
-
#
|
21
|
+
# Sets the HTTP status code to be used for all subsequent requests for a given connection type
|
34
22
|
#
|
35
23
|
# @step_input http_verb [String] The type of request this code will be used for
|
36
24
|
# @step_input status_code [Integer] The status code to return
|
@@ -39,7 +27,7 @@ When('I set the HTTP status code for {string} requests to {int}') do |http_verb,
|
|
39
27
|
Maze::Server.set_status_code_generator(Maze::Generator.new([status_code].cycle), http_verb)
|
40
28
|
end
|
41
29
|
|
42
|
-
#
|
30
|
+
# Sets the HTTP status code to be used for the next request for a given connection type
|
43
31
|
#
|
44
32
|
# @step_input http_verb [String] The type of request this code will be used for
|
45
33
|
# @step_input status_code [Integer] The status code to return
|
@@ -48,6 +36,27 @@ When('I set the HTTP status code for the next {string} request to {int}') do |ht
|
|
48
36
|
Maze::Server.set_status_code_generator(create_defaulting_generator([status_code], Maze::Server::DEFAULT_STATUS_CODE), http_verb)
|
49
37
|
end
|
50
38
|
|
39
|
+
# Sets the HTTP status code to be used for all subsequent POST requests
|
40
|
+
#
|
41
|
+
# @step_input status_code [Integer] The status code to return
|
42
|
+
When('I set the HTTP status code to {int}') do |status_code|
|
43
|
+
step %{I set the HTTP status code for "POST" requests to #{status_code}}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Sets the HTTP status code to be used for the next POST request
|
47
|
+
#
|
48
|
+
# @step_input status_code [Integer] The status code to return
|
49
|
+
When('I set the HTTP status code for the next request to {int}') do |status_code|
|
50
|
+
step %{I set the HTTP status code for the next "POST" request to #{status_code}}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Sets the HTTP status code to be used for the next set of POST requests
|
54
|
+
#
|
55
|
+
# @step_input status_codes [String] A comma separated list of status codes to return
|
56
|
+
When('I set the HTTP status code for the next requests to {string}') do |status_codes|
|
57
|
+
step %{I set the HTTP status code for the next "POST" requests to "#{status_codes}"}
|
58
|
+
end
|
59
|
+
|
51
60
|
# Sets the sampling probability to be used for all subsequent trace responses
|
52
61
|
#
|
53
62
|
# @step_input sampling_probability [String] The sampling probability to return
|
@@ -132,14 +132,15 @@ end
|
|
132
132
|
|
133
133
|
Then('a span string attribute {string} exists') do |attribute|
|
134
134
|
spans = spans_from_request_list(Maze::Server.list_for('traces'))
|
135
|
-
selected_attributes = spans.map { |span| span['attributes'].find { |a| a['key']
|
135
|
+
selected_attributes = spans.map { |span| span['attributes'].find { |a| a['key'].eql?(attribute) && a['value'].has_key?('stringValue') } }.compact
|
136
136
|
Maze.check.false(selected_attributes.empty?)
|
137
137
|
end
|
138
138
|
|
139
139
|
Then('a span string attribute {string} equals {string}') do |attribute, expected|
|
140
140
|
spans = spans_from_request_list(Maze::Server.list_for('traces'))
|
141
|
-
selected_attributes = spans.map { |span| span['attributes'].find { |a| a['key']
|
142
|
-
|
141
|
+
selected_attributes = spans.map { |span| span['attributes'].find { |a| a['key'].eql?(attribute) && a['value'].has_key?('stringValue') } }.compact
|
142
|
+
attribute_values = selected_attributes.map { |a| a['value']['stringValue'] }
|
143
|
+
Maze.check.includes attribute_values, expected
|
143
144
|
end
|
144
145
|
|
145
146
|
Then('a span field {string} equals {string}') do |key, expected|
|
@@ -186,6 +187,22 @@ Then('a span named {string} contains the attributes:') do |span_name, table|
|
|
186
187
|
end
|
187
188
|
end
|
188
189
|
|
190
|
+
Then('a span named {string} has a parent named {string}') do |child_name, parent_name|
|
191
|
+
spans = spans_from_request_list(Maze::Server.list_for('traces'))
|
192
|
+
child_spans = spans.find_all { |span| span['name'].eql?(child_name) }
|
193
|
+
raise Test::Unit::AssertionFailedError.new "No spans were found with the name #{child_name}" if child_spans.empty?
|
194
|
+
parent_spans = spans.find_all { |span| span['name'].eql?(parent_name) }
|
195
|
+
raise Test::Unit::AssertionFailedError.new "No spans were found with the name #{parent_name}" if parent_spans.empty?
|
196
|
+
|
197
|
+
expected_parent_ids = child_spans.map { |span| span['parentSpanId'] }
|
198
|
+
parent_ids = parent_spans.map { |span| span['spanId'] }
|
199
|
+
match = expected_parent_ids.any? { |expected_id| parent_ids.include?(expected_id) }
|
200
|
+
|
201
|
+
unless match
|
202
|
+
raise Test::Unit::AssertionFailedError.new "No child span named #{child_name} was found with a parent named #{parent_name}"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
189
206
|
def spans_from_request_list list
|
190
207
|
return list.remaining
|
191
208
|
.flat_map { |req| req[:body]['resourceSpans'] }
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative './request_list'
|
2
|
+
|
3
|
+
module Maze
|
4
|
+
class MetricsProcessor
|
5
|
+
# @param metrics [RequestList] The metrics to be processed
|
6
|
+
def initialize(metrics)
|
7
|
+
@metrics = metrics
|
8
|
+
@columns = Set.new
|
9
|
+
@rows = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Collates the metrics given into a CSV-friendly structure and writes the CSV to disk
|
13
|
+
def process
|
14
|
+
return if @metrics.size_all == 0
|
15
|
+
|
16
|
+
collate
|
17
|
+
write_to_disk
|
18
|
+
end
|
19
|
+
|
20
|
+
# Organises the raw metrics into an Array of hashes representing each row of the CSV,
|
21
|
+
# whilst also capturing an overall set of column headings
|
22
|
+
def collate
|
23
|
+
@metrics.all.each do |request|
|
24
|
+
row = {}
|
25
|
+
metric = request[:body]
|
26
|
+
metric.each do |key, value|
|
27
|
+
@columns.add key
|
28
|
+
row[key] = value
|
29
|
+
end
|
30
|
+
@rows << row
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_to_disk
|
35
|
+
filepath = File.join(Dir.pwd, 'maze_output', 'metrics.csv')
|
36
|
+
|
37
|
+
puts "Call with #{filepath}"
|
38
|
+
|
39
|
+
File.open(filepath, 'w') do |file|
|
40
|
+
# Write the header, with columns ordered alphabetically
|
41
|
+
sorted_columns = @columns.to_a.sort!
|
42
|
+
header = sorted_columns.join ','
|
43
|
+
file.puts header
|
44
|
+
|
45
|
+
# Write the rows
|
46
|
+
@rows.each do |row|
|
47
|
+
row_values = sorted_columns.map do |column|
|
48
|
+
if row.has_key? column
|
49
|
+
to_csv_friendly(row[column])
|
50
|
+
else
|
51
|
+
''
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
file.puts row_values.join ','
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_csv_friendly(value)
|
61
|
+
return value unless value.class == String
|
62
|
+
|
63
|
+
if value.include?(' ') || value.include?(',')
|
64
|
+
"\"#{value}\""
|
65
|
+
else
|
66
|
+
value
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
data/lib/maze/request_list.rb
CHANGED
data/lib/maze/server.rb
CHANGED
@@ -83,6 +83,8 @@ module Maze
|
|
83
83
|
builds
|
84
84
|
when 'log', 'logs'
|
85
85
|
logs
|
86
|
+
when 'metric', 'metrics'
|
87
|
+
metrics
|
86
88
|
when 'trace', 'traces'
|
87
89
|
traces
|
88
90
|
when 'upload', 'uploads'
|
@@ -145,6 +147,13 @@ module Maze
|
|
145
147
|
@logs ||= RequestList.new
|
146
148
|
end
|
147
149
|
|
150
|
+
# A list of metric requests received
|
151
|
+
#
|
152
|
+
# @return [RequestList] Received metric requests
|
153
|
+
def metrics
|
154
|
+
@metrics ||= RequestList.new
|
155
|
+
end
|
156
|
+
|
148
157
|
# A list of commands for a test fixture to perform. Strictly speaking these are responses to HTTP
|
149
158
|
# requests, but the list behavior is all we need.
|
150
159
|
#
|
@@ -202,6 +211,7 @@ module Maze
|
|
202
211
|
server.mount '/react-native-source-map', Servlets::Servlet, :sourcemaps
|
203
212
|
server.mount '/command', Servlets::CommandServlet
|
204
213
|
server.mount '/logs', Servlets::LogServlet
|
214
|
+
server.mount '/metrics', Servlets::Servlet, :metrics
|
205
215
|
server.mount '/reflect', Servlets::ReflectiveServlet
|
206
216
|
server.start
|
207
217
|
rescue StandardError => e
|
data/lib/maze.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative 'maze/timers'
|
|
7
7
|
# Glues the various parts of MazeRunner together that need to be accessed globally,
|
8
8
|
# providing an alternative to the proliferation of global variables or singletons.
|
9
9
|
module Maze
|
10
|
-
VERSION = '7.
|
10
|
+
VERSION = '7.26.0'
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address, :run_uuid
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag-maze-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Kirkland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -408,6 +408,7 @@ files:
|
|
408
408
|
- lib/maze/logger.rb
|
409
409
|
- lib/maze/macos_utils.rb
|
410
410
|
- lib/maze/maze_output.rb
|
411
|
+
- lib/maze/metrics_processor.rb
|
411
412
|
- lib/maze/network.rb
|
412
413
|
- lib/maze/option.rb
|
413
414
|
- lib/maze/option/parser.rb
|