Class: CI::Queue::Configuration
- Inherits:
-
Object
- Object
- CI::Queue::Configuration
- Defined in:
- lib/ci/queue/configuration.rb
Instance Attribute Summary collapse
- #build_id ⇒ Object
-
#circuit_breakers ⇒ Object
readonly
Returns the value of attribute circuit_breakers.
-
#failing_test ⇒ Object
Returns the value of attribute failing_test.
-
#failure_file ⇒ Object
Returns the value of attribute failure_file.
-
#grind_count ⇒ Object
Returns the value of attribute grind_count.
-
#max_requeues ⇒ Object
Returns the value of attribute max_requeues.
-
#max_test_duration ⇒ Object
Returns the value of attribute max_test_duration.
-
#max_test_duration_percentile ⇒ Object
Returns the value of attribute max_test_duration_percentile.
-
#max_test_failed ⇒ Object
Returns the value of attribute max_test_failed.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
- #queue_init_timeout ⇒ Object
-
#requeue_tolerance ⇒ Object
Returns the value of attribute requeue_tolerance.
- #seed ⇒ Object
-
#statsd_endpoint ⇒ Object
Returns the value of attribute statsd_endpoint.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#track_test_duration ⇒ Object
Returns the value of attribute track_test_duration.
-
#worker_id ⇒ Object
Returns the value of attribute worker_id.
Class Method Summary collapse
Instance Method Summary collapse
- #flaky?(test) ⇒ Boolean
- #global_max_requeues(tests_count) ⇒ Object
-
#initialize(timeout: 30, build_id: nil, worker_id: nil, max_requeues: 0, requeue_tolerance: 0, namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil, grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil, max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil, queue_init_timeout: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #max_consecutive_failures=(max) ⇒ Object
- #max_duration=(duration) ⇒ Object
Constructor Details
#initialize(timeout: 30, build_id: nil, worker_id: nil, max_requeues: 0, requeue_tolerance: 0, namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil, grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil, max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil, queue_init_timeout: nil) ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ci/queue/configuration.rb', line 32 def initialize( timeout: 30, build_id: nil, worker_id: nil, max_requeues: 0, requeue_tolerance: 0, namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil, grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil, max_test_duration_percentile: 0.5, track_test_duration: false, max_test_failed: nil, queue_init_timeout: nil ) @build_id = build_id @circuit_breakers = [CircuitBreaker::Disabled] @failure_file = failure_file @flaky_tests = flaky_tests @grind_count = grind_count @max_requeues = max_requeues @max_test_duration = max_test_duration @max_test_duration_percentile = max_test_duration_percentile @max_test_failed = max_test_failed @namespace = namespace @requeue_tolerance = requeue_tolerance @seed = seed @statsd_endpoint = statsd_endpoint @timeout = timeout @queue_init_timeout = queue_init_timeout @track_test_duration = track_test_duration @worker_id = worker_id self.max_consecutive_failures = max_consecutive_failures self.max_duration = max_duration end |
Instance Attribute Details
#build_id ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/ci/queue/configuration.rb', line 84 def build_id if namespace "#{namespace}:#{@build_id}" else @build_id end end |
#circuit_breakers ⇒ Object (readonly)
Returns the value of attribute circuit_breakers.
9 10 11 |
# File 'lib/ci/queue/configuration.rb', line 9 def circuit_breakers @circuit_breakers end |
#failing_test ⇒ Object
Returns the value of attribute failing_test.
6 7 8 |
# File 'lib/ci/queue/configuration.rb', line 6 def failing_test @failing_test end |
#failure_file ⇒ Object
Returns the value of attribute failure_file.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def failure_file @failure_file end |
#grind_count ⇒ Object
Returns the value of attribute grind_count.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def grind_count @grind_count end |
#max_requeues ⇒ Object
Returns the value of attribute max_requeues.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def max_requeues @max_requeues end |
#max_test_duration ⇒ Object
Returns the value of attribute max_test_duration.
7 8 9 |
# File 'lib/ci/queue/configuration.rb', line 7 def max_test_duration @max_test_duration end |
#max_test_duration_percentile ⇒ Object
Returns the value of attribute max_test_duration_percentile.
7 8 9 |
# File 'lib/ci/queue/configuration.rb', line 7 def max_test_duration_percentile @max_test_duration_percentile end |
#max_test_failed ⇒ Object
Returns the value of attribute max_test_failed.
8 9 10 |
# File 'lib/ci/queue/configuration.rb', line 8 def max_test_failed @max_test_failed end |
#namespace ⇒ Object
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/ci/queue/configuration.rb', line 6 def namespace @namespace end |
#queue_init_timeout ⇒ Object
60 61 62 |
# File 'lib/ci/queue/configuration.rb', line 60 def queue_init_timeout @queue_init_timeout || timeout end |
#requeue_tolerance ⇒ Object
Returns the value of attribute requeue_tolerance.
6 7 8 |
# File 'lib/ci/queue/configuration.rb', line 6 def requeue_tolerance @requeue_tolerance end |
#seed ⇒ Object
80 81 82 |
# File 'lib/ci/queue/configuration.rb', line 80 def seed @seed || build_id end |
#statsd_endpoint ⇒ Object
Returns the value of attribute statsd_endpoint.
6 7 8 |
# File 'lib/ci/queue/configuration.rb', line 6 def statsd_endpoint @statsd_endpoint end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def timeout @timeout end |
#track_test_duration ⇒ Object
Returns the value of attribute track_test_duration.
7 8 9 |
# File 'lib/ci/queue/configuration.rb', line 7 def track_test_duration @track_test_duration end |
#worker_id ⇒ Object
Returns the value of attribute worker_id.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def worker_id @worker_id end |
Class Method Details
.from_env(env) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ci/queue/configuration.rb', line 14 def from_env(env) new( build_id: env['CIRCLE_BUILD_URL'] || env['BUILDKITE_BUILD_ID'] || env['TRAVIS_BUILD_ID'] || env['HEROKU_TEST_RUN_ID'] || env['SEMAPHORE_PIPELINE_ID'], worker_id: env['CIRCLE_NODE_INDEX'] || env['BUILDKITE_PARALLEL_JOB'] || env['CI_NODE_INDEX'] || env['SEMAPHORE_JOB_ID'], seed: env['CIRCLE_SHA1'] || env['BUILDKITE_COMMIT'] || env['TRAVIS_COMMIT'] || env['HEROKU_TEST_RUN_COMMIT_VERSION'] || env['SEMAPHORE_GIT_SHA'], flaky_tests: load_flaky_tests(env['CI_QUEUE_FLAKY_TESTS']), statsd_endpoint: env['CI_QUEUE_STATSD_ADDR'], ) end |
.load_flaky_tests(path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ci/queue/configuration.rb', line 24 def load_flaky_tests(path) return [] unless path ::File.readlines(path).map(&:chomp).to_set rescue SystemCallError [] end |
Instance Method Details
#flaky?(test) ⇒ Boolean
76 77 78 |
# File 'lib/ci/queue/configuration.rb', line 76 def flaky?(test) @flaky_tests.include?(test.id) end |
#global_max_requeues(tests_count) ⇒ Object
92 93 94 |
# File 'lib/ci/queue/configuration.rb', line 92 def global_max_requeues(tests_count) (tests_count * Float(requeue_tolerance)).ceil end |
#max_consecutive_failures=(max) ⇒ Object
64 65 66 67 68 |
# File 'lib/ci/queue/configuration.rb', line 64 def max_consecutive_failures=(max) if max @circuit_breakers << CircuitBreaker::MaxConsecutiveFailures.new(max_consecutive_failures: max) end end |
#max_duration=(duration) ⇒ Object
70 71 72 73 74 |
# File 'lib/ci/queue/configuration.rb', line 70 def max_duration=(duration) if duration @circuit_breakers << CircuitBreaker::Timeout.new(duration: duration) end end |