Skip to content

Commit

Permalink
Do not retry Appium session creation on BitBar devices
Browse files Browse the repository at this point in the history
  • Loading branch information
twometresteve committed Sep 14, 2023
1 parent 7946fb6 commit 7630c0b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# 8.5.1 - TBD
# 8.5.1 - 2023/09/14

## Fixes

- Improve grouping and presentation of BugSnagged errors [581](https://github.com/bugsnag/maze-runner/pull/581)
- Improve grouping and presentation of BugSnagged errors [583](https://github.com/bugsnag/maze-runner/pull/583)
- Do not retry Appium session creation with BitBar devices [584](https://github.com/bugsnag/maze-runner/pull/584)

# 8.5.0 - 2023/09/05

Expand Down
1 change: 1 addition & 0 deletions bin/maze-runner
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require_relative '../lib/maze'
require_relative '../lib/maze/appium_server'
require_relative '../lib/maze/api/appium/file_manager'
require_relative '../lib/maze/api/cucumber/scenario'
require_relative '../lib/maze/api/exit_code'
require_relative '../lib/maze/bugsnag_config'
require_relative '../lib/maze/client/bb_api_client'
require_relative '../lib/maze/client/bb_client_utils'
Expand Down
7 changes: 6 additions & 1 deletion docs/Test_Outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

Maze Runner has a number of outputs:
- The standard Cucumber console output
- The command line exit code
- `maze_output` directory container various files relating to each scenario
- Logging generated using `$logger` in Ruby code

## Exit Code

A list of all possible exit codes can be found in [exit_code.rb](../lib/maze/api/exit_code.rb).

## `maze_output` folder

Maze Runner will generate a folder for each scenario containing:
- A file for each request type (errors, sessions, traces, etc.) detailing all requests of that type received during the scenario.
- For Appium tests on Android or iOS, the device log (`logcat` or `syslog`). Due to the overhead of retrieving these, it will only be generated for failed scenarios.

Each scenario folder is organised into a `passed` or `failed` folder immediately beneath `maze_runner`.
Each scenario folder is organised into a `passed` or `failed` folder immediately beneath `maze_output`. A zip archive of that whole folder will also be create and moved to appear at `maze_output/maze_output.zip`.

## Logging

Expand Down
13 changes: 13 additions & 0 deletions lib/maze/api/exit_code.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Maze
module Api
class ExitCode

# Cucumber itself can use codes 0 to 2

APP_UPLOAD_FAILURE = 100
TUNNEL_FAILURE = 101
SESSION_CREATION_FAILURE = 102

end
end
end
20 changes: 12 additions & 8 deletions lib/maze/client/appium/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def maze_address
raise 'Method not implemented by this class'
end

def retry_start_driver?
raise 'Method not implemented by this class'
end

def start_driver(config)
retry_failure = config.device_list.nil? || config.device_list.empty?
retry_failure = retry_start_driver?
driver = nil
until Maze.driver
begin
Expand All @@ -64,21 +68,21 @@ def start_driver(config)
result
rescue => start_error
$logger.error "Session creation failed: #{start_error}"
raise start_error unless retry_failure
false
end
end

if retry_failure
wait = Maze::Wait.new(interval: 10, timeout: 60)
success = wait.until(&start_driver_closure)

unless success
$logger.error 'Appium driver failed to start after 6 attempts in 60 seconds'
raise RuntimeError.new('Appium driver failed to start in 60 seconds')
end
else
start_driver_closure.call
success = start_driver_closure.call
end

unless success
# TODO Bugsnag notify
$logger.error 'Failed to create Appium driver, exiting'
exit(::Maze::Api::ExitCode::SESSION_CREATION_FAILURE)
end

# Infer OS version if necessary when running locally
Expand Down
4 changes: 4 additions & 0 deletions lib/maze/client/appium/bb_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def prepare_session
end
end

def retry_start_driver?
false
end

def start_scenario
unless Maze.config.legacy_driver?
# Write Maze's address to file and push to the device
Expand Down
4 changes: 4 additions & 0 deletions lib/maze/client/appium/bs_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def prepare_session
end
end

def retry_start_driver?
Maze.config.device_list.nil? || Maze.config.device_list.empty?
end

def start_scenario
unless Maze.config.legacy_driver?
# Write Maze's address to file and push to the device
Expand Down

0 comments on commit 7630c0b

Please sign in to comment.