Class: CI::Queue::Configuration
- Inherits:
-
Object
- Object
- CI::Queue::Configuration
- Defined in:
- lib/ci/queue/configuration.rb
Instance Attribute Summary collapse
-
#build_id ⇒ Object
Returns the value of attribute build_id.
-
#circuit_breaker ⇒ Object
readonly
Returns the value of attribute circuit_breaker.
-
#failing_test ⇒ Object
Returns the value of attribute failing_test.
-
#max_requeues ⇒ Object
Returns the value of attribute max_requeues.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#requeue_tolerance ⇒ Object
Returns the value of attribute requeue_tolerance.
-
#seed ⇒ Object
Returns the value of attribute seed.
-
#statsd_endpoint ⇒ Object
Returns the value of attribute statsd_endpoint.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#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) ⇒ Configuration
constructor
A new instance of Configuration.
- #max_consecutive_failures=(max) ⇒ 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) ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ci/queue/configuration.rb', line 27 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 ) @namespace = namespace @timeout = timeout @build_id = build_id @worker_id = worker_id @max_requeues = max_requeues @requeue_tolerance = requeue_tolerance @seed = seed @flaky_tests = flaky_tests @statsd_endpoint = statsd_endpoint self.max_consecutive_failures = max_consecutive_failures end |
Instance Attribute Details
#build_id ⇒ Object
Returns the value of attribute build_id.
4 5 6 |
# File 'lib/ci/queue/configuration.rb', line 4 def build_id @build_id end |
#circuit_breaker ⇒ Object (readonly)
Returns the value of attribute circuit_breaker.
6 7 8 |
# File 'lib/ci/queue/configuration.rb', line 6 def circuit_breaker @circuit_breaker end |
#failing_test ⇒ Object
Returns the value of attribute failing_test.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def failing_test @failing_test end |
#max_requeues ⇒ Object
Returns the value of attribute max_requeues.
4 5 6 |
# File 'lib/ci/queue/configuration.rb', line 4 def max_requeues @max_requeues end |
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def namespace @namespace end |
#requeue_tolerance ⇒ Object
Returns the value of attribute requeue_tolerance.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def requeue_tolerance @requeue_tolerance end |
#seed ⇒ Object
Returns the value of attribute seed.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def seed @seed end |
#statsd_endpoint ⇒ Object
Returns the value of attribute statsd_endpoint.
5 6 7 |
# File 'lib/ci/queue/configuration.rb', line 5 def statsd_endpoint @statsd_endpoint end |
#timeout ⇒ Object
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/ci/queue/configuration.rb', line 4 def timeout @timeout end |
#worker_id ⇒ Object
Returns the value of attribute worker_id.
4 5 6 |
# File 'lib/ci/queue/configuration.rb', line 4 def worker_id @worker_id end |
Class Method Details
.from_env(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ci/queue/configuration.rb', line 9 def from_env(env) new( build_id: env['CIRCLE_BUILD_URL'] || env['BUILDKITE_BUILD_ID'] || env['TRAVIS_BUILD_ID'] || env['HEROKU_TEST_RUN_ID'], worker_id: env['CIRCLE_NODE_INDEX'] || env['BUILDKITE_PARALLEL_JOB'] || env['CI_NODE_INDEX'], seed: env['CIRCLE_SHA1'] || env['BUILDKITE_COMMIT'] || env['TRAVIS_COMMIT'] || env['HEROKU_TEST_RUN_COMMIT_VERSION'], flaky_tests: load_flaky_tests(env['CI_QUEUE_FLAKY_TESTS']), statsd_endpoint: env['CI_QUEUE_STATSD_ADDR'], ) end |
.load_flaky_tests(path) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ci/queue/configuration.rb', line 19 def load_flaky_tests(path) return [] unless path ::File.readlines(path).map(&:chomp).to_set rescue SystemCallError [] end |
Instance Method Details
#flaky?(test) ⇒ Boolean
51 52 53 |
# File 'lib/ci/queue/configuration.rb', line 51 def flaky?(test) @flaky_tests.include?(test.id) end |
#global_max_requeues(tests_count) ⇒ Object
67 68 69 |
# File 'lib/ci/queue/configuration.rb', line 67 def global_max_requeues(tests_count) (tests_count * Float(requeue_tolerance)).ceil end |
#max_consecutive_failures=(max) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ci/queue/configuration.rb', line 43 def max_consecutive_failures=(max) @circuit_breaker = if max CircuitBreaker.new(max_consecutive_failures: max) else CircuitBreaker::Disabled end end |