Skip to content

Commit 2016d02

Browse files
committed
Check we executed all tests
1 parent a9277df commit 2016d02

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ruby/lib/ci/queue/redis/build_record.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def record_success(id, stats: nil, skip_flaky_record: false, acknowledge: true)
7272
error_reports_deleted_count, requeued_count, _ = redis.pipelined do |pipeline|
7373
pipeline.hdel(key('error-reports'), id)
7474
pipeline.hget(key('requeues-count'), id)
75+
pipeline.sadd(key('success-reports'), id)
76+
pipeline.expire(key('success-reports'), config.redis_ttl)
7577
record_stats(stats, pipeline: pipeline)
7678
end
7779
record_flaky(id) if !skip_flaky_record && (error_reports_deleted_count.to_i > 0 || requeued_count.to_i > 0)

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ def poll
6969
pipeline.expire(key('worker', worker_id, 'queue'), config.redis_ttl)
7070
pipeline.expire(key('processed'), config.redis_ttl)
7171
end
72+
73+
# check we executed all tests
74+
# only the master should perform this check because otherwise we will DDoS Redis when all workers
75+
# try to fetch the processed tests at the same time
76+
if master? && exhausted?
77+
executed_tests = (redis.smembers(key('success-reports')) + redis.hkeys(key('error-reports')))
78+
missing_tests = @index.keys - executed_tests
79+
80+
if missing_tests.size > 0
81+
puts "ci-queue did not process all tests!"
82+
puts missing_tests
83+
exit!(46)
84+
end
85+
end
7286
rescue *CONNECTION_ERRORS
7387
end
7488

0 commit comments

Comments
 (0)