summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-10-23 08:04:31 -0700
committerMatt Robinson <matt@puppetlabs.com>2010-10-28 15:35:02 -0700
commit5bf19e40df5e955c045f7a42a070cdbefecbcbe1 (patch)
tree54393bc6c2bcaa39ad1718b6d5ebd90e6b4448cc
parent1b60cc3c299306d783d9b0e9368726d2c04c9f21 (diff)
downloadpuppet-5bf19e40df5e955c045f7a42a070cdbefecbcbe1.tar.gz
puppet-5bf19e40df5e955c045f7a42a070cdbefecbcbe1.tar.xz
puppet-5bf19e40df5e955c045f7a42a070cdbefecbcbe1.zip
[#4894] Randomize port on webrick tests
This isn't a great test fix, but it should be enough for now to stop the sporadic test failures in Hudson where webrick isn't releasing it's port which causes other tests to fail. I created ticket #5098 as a reminder to refactor these tests later. Reviewed-by: Paul Berry
-rwxr-xr-xspec/integration/indirector/certificate_revocation_list/rest_spec.rb10
-rwxr-xr-xspec/integration/indirector/rest_spec.rb12
2 files changed, 15 insertions, 7 deletions
diff --git a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
index 86f2b0150..d831805c8 100755
--- a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
+++ b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
@@ -8,7 +8,11 @@ require 'puppet/network/http/webrick/rest'
describe "Certificate REST Terminus" do
before do
- Puppet[:masterport] = 34343
+# This port randomization is NOT a good pattern for testing, don't copy
+# but it's a quick fix to deal with sporadic test failures in Hudson #4894
+# Ticket #5098 created to fix these tests in the future
+ masterport = rand(100) + 34500
+ Puppet[:masterport] = masterport
Puppet[:server] = "localhost"
# Get a safe temporary file
@@ -19,7 +23,7 @@ describe "Certificate REST Terminus" do
Puppet.settings[:vardir] = @dir
Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
- Puppet.settings[:masterport] = "34343"
+ Puppet.settings[:masterport] = masterport
Puppet::Util::Cacher.expire
@@ -32,7 +36,7 @@ describe "Certificate REST Terminus" do
ca = Puppet::SSL::CertificateAuthority.new
ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname])
- @params = { :port => 34343, :handlers => [ :certificate_revocation_list ] }
+ @params = { :port => masterport, :handlers => [ :certificate_revocation_list ] }
@server = Puppet::Network::Server.new(@params)
@server.listen
diff --git a/spec/integration/indirector/rest_spec.rb b/spec/integration/indirector/rest_spec.rb
index 14e9e9593..e36d793ea 100755
--- a/spec/integration/indirector/rest_spec.rb
+++ b/spec/integration/indirector/rest_spec.rb
@@ -30,6 +30,10 @@ end
class Puppet::TestIndirectedFoo::Rest < Puppet::Indirector::REST
end
+# This port randomization is NOT a good pattern for testing, don't copy
+# but it's a quick fix to deal with sporadic test failures in Hudson #4894
+# Ticket #5098 created to fix these tests in the future
+masterport = rand(100) + 34300
describe Puppet::Indirector::REST do
before do
@@ -41,7 +45,7 @@ describe Puppet::Indirector::REST do
Puppet.settings[:vardir] = @dir
Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
- Puppet.settings[:masterport] = "34343"
+ Puppet.settings[:masterport] = masterport
Puppet::SSL::Host.ca_location = :local
@@ -65,7 +69,7 @@ describe Puppet::Indirector::REST do
ca = Puppet::SSL::CertificateAuthority.new
ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname])
- @params = { :port => 34343, :handlers => [ :test_indirected_foo ], :xmlrpc_handlers => [ :status ] }
+ @params = { :port => masterport, :handlers => [ :test_indirected_foo ], :xmlrpc_handlers => [ :status ] }
@server = Puppet::Network::Server.new(@params)
@server.listen
@@ -291,7 +295,7 @@ describe Puppet::Indirector::REST do
before :each do
Puppet[:servertype] = 'mongrel'
- @params = { :port => 34343, :handlers => [ :test_indirected_foo ] }
+ @params = { :port => masterport, :handlers => [ :test_indirected_foo ] }
# Make sure we never get a cert, since mongrel can't speak ssl
Puppet::SSL::Certificate.stubs(:find).returns nil
@@ -312,7 +316,7 @@ describe Puppet::Indirector::REST do
Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:check_authorization).returns(true)
end
- after do
+ after :each do
@server.unlisten
end