Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ruby/lib/ci/queue/redis/worker.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'ci/queue/static'
require 'set'
require 'concurrent/set'

module CI
module Queue
Expand All @@ -21,6 +21,7 @@ class Worker < Base

def initialize(redis, config)
@reserved_test = nil
@reserved_tests = Concurrent::Set.new
@shutdown_required = false
@idle_since = nil
super(redis, config)
Expand Down Expand Up @@ -301,6 +302,10 @@ def ensure_connection_and_script(script)
redis.ping
end

def reserved_tests
@reserved_tests ||= Concurrent::Set.new
end

def worker_id
config.worker_id
end
Expand Down
6 changes: 6 additions & 0 deletions ruby/lib/ci/queue/static.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'concurrent/set'

module CI
module Queue
class Static
Expand Down Expand Up @@ -112,6 +114,10 @@ def should_requeue?(key)
def requeues
@requeues ||= Hash.new(0)
end

def reserved_tests
@reserved_tests ||= Concurrent::Set.new
end
end
end
end
2 changes: 2 additions & 0 deletions ruby/test/integration/minitest_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'test_helper'
require 'tmpdir'
require 'active_support/testing/time_helpers'
require 'concurrent/set'

module Integration
class MinitestRedisTest < Minitest::Test
Expand Down Expand Up @@ -308,6 +309,7 @@ def test_retry_report
assert_equal 100, error_reports.size

error_reports.keys.each_with_index do |test_id, index|
queue.instance_variable_set(:@reserved_tests, Concurrent::Set.new([test_id]))
queue.build.record_success(test_id.dup, stats: {
'assertions' => index + 1,
'errors' => 0,
Expand Down
5 changes: 5 additions & 0 deletions ruby/test/minitest/queue/build_status_recorder_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'test_helper'
require 'concurrent/set'

module Minitest::Queue
class BuildStatusRecorderTest < Minitest::Test
Expand Down Expand Up @@ -50,6 +51,10 @@ def test_retrying_test

private

def reserve(queue, method_name)
queue.instance_variable_set(:@reserved_tests, Concurrent::Set.new([Minitest::Queue::SingleExample.new("Minitest::Test", method_name).id]))
end

def worker(id)
CI::Queue::Redis.new(
@redis_url,
Expand Down