From 9e9ed7007332d65bc2f0a4d764c5f34733a27f94 Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 6 Nov 2024 13:41:11 +0900 Subject: [PATCH] test_ack_handler: use singleton method instead of stub for stability (#4698) When using stub, sometimes it causes errors when it remove prepared methods by stub. To improve the stability of the CI, this patch will use the singleton method instead of stub. Signed-off-by: Shizuo Fujita Signed-off-by: Kentaro Hayashi --- test/plugin/out_forward/test_ack_handler.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/plugin/out_forward/test_ack_handler.rb b/test/plugin/out_forward/test_ack_handler.rb index 8264e4ac99..9246da8622 100644 --- a/test/plugin/out_forward/test_ack_handler.rb +++ b/test/plugin/out_forward/test_ack_handler.rb @@ -111,11 +111,11 @@ class AckHandlerTest < Test::Unit::TestCase r, w = IO.pipe begin w.write(chunk_id) - stub(r).recv { |_| + def r.recv(arg) sleep(1) # To ensure that multiple threads select the socket before closing. - raise IOError, 'stream closed in another thread' if r.closed? + raise IOError, 'stream closed in another thread' if self.closed? MessagePack.pack({ 'ack' => Base64.encode64('chunk_id 111') }) - } + end ack.enqueue(r) threads = []