diff options
| author | David Lutterkort <dlutter@redhat.com> | 2007-12-17 16:52:54 -0800 |
|---|---|---|
| committer | David Lutterkort <dlutter@redhat.com> | 2007-12-17 16:52:54 -0800 |
| commit | 4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52 (patch) | |
| tree | 9e708ec31ce32909cdc693037d7b6e1f32a06b62 /spec/unit | |
| parent | 8f5989a66b3e9ff3001b50c07a818c6ccb04a65f (diff) | |
| parent | 933b1df6d84ec34a6ff347240c0151434ecc80a9 (diff) | |
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'spec/unit')
| -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 |
