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
2 changes: 1 addition & 1 deletion redis/acknowledge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local error = ARGV[2]
local ttl = ARGV[3]
redis.call('zrem', zset_key, test)
redis.call('hdel', owners_key, test) -- Doesn't matter if it was reclaimed by another workers
local acknowledged = redis.call('sadd', processed_key, test)
local acknowledged = redis.call('sadd', processed_key, test) == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the mistake was to think Lua consider 0 as falsey.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right 🤦


if acknowledged and error ~= "" then
redis.call('hset', error_reports_key, test, error)
Expand Down
52 changes: 42 additions & 10 deletions ruby/test/minitest/queue/build_status_recorder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,34 @@ def test_retrying_test
assert_equal 0, summary.error_reports.size
end

def test_retrying_test_reverse
yielded = false

test = nil

@queue.poll do |_test|
test = _test
assert_equal "a", test.method_name
@reporter.record(result(test.method_name))

assert_equal 0, summary.error_reports.size

yielded = true
break
end

assert yielded, "@queue.poll didn't yield"

second_queue = worker(2)
second_reporter = BuildStatusRecorder.new(build: second_queue.build)
second_reporter.start

# pretend we reserved the same test again
reserve(second_queue, "a")
second_reporter.record(result("a", failure: "Something went wrong"))
assert_equal 0, summary.error_reports.size
end

def test_static_queue_record_success
static_queue = CI::Queue::Static.new(['test_example'], CI::Queue::Configuration.new(build_id: '42', worker_id: '1'))
static_reporter = BuildStatusRecorder.new(build: static_queue.build)
Expand All @@ -97,16 +125,20 @@ def reserve(queue, method_name)
end

def worker(id)
CI::Queue::Redis.new(
@redis_url,
CI::Queue::Configuration.new(
build_id: '42',
worker_id: id.to_s,
timeout: 0.2,
),
).populate([
Minitest::Queue::SingleExample.new("Minitest::Test", "a")
])
result = nil
capture_io do
result = CI::Queue::Redis.new(
@redis_url,
CI::Queue::Configuration.new(
build_id: '42',
worker_id: id.to_s,
timeout: 0.2,
),
).populate([
Minitest::Queue::SingleExample.new("Minitest::Test", "a")
])
end
result
end

def summary
Expand Down
Loading