diff options
author | Eugene Kenny <elkenny@gmail.com> | 2015-05-04 02:56:30 +0100 |
---|---|---|
committer | Eugene Kenny <elkenny@gmail.com> | 2016-03-11 15:30:25 +0000 |
commit | 1da352d06dac8ac3fa2fe0ceb4856c2203555134 (patch) | |
tree | 8f19758283b3eabcd4f28dbed61d18a8bf50eff8 /test | |
parent | 9682f42c3020254edefdbc66acf421858163f005 (diff) | |
download | net-ssh-multi-1da352d06dac8ac3fa2fe0ceb4856c2203555134.tar.gz |
Use keepalive_interval option as IO select timeout
Net::SSH supports sending keepalive packets to the server to check
whether the connection is still alive. For this to work, IO#select needs
to be given a timeout so that the event loop can run periodically and
send the packets.
Diffstat (limited to 'test')
-rw-r--r-- | test/session_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/session_test.rb b/test/session_test.rb index 42a56b2..c027db9 100644 --- a/test/session_test.rb +++ b/test/session_test.rb @@ -198,4 +198,25 @@ class SessionTest < Minitest::Test IO.expects(:select).with([:a, :b, :c], [:a, :c], nil, 5).returns([[:b, :c], [:a, :c]]) @session.process(5) end + + def test_process_should_pass_minimum_keepalive_interval_as_io_select_timeout + @session.use('h1', :keepalive => true) + @session.use('h2', :keepalive_interval => 1) + @session.use('h3', :keepalive => true, :keepalive_interval => 2) + @session.use('h4', :keepalive => true, :keepalive_interval => 3) + IO.expects(:select).with([], [], nil, 2) + @session.process + end + + def test_process_should_pass_wait_as_io_select_timeout_if_provided_and_minimum + @session.use('h1', :keepalive => true, :keepalive_interval => 1) + IO.expects(:select).with([], [], nil, 1) + @session.process(2) + end + + def test_process_should_pass_nil_as_io_select_timeout_by_default + @session.use('h1') + IO.expects(:select).with([], [], nil, nil) + @session.process + end end |