@@ -6,12 +6,16 @@ class Configuration
66 attr_accessor :requeue_tolerance , :namespace , :failing_test , :statsd_endpoint
77 attr_accessor :max_test_duration , :max_test_duration_percentile , :track_test_duration
88 attr_accessor :max_test_failed , :redis_ttl , :warnings_file , :debug_log , :max_missed_heartbeat_seconds
9+ attr_accessor :lazy_load , :lazy_load_stream_batch_size
10+ attr_accessor :lazy_load_streaming_timeout , :lazy_load_test_helpers
911 attr_reader :circuit_breakers
1012 attr_writer :seed , :build_id
1113 attr_writer :queue_init_timeout , :report_timeout , :inactive_workers_timeout
1214
1315 class << self
1416 def from_env ( env )
17+ lazy_load_value = env [ 'CI_QUEUE_LAZY_LOAD' ]
18+ lazy_load = lazy_load_value && !lazy_load_value . strip . empty? && !%w( 0 false ) . include? ( lazy_load_value . strip . downcase )
1519 new (
1620 build_id : env [ 'CIRCLE_BUILD_URL' ] || env [ 'BUILDKITE_BUILD_ID' ] || env [ 'TRAVIS_BUILD_ID' ] || env [ 'HEROKU_TEST_RUN_ID' ] || env [ 'SEMAPHORE_PIPELINE_ID' ] ,
1721 worker_id : env [ 'CIRCLE_NODE_INDEX' ] || env [ 'BUILDKITE_PARALLEL_JOB' ] || env [ 'CI_NODE_INDEX' ] || env [ 'SEMAPHORE_JOB_ID' ] ,
@@ -22,6 +26,10 @@ def from_env(env)
2226 debug_log : env [ 'CI_QUEUE_DEBUG_LOG' ] ,
2327 max_requeues : env [ 'CI_QUEUE_MAX_REQUEUES' ] &.to_i || 0 ,
2428 requeue_tolerance : env [ 'CI_QUEUE_REQUEUE_TOLERANCE' ] &.to_f || 0 ,
29+ lazy_load : lazy_load || false ,
30+ lazy_load_stream_batch_size : ( env [ 'CI_QUEUE_LAZY_LOAD_STREAM_BATCH_SIZE' ] || env [ 'CI_QUEUE_STREAM_BATCH_SIZE' ] ) &.to_i ,
31+ lazy_load_streaming_timeout : ( env [ 'CI_QUEUE_LAZY_LOAD_STREAM_TIMEOUT' ] || env [ 'CI_QUEUE_STREAM_TIMEOUT' ] ) &.to_i ,
32+ lazy_load_test_helpers : env [ 'CI_QUEUE_LAZY_LOAD_TEST_HELPERS' ] || env [ 'CI_QUEUE_TEST_HELPERS' ] ,
2533 )
2634 end
2735
@@ -46,7 +54,8 @@ def initialize(
4654 grind_count : nil , max_duration : nil , failure_file : nil , max_test_duration : nil ,
4755 max_test_duration_percentile : 0.5 , track_test_duration : false , max_test_failed : nil ,
4856 queue_init_timeout : nil , redis_ttl : 8 * 60 * 60 , report_timeout : nil , inactive_workers_timeout : nil ,
49- export_flaky_tests_file : nil , warnings_file : nil , debug_log : nil , max_missed_heartbeat_seconds : nil )
57+ export_flaky_tests_file : nil , warnings_file : nil , debug_log : nil , max_missed_heartbeat_seconds : nil ,
58+ lazy_load : false , lazy_load_stream_batch_size : nil , lazy_load_streaming_timeout : nil , lazy_load_test_helpers : nil )
5059 @build_id = build_id
5160 @circuit_breakers = [ CircuitBreaker ::Disabled ]
5261 @failure_file = failure_file
@@ -73,6 +82,16 @@ def initialize(
7382 @warnings_file = warnings_file
7483 @debug_log = debug_log
7584 @max_missed_heartbeat_seconds = max_missed_heartbeat_seconds
85+ @lazy_load = lazy_load
86+ @lazy_load_stream_batch_size = lazy_load_stream_batch_size || 5_000
87+ @lazy_load_streaming_timeout = lazy_load_streaming_timeout
88+ @lazy_load_test_helpers = lazy_load_test_helpers
89+ end
90+
91+ def lazy_load_test_helper_paths
92+ return [ ] unless @lazy_load_test_helpers
93+
94+ @lazy_load_test_helpers . split ( ',' ) . map ( &:strip )
7695 end
7796
7897 def queue_init_timeout
@@ -83,6 +102,43 @@ def report_timeout
83102 @report_timeout || timeout
84103 end
85104
105+ def lazy_load_streaming_timeout
106+ if @lazy_load_streaming_timeout && @lazy_load_streaming_timeout > 0
107+ @lazy_load_streaming_timeout
108+ else
109+ [ queue_init_timeout , 300 ] . max
110+ end
111+ end
112+
113+ # Backward-compatible aliases for existing callers.
114+ def stream_batch_size
115+ lazy_load_stream_batch_size
116+ end
117+
118+ def stream_batch_size = ( value )
119+ self . lazy_load_stream_batch_size = value
120+ end
121+
122+ def streaming_timeout
123+ lazy_load_streaming_timeout
124+ end
125+
126+ def streaming_timeout = ( value )
127+ self . lazy_load_streaming_timeout = value
128+ end
129+
130+ def test_helpers
131+ lazy_load_test_helpers
132+ end
133+
134+ def test_helpers = ( value )
135+ self . lazy_load_test_helpers = value
136+ end
137+
138+ def test_helper_paths
139+ lazy_load_test_helper_paths
140+ end
141+
86142 def inactive_workers_timeout
87143 @inactive_workers_timeout || timeout
88144 end
0 commit comments