From 96e1b674eacb7937a6cda0b148fbe6f7b84c1a0c Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sat, 23 Nov 2024 12:22:09 -0600 Subject: [PATCH] CI; test/test_puma_server.rb - fixup auto_trim tests --- test/test_puma_server.rb | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/test/test_puma_server.rb b/test/test_puma_server.rb index 27c380e0dd..1570747fd8 100644 --- a/test/test_puma_server.rb +++ b/test/test_puma_server.rb @@ -2102,35 +2102,12 @@ def test_cl_and_te_smuggle end def test_auto_trim_with_variable_pool_size - auto_trim_time = 3 - server_run(min_threads: 1, max_threads: 2, auto_trim_time: auto_trim_time) - sleep 1 # wait for possible initial trim on run - thread_pool_expect true, :trim, nil, after: auto_trim_time + server_run(min_threads: 1, max_threads: 2, auto_trim_time: 1) + assert @pool.instance_variable_get(:@auto_trim) end def test_auto_trim_with_fixed_pool_size - auto_trim_time = 3 - server_run(min_threads: 2, max_threads: 2, auto_trim_time: auto_trim_time) - sleep 1 # wait for possible initial trim on run - thread_pool_expect false, :trim, nil, after: auto_trim_time - end - - private - - def thread_pool_expect(should_expect, expect_method, *expect_args, after: nil) - mock_pool = Minitest::Mock.new - mock_pool.expect(expect_method, *expect_args) if should_expect - - @pool.singleton_class.class_eval do - define_method(expect_method) do |*args, **kwargs| - raise "unexpected #{expect_method} called on Puma::Threadpool" unless should_expect - - mock_pool.public_send(expect_method, *args, **kwargs) - end - end - - sleep after if after - - assert mock_pool.verify # assert to satisfy proveit + server_run(min_threads: 2, max_threads: 2, auto_trim_time: 1) + refute @pool.instance_variable_get(:@auto_trim) end end