Skip to content

Commit 4c71c48

Browse files
committed
Remove recovery manifest
1 parent 49a0560 commit 4c71c48

8 files changed

Lines changed: 19 additions & 151 deletions

File tree

‎ruby/README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ previously reserved by that worker:
4747
```bash
4848
minitest-queue --queue redis://example.com run \
4949
--retry-mode worker-history \
50-
--recovery-manifest tmp/ci-queue-recovery.json \
5150
-Itest test/**/*_test.rb
5251
```
5352

5453
The replay uses the existing local retry queue and exits after the worker history
55-
is exhausted. It does not claim additional work from the shared Redis queue. The
56-
manifest is written atomically only after a complete run.
54+
is exhausted. It does not claim additional work from the shared Redis queue.
5755

5856

5957
If you'd like to centralize the error reporting you can do so with:

‎ruby/lib/ci/queue/configuration.rb‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Configuration
1515
attr_accessor :timing_redis_url
1616
attr_accessor :write_duration_averages
1717
attr_accessor :heartbeat_grace_period, :heartbeat_interval
18-
attr_accessor :retry_mode, :recovery_manifest, :retry_count
18+
attr_accessor :retry_mode
1919
attr_reader :circuit_breakers
2020
attr_writer :seed, :build_id
2121
attr_writer :queue_init_timeout, :report_timeout, :inactive_workers_timeout
@@ -31,7 +31,6 @@ def from_env(env)
3131
redis_ttl: env['CI_QUEUE_REDIS_TTL']&.to_i || 8 * 60 * 60,
3232
known_flaky_tests: load_known_flaky_tests(env['CI_QUEUE_KNOWN_FLAKY_TESTS']),
3333
branch: env['BUILDKITE_BRANCH'],
34-
retry_count: env['BUILDKITE_RETRY_COUNT'].to_i,
3534
)
3635
end
3736

@@ -69,9 +68,7 @@ def initialize(
6968
timing_redis_url: nil,
7069
heartbeat_grace_period: 30,
7170
heartbeat_interval: 10,
72-
retry_mode: :failures,
73-
recovery_manifest: nil,
74-
retry_count: 0
71+
retry_mode: :failures
7572
)
7673
@build_id = build_id
7774
@circuit_breakers = [CircuitBreaker::Disabled]
@@ -111,8 +108,6 @@ def initialize(
111108
@heartbeat_grace_period = heartbeat_grace_period
112109
@heartbeat_interval = heartbeat_interval
113110
@retry_mode = retry_mode
114-
@recovery_manifest = recovery_manifest
115-
@retry_count = retry_count
116111
end
117112

118113
def queue_init_timeout

‎ruby/lib/ci/queue/redis/retry.rb‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,9 @@ module Redis
55
class Retry < Static
66
def initialize(tests, config, redis:)
77
@redis = redis
8-
@poll_completed = false
98
super(tests, config)
109
end
1110

12-
def poll_completed?
13-
@poll_completed
14-
end
15-
16-
def poll
17-
super
18-
@poll_completed = exhausted?
19-
end
20-
2111
def build
2212
@build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config)
2313
end

‎ruby/lib/ci/queue/redis/worker.rb‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ def retrying?
145145
end
146146
end
147147

148-
def retry_queue(scope: :failures)
149-
return worker_history_retry_queue if scope == :worker_history
150-
raise ArgumentError, "Unknown retry scope: #{scope}" unless scope == :failures
148+
def retry_queue
149+
return worker_history_retry_queue if config.retry_mode == :worker_history
151150

152151
failures = build.failed_tests.to_set
153152
log = redis.lrange(key('worker', worker_id, 'queue'), 0, -1)

‎ruby/lib/minitest/queue.rb‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
require 'minitest/queue/grind_reporter'
1616
require 'minitest/queue/test_time_recorder'
1717
require 'minitest/queue/test_time_reporter'
18-
require 'minitest/queue/recovery_reporter'
1918

2019
module Minitest
2120
class Requeue < Skip

‎ruby/lib/minitest/queue/recovery_reporter.rb‎

Lines changed: 0 additions & 54 deletions
This file was deleted.

‎ruby/lib/minitest/queue/runner.rb‎

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
require 'minitest/queue'
55
require 'ci/queue'
66
require 'digest/md5'
7-
require 'fileutils'
87
require 'minitest/reporters/bisect_reporter'
98
require 'minitest/reporters/statsd_reporter'
109

@@ -50,17 +49,16 @@ def retry_command
5049

5150
def run_command
5251
require_worker_id!
53-
FileUtils.rm_f(queue_config.recovery_manifest) if queue_config.recovery_manifest
5452
if queue.retrying? || retry?
5553
if queue.expired?
5654
abort! "The test run is too old and can't be retried"
5755
end
5856
reset_counters
59-
retry_queue = retry_queue_for_retry
57+
retry_queue = queue.retry_queue
6058
if retry_queue.exhausted?
6159
puts "The retry queue does not contain any failure, we'll process the main queue instead."
6260
else
63-
if worker_history_retry?
61+
if queue_config.retry_mode == :worker_history
6462
puts "Replaying this worker's reservation history."
6563
else
6664
puts "Retrying failed tests."
@@ -87,13 +85,6 @@ def run_command
8785
if queue_config.statsd_endpoint
8886
reporters << Minitest::Reporters::StatsdReporter.new(statsd_endpoint: queue_config.statsd_endpoint)
8987
end
90-
if queue_config.recovery_manifest
91-
reporters << RecoveryReporter.new(
92-
path: queue_config.recovery_manifest,
93-
queue: queue,
94-
config: queue_config
95-
)
96-
end
9788
Minitest.queue_reporters = reporters
9889

9990
trap('TERM') { Minitest.queue.shutdown! }
@@ -337,22 +328,6 @@ def reset_counters
337328
queue.build.reset_stats(BuildStatusRecorder::COUNTERS)
338329
end
339330

340-
def worker_history_retry?
341-
queue_config.retry_mode == :worker_history
342-
end
343-
344-
def retry_queue_for_retry
345-
if worker_history_retry?
346-
abort! 'Worker history recovery requires a distributed Redis queue' unless queue.distributed?
347-
348-
queue.retry_queue(scope: :worker_history)
349-
else
350-
queue.retry_queue
351-
end
352-
rescue CI::Queue::Redis::WorkerHistoryError => error
353-
abort! error.message
354-
end
355-
356331
def populate_queue
357332
Minitest.queue.populate(Minitest.loaded_tests, random: ordering_seed, &:id)
358333
end
@@ -531,14 +506,6 @@ def parser
531506
queue_config.retry_mode = mode.tr('-', '_').to_sym
532507
end
533508

534-
help = <<~EOS
535-
Write worker-history recovery details to a JSON file after a completed run.
536-
EOS
537-
opts.separator ""
538-
opts.on('--recovery-manifest PATH', help) do |path|
539-
queue_config.recovery_manifest = path
540-
end
541-
542509
help = <<~EOS
543510
Defines how many time a single test can be requeued.
544511
Defaults to 0.

‎ruby/test/integration/minitest_redis_test.rb‎

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -264,45 +264,20 @@ def test_retry_fails_when_test_run_is_expired
264264
assert_equal "The test run is too old and can't be retried", output
265265
end
266266

267-
def test_worker_history_retry_writes_recovery_manifest
268-
Dir.mktmpdir do |directory|
269-
manifest_path = File.join(directory, 'recovery.json')
270-
run_worker_history_worker(manifest_path, retry_count: 0)
271-
272-
first_manifest = JSON.parse(File.read(manifest_path))
273-
assert_equal 0, first_manifest['retry_count']
274-
refute first_manifest['resumed_shared_queue']
275-
assert first_manifest['replay_completed']
276-
277-
out, = run_worker_history_worker(manifest_path, retry_count: 1)
278-
279-
assert_includes out, "Replaying this worker's reservation history."
280-
retry_manifest = JSON.parse(File.read(manifest_path))
281-
assert_equal 1, retry_manifest['schema_version']
282-
assert_equal '1', retry_manifest['worker_id']
283-
assert_equal 1, retry_manifest['retry_count']
284-
refute retry_manifest['resumed_shared_queue']
285-
assert retry_manifest['replay_completed']
286-
end
267+
def test_worker_history_retry_replays_worker_reservations
268+
run_worker_history_worker(retry_count: 0)
269+
out, = run_worker_history_worker(retry_count: 1)
270+
271+
assert_predicate $?, :success?
272+
assert_includes out, "Replaying this worker's reservation history."
287273
end
288274

289-
def test_worker_history_retry_removes_stale_manifest_when_history_is_missing
290-
run_worker_history_worker(nil, retry_count: 0, build_id: 'missing-history', worker_id: '1')
291-
292-
Dir.mktmpdir do |directory|
293-
manifest_path = File.join(directory, 'recovery.json')
294-
File.write(manifest_path, '{"stale":true}')
295-
out, = run_worker_history_worker(
296-
manifest_path,
297-
retry_count: 1,
298-
build_id: 'missing-history',
299-
worker_id: '2'
300-
)
275+
def test_worker_history_retry_fails_when_history_is_missing
276+
run_worker_history_worker(retry_count: 0, build_id: 'missing-history', worker_id: '1')
277+
out, err = run_worker_history_worker(retry_count: 1, build_id: 'missing-history', worker_id: '2')
301278

302-
refute_predicate $?, :success?
303-
assert_includes out, 'Reservation history is missing for worker 2'
304-
refute_path_exists manifest_path
305-
end
279+
refute_predicate $?, :success?
280+
assert_includes out + err, 'Reservation history is missing for worker 2'
306281
end
307282

308283
def test_retry_report
@@ -829,7 +804,7 @@ def test_utf8_tests_and_marshal
829804

830805
private
831806

832-
def run_worker_history_worker(manifest_path, retry_count:, build_id: 'worker-history', worker_id: '1')
807+
def run_worker_history_worker(retry_count:, build_id: 'worker-history', worker_id: '1')
833808
args = [
834809
@exe, 'run',
835810
'--queue', @redis_url,
@@ -839,7 +814,6 @@ def run_worker_history_worker(manifest_path, retry_count:, build_id: 'worker-his
839814
'--timeout', '1',
840815
'--retry-mode', 'worker-history'
841816
]
842-
args.push('--recovery-manifest', manifest_path) if manifest_path
843817
args.push('-Itest', 'test/passing_test.rb')
844818

845819
capture_subprocess_io do

0 commit comments

Comments
 (0)