diff options
author | Markus Roberts <Markus@reality.com> | 2010-11-09 15:31:46 -0800 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2010-11-12 04:09:54 +1100 |
commit | a097b939ab52bafb681cf7c5dcaf11717add07e6 (patch) | |
tree | d5f6910975a771fea37349c7d611944c9a6a075e /spec/integration | |
parent | ee61b4ecec7d5a993eac6a356b4bc0dcc6ceaf94 (diff) | |
download | puppet-a097b939ab52bafb681cf7c5dcaf11717add07e6.tar.gz puppet-a097b939ab52bafb681cf7c5dcaf11717add07e6.tar.xz puppet-a097b939ab52bafb681cf7c5dcaf11717add07e6.zip |
Fix for #4894 -- retry tests if port is in use
If multiple processes are running the spec tests they may conflict trying to
listen on a port. If this happens the test waits 0.1 seconds and retries for
up to 100 times before marking the test pending due to too many conflicts.
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/indirector/bucket_file/rest_spec.rb | 11 | ||||
-rwxr-xr-x | spec/integration/indirector/certificate_revocation_list/rest_spec.rb | 11 | ||||
-rwxr-xr-x | spec/integration/indirector/rest_spec.rb | 12 |
3 files changed, 28 insertions, 6 deletions
diff --git a/spec/integration/indirector/bucket_file/rest_spec.rb b/spec/integration/indirector/bucket_file/rest_spec.rb index dc10faa67..9864a98ce 100644 --- a/spec/integration/indirector/bucket_file/rest_spec.rb +++ b/spec/integration/indirector/bucket_file/rest_spec.rb @@ -36,8 +36,15 @@ describe "Filebucket REST Terminus" do @host = Puppet::SSL::Host.new(Puppet[:certname]) @params = { :port => 34343, :handlers => [ :file_bucket_file ] } - @server = Puppet::Network::Server.new(@params) - @server.listen + begin + @server = Puppet::Network::Server.new(@params) + @server.listen + rescue Errno::EADDRINUSE => e + sleep 0.1 + puts "Port 34343 is in use; waiting for it to be free" if retries == 50 + retry if (retries += 1) < 100 + pending "Can't run too many simultanious tests" + end @old_terminus = Puppet::FileBucket::File.indirection.terminus_class Puppet::FileBucket::File.terminus_class = :rest diff --git a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb index 86f2b0150..3998db45f 100755 --- a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +++ b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb @@ -33,8 +33,15 @@ describe "Certificate REST Terminus" do ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) @params = { :port => 34343, :handlers => [ :certificate_revocation_list ] } - @server = Puppet::Network::Server.new(@params) - @server.listen + begin + @server = Puppet::Network::Server.new(@params) + @server.listen + rescue Errno::EADDRINUSE => e + sleep 0.1 + puts "Port 34343 is in use; waiting for it to be free" if retries == 50 + retry if (retries += 1) < 100 + pending "Can't run too many simultanious tests" + end # And make sure we've generated the CRL @crl = ca.crl diff --git a/spec/integration/indirector/rest_spec.rb b/spec/integration/indirector/rest_spec.rb index 14e9e9593..53a3086cd 100755 --- a/spec/integration/indirector/rest_spec.rb +++ b/spec/integration/indirector/rest_spec.rb @@ -66,8 +66,16 @@ describe Puppet::Indirector::REST do ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) @params = { :port => 34343, :handlers => [ :test_indirected_foo ], :xmlrpc_handlers => [ :status ] } - @server = Puppet::Network::Server.new(@params) - @server.listen + retries = 0 + begin + @server = Puppet::Network::Server.new(@params) + @server.listen + rescue Errno::EADDRINUSE => e + sleep 0.1 + puts "Port 34343 is in use; waiting for it to be free" if retries == 50 + retry if (retries += 1) < 100 + pending "Can't run too many simultanious tests" + end # LAK:NOTE We need to have a fake model here so that our indirected methods get # passed through REST; otherwise we'd be stubbing 'find', which would cause an immediate |