diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-07-19 15:57:39 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-07-19 15:57:39 -0700 |
| commit | e8a2287cdac5dbf086b60af65e301f3e2360ee2b (patch) | |
| tree | 1c565e2c754f3cb43f4e0dc8fa7bb5e81a40d064 /spec | |
| parent | c1e83597712f4553960b42aebc3ab45ae272e724 (diff) | |
| parent | 185a666018c0cf0b2c497f655f942a82cd22e49e (diff) | |
| download | puppet-e8a2287cdac5dbf086b60af65e301f3e2360ee2b.tar.gz puppet-e8a2287cdac5dbf086b60af65e301f3e2360ee2b.tar.xz puppet-e8a2287cdac5dbf086b60af65e301f3e2360ee2b.zip | |
Merge branch 'remove-http-pool-keep-alive'
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/network/client_spec.rb | 45 | ||||
| -rwxr-xr-x | spec/unit/network/http_pool_spec.rb | 75 |
2 files changed, 4 insertions, 116 deletions
diff --git a/spec/unit/network/client_spec.rb b/spec/unit/network/client_spec.rb deleted file mode 100755 index 102a053c0..000000000 --- a/spec/unit/network/client_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-24. -# Copyright (c) 2008. All rights reserved. - -require 'spec_helper' - -require 'puppet/network/client' - -describe Puppet::Network::Client do - before do - Puppet.settings.stubs(:use).returns(true) - Puppet::Network::HttpPool.stubs(:cert_setup) - end - - describe "when keep-alive is enabled" do - before do - Puppet::Network::HttpPool.stubs(:keep_alive?).returns true - end - it "should start the http client up on creation" do - http = mock 'http' - http.stub_everything - http.expects(:start) - Net::HTTP.stubs(:new).returns http - - # Pick a random subclass... - Puppet::Network::Client.runner.new :Server => Puppet[:server] - end - end - - describe "when keep-alive is disabled" do - before do - Puppet::Network::HttpPool.stubs(:keep_alive?).returns false - end - it "should not start the http client up on creation" do - http = mock 'http' - http.stub_everything - http.expects(:start).never - Net::HTTP.stubs(:new).returns http - - # Pick a random subclass... - Puppet::Network::Client.runner.new :Server => Puppet[:server] - end - end -end diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb index 32c7a90fe..1961f3029 100755 --- a/spec/unit/network/http_pool_spec.rb +++ b/spec/unit/network/http_pool_spec.rb @@ -8,15 +8,9 @@ require 'puppet/network/http_pool' describe Puppet::Network::HttpPool do after do - Puppet::Util::Cacher.expire - Puppet::Network::HttpPool.clear_http_instances Puppet::Network::HttpPool.instance_variable_set("@ssl_host", nil) end - it "should have keep-alive disabled" do - Puppet::Network::HttpPool::HTTP_KEEP_ALIVE.should be_false - end - it "should use the global SSL::Host instance to get its certificate information" do host = mock 'host' Puppet::SSL::Host.expects(:localhost).with.returns host @@ -58,71 +52,10 @@ describe Puppet::Network::HttpPool do Puppet::Network::HttpPool.http_instance("me", 54321).open_timeout.should == 120 end - describe "and http keep-alive is enabled" do - before do - Puppet::Network::HttpPool.stubs(:keep_alive?).returns true - end - - it "should cache http instances" do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - old = Puppet::Network::HttpPool.http_instance("me", 54321) - Puppet::Network::HttpPool.http_instance("me", 54321).should equal(old) - end - - it "should have a mechanism for getting a new http instance instead of the cached instance" do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - old = Puppet::Network::HttpPool.http_instance("me", 54321) - Puppet::Network::HttpPool.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_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - old = Puppet::Network::HttpPool.http_instance("me", 54321) - old.expects(:started?).returns(true) - old.expects(:finish) - Puppet::Network::HttpPool.http_instance("me", 54321, true) - end - - it "should have a mechanism for clearing the http cache", :fails_on_windows => true do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - old = Puppet::Network::HttpPool.http_instance("me", 54321) - Puppet::Network::HttpPool.http_instance("me", 54321).should equal(old) - old = Puppet::Network::HttpPool.http_instance("me", 54321) - Puppet::Network::HttpPool.clear_http_instances - Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old) - end - - it "should close open http connections when clearing the cache" do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - one = Puppet::Network::HttpPool.http_instance("me", 54321) - one.expects(:started?).returns(true) - one.expects(:finish).returns(true) - Puppet::Network::HttpPool.clear_http_instances - end - - it "should not close unopened http connections when clearing the cache" do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - one = Puppet::Network::HttpPool.http_instance("me", 54321) - one.expects(:started?).returns(false) - one.expects(:finish).never - Puppet::Network::HttpPool.clear_http_instances - end - end - - describe "and http keep-alive is disabled" do - before do - Puppet::Network::HttpPool.stubs(:keep_alive?).returns false - end - - it "should not cache http instances" do - stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 - old = Puppet::Network::HttpPool.http_instance("me", 54321) - Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old) - end - end - - after do - Puppet::Network::HttpPool.clear_http_instances + it "should not cache http instances" do + stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120 + old = Puppet::Network::HttpPool.http_instance("me", 54321) + Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old) end end |
