bugsnag-maze-runner 7.26.1 → 7.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73f329df5934008d114f663a224e93592bc7d785024e20d0b015771abc1ca027
4
- data.tar.gz: c566d0a2aaccaf1bfe36107290ffd8519d777a7c9e5dbe77769a1674dd751e6e
3
+ metadata.gz: 4a074f231fdb2489046d9e6ad85f601239d3375edbbffe7de28ad862bc66a881
4
+ data.tar.gz: afe8771d431a5988986ad0ae5982f24c866436eb10edc95afb81af5fb5d2b0a7
5
5
  SHA512:
6
- metadata.gz: e8fadbe837d32d0f8804c168eadf175aa6b0e1a3448d3072243ff25f8b0c64933a1b00edacf24c22de9bf4aa607e328cfa0351d94010c1a688ca612d347c9411
7
- data.tar.gz: e7eb8c09b447af8b4b473a28b80b023a70dcf31100ea1d9fb0677f9c52a4322156f289eb102751be282cbdac47b451a7ba63490595fd98fe30bad3c8fa6e5170
6
+ metadata.gz: 1091d4188d165f6d1122a5a2a0275eda1ed818a550bf953c9a826f84950691ca86674bda0e11a007260a45742665c3d52630c614f1705daf88dc6ff86dec0b82
7
+ data.tar.gz: 59ec8f4f08c75411e9766c4379b841f39d1a7f3dc9f02988231fc99c229fb7affe226145f86499860a3b005cf2be9261fc0f6a8eea6151ead2515ef7c27b3e96
data/bin/maze-runner CHANGED
@@ -58,6 +58,7 @@ require_relative '../lib/maze/assertions/request_set_assertions'
58
58
 
59
59
  require_relative '../lib/maze/schemas/trace_schema'
60
60
  require_relative '../lib/maze/schemas/trace_validator'
61
+ require_relative '../lib/maze/schemas/validator'
61
62
 
62
63
  require_relative '../lib/maze/store'
63
64
  require_relative '../lib/maze/timers'
@@ -31,60 +31,6 @@ def assert_received_requests(request_count, list, list_name, precise = true)
31
31
  else
32
32
  Maze.check.operator(request_count, :<=, list.size_remaining, "#{list.size_remaining} #{list_name} received")
33
33
  end
34
-
35
- verify_schema_matches(list, list_name)
36
- validate_payload_elements(list, list_name)
37
- end
38
-
39
- def verify_schema_matches(list, list_name)
40
- request_schema_results = list.all.map { |request| request[:schema_errors] }
41
- passed = true
42
- request_schema_results.each.with_index(1) do |schema_errors, index|
43
- next if schema_errors.nil?
44
- if schema_errors.size > 0
45
- passed = false
46
- $stdout.puts "\n"
47
- $stdout.puts "\e[31m--- #{list_name} #{index} failed validation with errors at the following locations:\e[0m"
48
- schema_errors.each do |error|
49
- $stdout.puts "\e[31m#{error["data_pointer"]} failed to match #{error["schema_pointer"]}\e[0m"
50
- end
51
- $stdout.puts "\n"
52
- end
53
- end
54
-
55
- unless passed
56
- raise Test::Unit::AssertionFailedError.new 'The received payloads did not match the endpoint schema. A full list of the errors can be found above'
57
- end
58
- end
59
-
60
- def validate_payload_elements(list, list_name)
61
- validator_class = case list_name
62
- when 'trace', 'traces'
63
- Maze::Schemas::TraceValidator
64
- else
65
- nil
66
- end
67
-
68
- if validator_class
69
- validators = list.all.map do |request|
70
- validator = validator_class.new(request[:body])
71
- validator.validate
72
- validator
73
- end
74
-
75
- return if validators.all? { |validator| validator.success }
76
- validators.each.with_index(1) do |validator, index|
77
- unless validator.success
78
- $stdout.puts "\n"
79
- $stdout.puts "\e[31m--- #{list_name} #{index} failed validation with the following errors:\e[0m"
80
- validator.errors.each do |error|
81
- $stdout.puts "\e[31m#{error}\e[0m"
82
- end
83
- $stdout.puts "\n"
84
- end
85
- end
86
- raise Test::Unit::AssertionFailedError.new("One or more #{list_name} payloads failed validation. A full list of the errors can be found above")
87
- end
88
34
  end
89
35
 
90
36
  #
@@ -255,6 +255,9 @@ def assert_received_spans(span_count, list)
255
255
  end
256
256
 
257
257
  Maze.check.operator(span_count, :<=, received_count, "#{received_count} spans received")
258
+
259
+ Maze::Schemas::Validator.verify_against_schema(list, 'trace')
260
+ Maze::Schemas::Validator.validate_payload_elements(list, 'trace')
258
261
  end
259
262
 
260
263
  def get_attribute_value(field, attribute, attr_type)
@@ -44,12 +44,6 @@ BeforeAll do
44
44
  Maze.run_uuid = SecureRandom.uuid
45
45
  $logger.info "UUID for this run: #{Maze.run_uuid}"
46
46
 
47
- # Determine public IP if enabled
48
- if Maze.config.aws_public_ip
49
- Maze.public_address = Maze::AwsPublicIp.new.address
50
- $logger.info "Public address: #{Maze.public_address}"
51
- end
52
-
53
47
  # Start mock server
54
48
  Maze::Server.start
55
49
  Maze::Server.set_response_delay_generator(Maze::Generator.new [Maze::Server::DEFAULT_RESPONSE_DELAY].cycle)
@@ -66,6 +60,18 @@ BeforeAll do
66
60
  # This must happen after any client hooks have run, so that they can set the server root
67
61
  Maze::DocumentServer.start unless Maze.config.document_server_root.nil?
68
62
 
63
+ # Determine public IP if enabled
64
+ if Maze.config.aws_public_ip
65
+ public_ip = Maze::AwsPublicIp.new
66
+ Maze.public_address = public_ip.address
67
+ $logger.info "Public address: #{Maze.public_address}"
68
+
69
+ unless Maze.config.document_server_root.nil?
70
+ Maze.public_document_server_address = public_ip.document_server_address
71
+ $logger.info "Public document server address: #{Maze.public_document_server_address}"
72
+ end
73
+ end
74
+
69
75
  # An initial setup for total success status
70
76
  $success = true
71
77
  end
@@ -186,6 +192,15 @@ After do |scenario|
186
192
  end
187
193
  end
188
194
 
195
+ # Test all requests against schemas or extra validation rules. These will only run if the schema/validation is
196
+ # specified for the specific endpoint
197
+ After do |scenario|
198
+ ['error', 'session', 'build', 'trace'].each do |endpoint|
199
+ Maze::Schemas::Validator.verify_against_schema(Maze::Server.list_for(endpoint), endpoint)
200
+ Maze::Schemas::Validator.validate_payload_elements(Maze::Server.list_for(endpoint), endpoint)
201
+ end
202
+ end
203
+
189
204
  # After all tests
190
205
  AfterAll do
191
206
 
@@ -1,16 +1,31 @@
1
1
  module Maze
2
2
  # Determines the public IP address and port when running on Buildkite with the Elastic CI Stack for AWS
3
3
  class AwsPublicIp
4
- attr_reader :address
4
+ attr_reader :host
5
+ attr_reader :port
6
+ attr_reader :document_server_port
7
+
8
+ def address
9
+ "#{@ip}:#{@port}"
10
+ end
11
+
12
+ def document_server_address
13
+ return nil if @document_server_port.nil?
14
+
15
+ "#{@ip}:#{@document_server_port}"
16
+ end
5
17
 
6
18
  def initialize
7
19
  # This class is only relevant on Buildkite
8
20
  return unless ENV['BUILDKITE']
9
21
 
10
- ip = determine_public_ip
11
- port = determine_public_port
22
+ @ip = determine_public_ip
23
+ @port = determine_public_port Maze.config.port
24
+
25
+ unless Maze.config.document_server_root.nil?
26
+ @document_server_port = determine_public_port Maze.config.document_server_port
27
+ end
12
28
 
13
- @address = "#{ip}:#{port}"
14
29
  end
15
30
 
16
31
  # Determines the public IP address of the running AWS instance
@@ -20,8 +35,9 @@ module Maze
20
35
  `curl --silent -XGET http://169.254.169.254/latest/meta-data/public-ipv4`
21
36
  end
22
37
 
23
- # Determines the external port of the running Docker container that's associated with the port of the mock server
24
- def determine_public_port
38
+ # Determines the external port of the running Docker container that's associated with the port given
39
+ # @param local_port Local port to find the external port for
40
+ def determine_public_port(local_port)
25
41
  port = 0
26
42
  count = 0
27
43
  max_attempts = 30
@@ -35,7 +51,7 @@ module Maze
35
51
  begin
36
52
  json_string = result[0][0].strip
37
53
  json_result = JSON.parse(json_string)
38
- port = json_result['NetworkSettings']['Ports']["#{Maze.config.port}/tcp"][0]['HostPort']
54
+ port = json_result['NetworkSettings']['Ports']["#{local_port}/tcp"][0]['HostPort']
39
55
  rescue StandardError
40
56
  $logger.error "Unable to parse public port from: #{json_string}"
41
57
  return 0
@@ -6,7 +6,7 @@ module Maze
6
6
  config = Maze.config
7
7
  config.app = Maze::Client::BitBarClientUtils.upload_app config.access_key,
8
8
  config.app
9
- if Maze.config.start_tunnel
9
+ if Maze::Client::BitBarClientUtils.use_local_tunnel?
10
10
  Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
11
11
  config.username,
12
12
  config.access_key
@@ -61,7 +61,7 @@ module Maze
61
61
 
62
62
  def stop_session
63
63
  super
64
- if Maze.config.start_tunnel
64
+ if Maze::Client::BitBarClientUtils.use_local_tunnel?
65
65
  Maze::Client::BitBarClientUtils.stop_local_tunnel
66
66
  end
67
67
  end
@@ -123,6 +123,10 @@ module Maze
123
123
  end
124
124
  end
125
125
 
126
+ def use_local_tunnel?
127
+ Maze.config.start_tunnel && !Maze.config.aws_public_ip
128
+ end
129
+
126
130
  # Starts the BitBar local tunnel
127
131
  #
128
132
  # @param sb_local [String] path to the SBSecureTunnel binary
@@ -19,34 +19,6 @@ chrome_107:
19
19
  version: '107'
20
20
  resolution: '1920x1080'
21
21
 
22
- chrome_106:
23
- platform: 'Windows'
24
- osVersion: '11'
25
- browserName: 'chrome'
26
- version: '106'
27
- resolution: '1920x1080'
28
-
29
- chrome_105:
30
- platform: 'Windows'
31
- osVersion: '11'
32
- browserName: 'chrome'
33
- version: '105'
34
- resolution: '1920x1080'
35
-
36
- chrome_104:
37
- platform: 'Windows'
38
- osVersion: '11'
39
- browserName: 'chrome'
40
- version: '104'
41
- resolution: '1920x1080'
42
-
43
- chrome_103:
44
- platform: 'Windows'
45
- osVersion: '11'
46
- browserName: 'chrome'
47
- version: '103'
48
- resolution: '1920x1080'
49
-
50
22
  chrome_72:
51
23
  platform: 'Windows'
52
24
  osVersion: '10'
@@ -131,48 +103,6 @@ edge_latest:
131
103
  version: 'latest'
132
104
  resolution: '1920x1080'
133
105
 
134
- edge_106:
135
- platform: 'Windows'
136
- osVersion: '11'
137
- browserName: 'MicrosoftEdge'
138
- version: '106'
139
- resolution: '1920x1080'
140
-
141
- edge_105:
142
- platform: 'Windows'
143
- osVersion: '11'
144
- browserName: 'MicrosoftEdge'
145
- version: '105'
146
- resolution: '1920x1080'
147
-
148
- edge_104:
149
- platform: 'Windows'
150
- osVersion: '11'
151
- browserName: 'MicrosoftEdge'
152
- version: '104'
153
- resolution: '1920x1080'
154
-
155
- edge_103:
156
- platform: 'Windows'
157
- osVersion: '11'
158
- browserName: 'MicrosoftEdge'
159
- version: '103'
160
- resolution: '1920x1080'
161
-
162
- edge_102:
163
- platform: 'Windows'
164
- osVersion: '11'
165
- browserName: 'MicrosoftEdge'
166
- version: '102'
167
- resolution: '1920x1080'
168
-
169
- edge_101:
170
- platform: 'Windows'
171
- osVersion: '11'
172
- browserName: 'MicrosoftEdge'
173
- version: '101'
174
- resolution: '1920x1080'
175
-
176
106
  safari_16:
177
107
  platform: 'macOS'
178
108
  osVersion: '13'
@@ -4,11 +4,6 @@ module Maze
4
4
  class BitBarClient < BaseClient
5
5
  def start_session
6
6
  config = Maze.config
7
- if ENV['BUILDKITE']
8
- credentials = Maze::Client::BitBarClientUtils.account_credentials config.tms_uri
9
- config.username = credentials[:username]
10
- config.access_key = credentials[:access_key]
11
- end
12
7
  capabilities = ::Selenium::WebDriver::Remote::Capabilities.new
13
8
  capabilities['bitbar_apiKey'] = config.access_key
14
9
  browsers = YAML.safe_load(File.read("#{__dir__}/bb_browsers.yml"))
@@ -16,13 +11,17 @@ module Maze
16
11
  capabilities.merge! JSON.parse(config.capabilities_option)
17
12
  config.capabilities = capabilities
18
13
 
19
- Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
20
- config.username,
21
- config.access_key
14
+ if Maze::Client::BitBarClientUtils.use_local_tunnel?
15
+ credentials = Maze::Client::BitBarClientUtils.account_credentials config.tms_uri
16
+ config.username = credentials[:username]
17
+ config.access_key = credentials[:access_key]
18
+
19
+ Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
20
+ config.username,
21
+ config.access_key
22
+ end
22
23
 
23
- # TODO This probably needs to be settable via an environment variable
24
- # selenium_url = 'https://us-west-desktop-hub.bitbar.com/wd/hub'
25
- selenium_url = 'https://eu-desktop-hub.bitbar.com/wd/hub'
24
+ selenium_url = Maze.config.selenium_server_url
26
25
  Maze.driver = Maze::Driver::Browser.new :remote, selenium_url, config.capabilities
27
26
  Maze.driver.start_driver
28
27
  end
@@ -38,8 +37,10 @@ module Maze
38
37
 
39
38
  def stop_session
40
39
  super
41
- Maze::Client::BitBarClientUtils.stop_local_tunnel
42
- Maze::Client::BitBarClientUtils.release_account(Maze.config.tms_uri) if ENV['BUILDKITE']
40
+ if Maze::Client::BitBarClientUtils.use_local_tunnel?
41
+ Maze::Client::BitBarClientUtils.stop_local_tunnel
42
+ Maze::Client::BitBarClientUtils.release_account(Maze.config.tms_uri) if ENV['BUILDKITE']
43
+ end
43
44
  end
44
45
  end
45
46
  end
@@ -132,6 +132,12 @@ module Maze
132
132
  # Access token for the test-management service
133
133
  attr_accessor :tms_token
134
134
 
135
+ # URL of the Appium server
136
+ attr_accessor :appium_server_url
137
+
138
+ # URL of the Selenium server
139
+ attr_accessor :selenium_server_url
140
+
135
141
  # Whether the legacy (JSON-WP) Appium driver should be used
136
142
  def legacy_driver?
137
143
  @legacy_driver
@@ -157,9 +163,6 @@ module Maze
157
163
  # Device id for running on local iOS devices
158
164
  attr_accessor :device_id
159
165
 
160
- # URL of the Appium server
161
- attr_accessor :appium_server_url
162
-
163
166
  # Whether an appium server should be started
164
167
  attr_accessor :start_appium
165
168
 
@@ -118,6 +118,15 @@ module Maze
118
118
  opt Option::TUNNEL,
119
119
  'Start the device farm secure tunnel',
120
120
  default: true
121
+ opt Option::APPIUM_SERVER,
122
+ "Appium server URL. Defaults are: \n" +
123
+ " --farm=local - MAZE_APPIUM_SERVER or http://localhost:4723/wd/hub\n" +
124
+ " --farm=bb - MAZE_APPIUM_SERVER or https://us-west-mobile-hub.bitbar.com/wd/hub\n" +
125
+ 'Not used for --farm=bs',
126
+ type: :string
127
+ opt Option::SELENIUM_SERVER,
128
+ "Selenium server URL. Only used for --farm=bb, defaulting to MAZE_SELENIUM_SERVER or https://us-west-desktop-hub.bitbar.com/wd/hub",
129
+ type: :string
121
130
 
122
131
  # SmartBear-only options
123
132
  opt Option::SB_LOCAL,
@@ -147,9 +156,6 @@ module Maze
147
156
  opt Option::OS_VERSION,
148
157
  'The intended OS version when running on a local device',
149
158
  type: :string
150
- opt Option::APPIUM_SERVER,
151
- 'Appium server URL, only used for --farm=local. MAZE_APPIUM_SERVER env var or "http://localhost:4723/wd/hub" by default',
152
- type: :string
153
159
  opt Option::START_APPIUM,
154
160
  'Whether a local Appium server should be start. Only used for --farm=local.',
155
161
  default: true
@@ -222,6 +228,8 @@ module Maze
222
228
  options[Option::USERNAME] ||= ENV['BITBAR_USERNAME']
223
229
  options[Option::ACCESS_KEY] ||= ENV['BITBAR_ACCESS_KEY']
224
230
  options[Option::TMS_URI] ||= ENV['MAZE_TMS_URI']
231
+ options[Option::APPIUM_SERVER] ||= ENV['MAZE_APPIUM_SERVER'] || 'https://us-west-mobile-hub.bitbar.com/wd/hub'
232
+ options[Option::SELENIUM_SERVER] ||= ENV['MAZE_SELENIUM_SERVER'] || 'https://us-west-desktop-hub.bitbar.com/wd/hub'
225
233
  end
226
234
 
227
235
  options[Option::REPEATER_API_KEY] ||= ENV['MAZE_REPEATER_API_KEY']
@@ -97,7 +97,8 @@ module Maze
97
97
  config.os = options[Maze::Option::OS]
98
98
  config.os_version = options[Maze::Option::OS_VERSION]
99
99
  config.sb_local = Maze::Helper.expand_path(options[Maze::Option::SB_LOCAL])
100
- config.appium_server_url = 'https://us-west-mobile-hub.bitbar.com/wd/hub'
100
+ config.appium_server_url = options[Maze::Option::APPIUM_SERVER]
101
+ config.selenium_server_url = options[Maze::Option::SELENIUM_SERVER]
101
102
  config.app_bundle_id = options[Maze::Option::APP_BUNDLE_ID]
102
103
  when :local then
103
104
  if options[Maze::Option::BROWSER]
data/lib/maze/option.rb CHANGED
@@ -30,6 +30,8 @@ module Maze
30
30
  OS_VERSION = 'os-version'
31
31
  TUNNEL = 'tunnel'
32
32
  USERNAME = 'username'
33
+ APPIUM_SERVER = 'appium-server'
34
+ SELENIUM_SERVER = 'selenium-server'
33
35
 
34
36
  # BitBar options
35
37
  SB_LOCAL = 'sb-local'
@@ -43,7 +45,6 @@ module Maze
43
45
 
44
46
  # Local-only options
45
47
  APPIUM_LOGFILE = 'appium-logfile'
46
- APPIUM_SERVER = 'appium-server'
47
48
  APPLE_TEAM_ID = 'apple-team-id'
48
49
  START_APPIUM = 'start-appium'
49
50
  UDID = 'udid'
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Maze
4
+ module Schemas
5
+
6
+ # A general entry point for running validation with schemas and other validation methods
7
+ class Validator
8
+
9
+ class << self
10
+
11
+ # Tests that payloads for a specific path have passed any schema checks implemented on receipt
12
+ # Throws an AssertionFailedError with a list of issues on failure
13
+ #
14
+ # @param list [Array] An array of received requests
15
+ # @param list_name [String] The name of the payload list for received requests
16
+ def verify_against_schema(list, list_name)
17
+ request_schema_results = list.all.map { |request| request[:schema_errors] }
18
+ passed = true
19
+ request_schema_results.each.with_index(1) do |schema_errors, index|
20
+ next if schema_errors.nil?
21
+ if schema_errors.size > 0
22
+ passed = false
23
+ $stdout.puts "\n"
24
+ $stdout.puts "\e[31m--- #{list_name} #{index} failed validation:\e[0m"
25
+ schema_errors.each do |error|
26
+ $stdout.puts "\e[31m#{JSONSchemer::Errors.pretty(error)}\e[0m"
27
+ end
28
+ $stdout.puts "\n"
29
+ end
30
+ end
31
+
32
+ unless passed
33
+ raise Test::Unit::AssertionFailedError.new 'The received payloads did not match the endpoint schema. A full list of the errors can be found above'
34
+ end
35
+ end
36
+
37
+ # Tests that payloads for a specific path pass any additional validation checks
38
+ # Throws an AssertionFailedError with a list of issues on failure
39
+ #
40
+ # @param list [Array] An array of received requests
41
+ # @param list_name [String] The name of the payload list for received requests
42
+ def validate_payload_elements(list, list_name)
43
+ validator_class = case list_name
44
+ when 'trace', 'traces'
45
+ Maze::Schemas::TraceValidator
46
+ else
47
+ nil
48
+ end
49
+
50
+ if validator_class
51
+ validators = list.all.map do |request|
52
+ validator = validator_class.new(request[:body])
53
+ validator.validate
54
+ validator
55
+ end
56
+
57
+ return if validators.all? { |validator| validator.success }
58
+ validators.each.with_index(1) do |validator, index|
59
+ unless validator.success
60
+ $stdout.puts "\n"
61
+ $stdout.puts "\e[31m--- #{list_name} #{index} failed validation with the following errors:\e[0m"
62
+ validator.errors.each do |error|
63
+ $stdout.puts "\e[31m#{error}\e[0m"
64
+ end
65
+ $stdout.puts "\n"
66
+ end
67
+ end
68
+ raise Test::Unit::AssertionFailedError.new("One or more #{list_name} payloads failed validation. A full list of the errors can be found above")
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
data/lib/maze.rb CHANGED
@@ -7,10 +7,11 @@ 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.26.1'
10
+ VERSION = '7.28.0'
11
11
 
12
12
  class << self
13
- attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address, :run_uuid
13
+ attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address,
14
+ :public_document_server_address, :run_uuid
14
15
 
15
16
  def config
16
17
  @config ||= Maze::Configuration.new
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.26.1
4
+ version: 7.28.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-04-20 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -427,6 +427,7 @@ files:
427
427
  - lib/maze/schemas/OtelTraceSchema.json
428
428
  - lib/maze/schemas/trace_schema.rb
429
429
  - lib/maze/schemas/trace_validator.rb
430
+ - lib/maze/schemas/validator.rb
430
431
  - lib/maze/server.rb
431
432
  - lib/maze/servlets/base_servlet.rb
432
433
  - lib/maze/servlets/command_servlet.rb