Actions
Patch #44265
closedWebhookTest occasionally hangs
Description
Running ./bin/rails test occasionally hangs because WebhookTest never finishes.
This seems to happen in WebhookTest#with_webhook_server when server.shutdown is called before the thread calls server.start. In that case, thread.join then waits forever because the thread never exits.
The issue can be reproduced more reliably by adding a delay before server.start:
diff --git a/test/unit/webhook_test.rb b/test/unit/webhook_test.rb
index 9d0a83f49..4c09c104e 100644
--- a/test/unit/webhook_test.rb
+++ b/test/unit/webhook_test.rb
@@ -366,10 +366,16 @@ class WebhookTest < ActiveSupport::TestCase
res.body = body
end
port = server.listeners.first.addr[1]
- thread = Thread.new { server.start }
+ thread = Thread.new do
+ sleep 3
+ server.start
+ end
yield port, received
$ ./bin/rails test test/unit/webhook_test.rb Run options: --seed 58457 # Running: (hangs indefinitely)
The attached patch prevents the test from hanging by forcibly terminating the thread if it does not exit within a reasonable amount of time.
Files
Updated by Katsuya HIDAKA 23 days ago
I confirmed that CI completed successfully with this patch on at least three separate runs. The patch looks good to me.
Since Redmine CI has been a bit unstable recently, I think we should merge this patch sooner rather than later.
Actions