Skip to content

Commit 48d6ff3

Browse files
committed
add connection pool keepalive test
1 parent 337ad41 commit 48d6ff3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Vagrantfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ VAGRANTFILE_API_VERSION = "2"
22

33
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
44
config.vm.box = 'hashicorp/precise64'
5+
config.vm.provision "shell", inline: <<-SHELL
6+
echo 'ClientAliveInterval 1' >> /etc/ssh/sshd_config
7+
echo 'ClientAliveCountMax 1' >> /etc/ssh/sshd_config
8+
service ssh restart
9+
SHELL
510

611
json_config_path = File.join("test", "boxes.json")
712
list = File.open(json_config_path).read

test/functional/backends/test_netssh.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ def test_interaction_handler
212212
end.run
213213
assert_equal("Enter Data\nCaptured SOME DATA", captured_command_result)
214214
end
215+
216+
def test_connection_pool_keepalive
217+
# ensure we enable connection pool
218+
SSHKit::Backend::Netssh.pool.idle_timeout = 10
219+
Netssh.new(a_host) do |_host|
220+
test :false
221+
end.run
222+
sleep 2.5
223+
captured_command_result = nil
224+
Netssh.new(a_host) do |_host|
225+
captured_command_result = capture(:echo, 'some_value')
226+
end.run
227+
assert_equal "some_value", captured_command_result
228+
end
215229
end
216230

217231
end

0 commit comments

Comments
 (0)