Skip to content

Commit

Permalink
add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
stephsachrajda committed Oct 19, 2023
1 parent c7ece4b commit 4135e25
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions ruby/lib/ci/queue/redis/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def queue_initializing?
end

def increment_test_failed
puts "---- incrementing cache test failed"
redis.incr(key('test_failed_count'))
end

Expand Down
6 changes: 4 additions & 2 deletions ruby/lib/ci/queue/redis/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ def build
def acknowledge(test)
test_key = test.id
raise_on_mismatching_test(test_key)
eval_script(
result = eval_script(
:acknowledge,
keys: [key('running'), key('processed'), key('owners')],
argv: [test_key],
) == 1
)
puts "result = #{result}" unless result == 1
result == 1
end

def requeue(test, offset: Redis.requeue_offset)
Expand Down
20 changes: 16 additions & 4 deletions ruby/lib/minitest/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,29 @@ def run_from_queue(reporter, *)
end

requeued = false

if failed && CI::Queue.requeueable?(result) && queue.requeue(example)
requeued = true
result.requeue!
puts "---- requeable recording!"
reporter.record(result)
elsif queue.acknowledge(example) || !failed
# If the test was already acknowledged by another worker (we timed out)
# Then we only record it if it is successful.
reporter.record(result)
else
ack_result = queue.acknowledge(example)
puts "no ack" unless ack_result
if ack_result
# If the test was already acknowledged by another worker (we timed out)
# Then we only record it if it is successful.
puts "---- ACK recording!"
reporter.record(result)
elsif !failed
puts "---- not failed recording!"
reporter.record(result)
end
end

if !requeued && failed
puts "---- id = #{example.id}"
puts "---- incrementing test failed in poll"
queue.increment_test_failed
end
end
Expand Down
3 changes: 3 additions & 0 deletions ruby/lib/minitest/queue/build_status_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ def record(test)
elsif test.skipped?
self.skips += 1
elsif test.error?
puts "--- increment error in record"
self.errors += 1
elsif test.failure
puts "--- increment failure in record"
self.failures += 1
end

stats = COUNTERS.zip(COUNTERS.map { |c| send(c) }).to_h
if (test.failure || test.error?) && !test.skipped?
puts "--- recording error in record"
build.record_error("#{test.klass}##{test.name}", dump(test), stats: stats)
else
build.record_success("#{test.klass}##{test.name}", stats: stats, skip_flaky_record: test.skipped?)
Expand Down
10 changes: 0 additions & 10 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,6 @@ def report_command
msg = "#{supervisor.size} tests weren't run."
if supervisor.max_test_failed?
puts("Encountered #{supervisor.test_failed} failures")

if queue_config.failure_file
reporter = BuildStatusReporter.new(build: supervisor.build)
failures = reporter.error_reports.map(&:to_h).to_json
puts "----"
puts failures
puts "----"
File.write(queue_config.failure_file, failures)
end

puts('Encountered too many failed tests. Test run was ended early.')
abort!(msg)
else
Expand Down

0 comments on commit 4135e25

Please sign in to comment.