Class: DistribCore::Leader::ErrorHandler
- Inherits:
-
Object
- Object
- DistribCore::Leader::ErrorHandler
- Defined in:
- lib/distrib_core/leader/error_handler.rb
Overview
Default strategy to manage retries of tests.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#failed_workers_count ⇒ Object
readonly
Returns the value of attribute failed_workers_count.
-
#failed_workers_threshold ⇒ Object
Returns the value of attribute failed_workers_threshold.
-
#fatal_worker_failures ⇒ Object
Returns the value of attribute fatal_worker_failures.
-
#retry_attempts ⇒ Object
Returns the value of attribute retry_attempts.
-
#retryable_exceptions ⇒ Object
Returns the value of attribute retryable_exceptions.
Instance Method Summary collapse
- #ignore_worker_failure?(exception) ⇒ Boolean
-
#initialize(exception_extractor) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
-
#retry_test?(test, results, exception) ⇒ Boolean
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity.
Constructor Details
#initialize(exception_extractor) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/distrib_core/leader/error_handler.rb', line 8 def initialize(exception_extractor) @retryable_exceptions = [] @retry_attempts = 0 @retries_per_test = Hash.new(0) @fatal_worker_failures = [] @failed_workers_threshold = 0 @failed_workers_count = 0 @exception_extractor = exception_extractor end |
Instance Attribute Details
#failed_workers_count ⇒ Object
Returns the value of attribute failed_workers_count.
6 7 8 |
# File 'lib/distrib_core/leader/error_handler.rb', line 6 def failed_workers_count @failed_workers_count end |
#failed_workers_threshold ⇒ Object
Returns the value of attribute failed_workers_threshold.
5 6 7 |
# File 'lib/distrib_core/leader/error_handler.rb', line 5 def failed_workers_threshold @failed_workers_threshold end |
#fatal_worker_failures ⇒ Object
Returns the value of attribute fatal_worker_failures.
5 6 7 |
# File 'lib/distrib_core/leader/error_handler.rb', line 5 def fatal_worker_failures @fatal_worker_failures end |
#retry_attempts ⇒ Object
Returns the value of attribute retry_attempts.
5 6 7 |
# File 'lib/distrib_core/leader/error_handler.rb', line 5 def retry_attempts @retry_attempts end |
#retryable_exceptions ⇒ Object
Returns the value of attribute retryable_exceptions.
5 6 7 |
# File 'lib/distrib_core/leader/error_handler.rb', line 5 def retryable_exceptions @retryable_exceptions end |
Instance Method Details
#ignore_worker_failure?(exception) ⇒ Boolean
46 47 48 49 50 51 52 |
# File 'lib/distrib_core/leader/error_handler.rb', line 46 def ignore_worker_failure?(exception) self.failed_workers_count += 1 return false if missing_exception?(exception) || exceeded_failures_threshold? || fatal_failure?(exception) true end |
#retry_test?(test, results, exception) ⇒ Boolean
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/distrib_core/leader/error_handler.rb', line 20 def retry_test?(test, results, exception) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity return false if retries_per_test[test] >= retry_attempts exceptions = exception_extractor.failures_of(results) exceptions.push(exception) if exception failures_causes = exception_extractor.unpack_causes(exceptions) return false if failures_causes.empty? if retryable_exceptions.empty? retries_per_test[test] += 1 return true end retried = failures_causes.all? do |causes| causes.any? do |cause| retryable_exceptions.include?(cause.original_class) end end retries_per_test[test] += 1 if retried retried end |