diff options
| author | Luke Kanies <luke@madstop.com> | 2007-12-17 17:13:25 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-12-17 17:13:25 -0600 |
| commit | 933b1df6d84ec34a6ff347240c0151434ecc80a9 (patch) | |
| tree | c02967b3be2880db79af12e685dce03b5ffce2c6 /spec | |
| parent | e0dab9a48896f3d92b2845f5a886885ede777305 (diff) | |
Fixing #961 -- closing existing, open connections when
a new connection is requested, and closing all connections
at the end of each run.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/network/xmlrpc/client.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/spec/unit/network/xmlrpc/client.rb b/spec/unit/network/xmlrpc/client.rb index 2e7b566d5..b40486e13 100755 --- a/spec/unit/network/xmlrpc/client.rb +++ b/spec/unit/network/xmlrpc/client.rb @@ -14,7 +14,7 @@ describe Puppet::Network::XMLRPCClient, " when managing http instances" do end it "should return an http instance created with the passed host and port" do - http = stub 'http', :use_ssl= => nil, :read_timeout= => nil, :open_timeout= => nil, :enable_post_connection_check= => nil + http = stub 'http', :use_ssl= => nil, :read_timeout= => nil, :open_timeout= => nil, :enable_post_connection_check= => nil, :started? => false Net::HTTP.expects(:new).with("me", 54321, nil, nil).returns(http) Puppet::Network::XMLRPCClient.http_instance("me", 54321).should equal(http) end @@ -62,6 +62,20 @@ describe Puppet::Network::XMLRPCClient, " when managing http instances" do Puppet::Network::XMLRPCClient.http_instance("me", 54321).should_not equal(old) end + it "should have a mechanism for getting a new http instance instead of the cached instance" do + stub_settings :http_keepalive => true, :http_proxy_host => "myhost", :http_proxy_port => 432, :http_enable_post_connection_check => true + old = Puppet::Network::XMLRPCClient.http_instance("me", 54321) + Puppet::Network::XMLRPCClient.http_instance("me", 54321, true).should_not equal(old) + end + + it "should close existing, open connections when requesting a new connection" do + stub_settings :http_keepalive => true, :http_proxy_host => "myhost", :http_proxy_port => 432, :http_enable_post_connection_check => true + old = Puppet::Network::XMLRPCClient.http_instance("me", 54321) + old.expects(:started?).returns(true) + old.expects(:finish) + Puppet::Network::XMLRPCClient.http_instance("me", 54321, true) + end + it "should have a mechanism for clearing the http cache" do stub_settings :http_keepalive => true, :http_proxy_host => "myhost", :http_proxy_port => 432, :http_enable_post_connection_check => true old = Puppet::Network::XMLRPCClient.http_instance("me", 54321) @@ -71,6 +85,22 @@ describe Puppet::Network::XMLRPCClient, " when managing http instances" do Puppet::Network::XMLRPCClient.http_instance("me", 54321).should_not equal(old) end + it "should close open http connections when clearing the cache" do + stub_settings :http_keepalive => true, :http_proxy_host => "myhost", :http_proxy_port => 432, :http_enable_post_connection_check => true + one = Puppet::Network::XMLRPCClient.http_instance("me", 54321) + one.expects(:started?).returns(true) + one.expects(:finish).returns(true) + Puppet::Network::XMLRPCClient.clear_http_instances + end + + it "should not close unopened http connections when clearing the cache" do + stub_settings :http_keepalive => true, :http_proxy_host => "myhost", :http_proxy_port => 432, :http_enable_post_connection_check => true + one = Puppet::Network::XMLRPCClient.http_instance("me", 54321) + one.expects(:started?).returns(false) + one.expects(:finish).never + Puppet::Network::XMLRPCClient.clear_http_instances + end + after do Puppet::Network::XMLRPCClient.clear_http_instances end |
