summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-01-23 10:53:27 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-01-23 10:53:27 -0800
commit8b1052a21db688440b9a002a4bf127a5118d0b5a (patch)
tree97d90ef2be18ff52b8c1925bddd2774cfb700f8d
parentbc98db2fd24d75443d048a83ae1844eec7499507 (diff)
downloadchef-lcg/speed-up-http-func-tests.tar.gz
speed up http func testslcg/speed-up-http-func-tests
For the truncated downloads the tiny server needs to hit its RequestTimeout in order to terminate the truncated request, so that is set to 1 second. Then also drop down the retries and the rest_timeout on the client side (but keep the rest_timeout to 2 to keep it above the tiny_server timeout) Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/http.rb2
-rw-r--r--spec/functional/http/simple_spec.rb16
-rw-r--r--spec/functional/resource/remote_file_spec.rb30
3 files changed, 29 insertions, 19 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index c9df4e1235..241806da4e 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -5,7 +5,7 @@
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2009-2017, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb
index 421045693a..e792cc8d75 100644
--- a/spec/functional/http/simple_spec.rb
+++ b/spec/functional/http/simple_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@chef.io>)
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,11 +26,17 @@ describe Chef::HTTP::Simple do
let(:http_client) { described_class.new(source) }
let(:http_client_disable_gzip) { described_class.new(source, { :disable_gzip => true } ) }
+ before(:all) do
+ start_tiny_server(RequestTimeout: 1)
+ end
+
before(:each) do
- start_tiny_server
+ Chef::Config[:rest_timeout] = 2
+ Chef::Config[:http_retry_delay] = 0
+ Chef::Config[:http_retry_count] = 0
end
- after(:each) do
+ after(:all) do
stop_tiny_server
end
@@ -46,10 +52,10 @@ describe Chef::HTTP::Simple do
end
shared_examples_for "validates content length and throws an exception" do
- it "successfully downloads a streaming request" do
+ it "a streaming request throws a content length exception" do
expect { http_client.streaming_request(source) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
- it "successfully does a non-streaming GET request" do
+ it "a non-streaming GET request throws a content length exception" do
expect { http_client.get(source) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
end
end
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 94c42a73ba..8e484b2968 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
-# Copyright:: Copyright 2011-2016, Chef Software Inc.
+# Copyright:: Copyright 2011-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,9 @@ describe Chef::Resource::RemoteFile do
before(:each) do
@old_file_cache = Chef::Config[:file_cache_path]
Chef::Config[:file_cache_path] = file_cache_path
+ Chef::Config[:rest_timeout] = 2
+ Chef::Config[:http_retry_delay] = 0
+ Chef::Config[:http_retry_count] = 0
end
after(:each) do
@@ -55,11 +58,11 @@ describe Chef::Resource::RemoteFile do
let(:default_mode) { (0666 & ~File.umask).to_s(8) }
context "when fetching files over HTTP" do
- before(:each) do
- start_tiny_server
+ before(:all) do
+ start_tiny_server(RequestTimeout: 1)
end
- after(:each) do
+ after(:all) do
stop_tiny_server
end
@@ -97,21 +100,22 @@ describe Chef::Resource::RemoteFile do
context "when fetching files over HTTPS" do
- before(:each) do
+ before(:all) do
cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
cert = OpenSSL::X509::Certificate.new(cert_text)
key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
key = OpenSSL::PKey::RSA.new(key_text)
- server_opts = { :SSLEnable => true,
- :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
- :SSLCertificate => cert,
- :SSLPrivateKey => key }
+ server_opts = { SSLEnable: true,
+ SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
+ SSLCertificate: cert,
+ SSLPrivateKey: key,
+ RequestTimeout: 1 }
start_tiny_server(server_opts)
end
- after(:each) do
+ after(:all) do
stop_tiny_server
end
@@ -295,11 +299,11 @@ describe Chef::Resource::RemoteFile do
end
context "when dealing with content length checking" do
- before(:each) do
- start_tiny_server
+ before(:all) do
+ start_tiny_server(RequestTimeout: 1)
end
- after(:each) do
+ after(:all) do
stop_tiny_server
end