[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Markus Roberts
Markus at reality.com
Wed Jul 14 10:36:00 UTC 2010
The following commit has been merged in the upstream branch:
commit 174e02a2b71fd51ff27f9186526352d79253da26
Author: Matt Robinson <matt at puppetlabs.com>
Date: Thu Jul 1 12:01:46 2010 -0700
[#4090] Change how RunMode instances are created so that an object for each RunMode is only created once instead of every time it's called
Got lots of unpredictable test failures, presumably because a new
RunMode was being created every time we accessed the RunMode.
diff --git a/lib/puppet.rb b/lib/puppet.rb
index af1bd8d..2e0066c 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -93,7 +93,7 @@ module Puppet
def self.run_mode
require 'puppet/util/run_mode'
- $puppet_application_mode || Puppet::Util::RunMode.new( :user )
+ $puppet_application_mode || Puppet::Util::RunMode[:user]
end
def self.application_name
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index c49f42f..8aa3708 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -228,7 +228,7 @@ class Application
return @run_mode if @run_mode and not mode_name
require 'puppet/util/run_mode'
- @run_mode = Puppet::Util::RunMode.new( mode_name || :user )
+ @run_mode = Puppet::Util::RunMode[ mode_name || :user ]
end
end
diff --git a/lib/puppet/util/run_mode.rb b/lib/puppet/util/run_mode.rb
index 08f2c85..029c1f9 100644
--- a/lib/puppet/util/run_mode.rb
+++ b/lib/puppet/util/run_mode.rb
@@ -5,8 +5,14 @@ module Puppet
@name = name.to_sym
end
+ @@run_modes = Hash.new {|h, k| h[k] = RunMode.new(k)}
+
attr :name
+ def self.[](name)
+ @@run_modes[name]
+ end
+
def master?
name == :master
end
diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb
index db812b2..a39113d 100755
--- a/spec/unit/ssl/certificate_authority_spec.rb
+++ b/spec/unit/ssl/certificate_authority_spec.rb
@@ -27,7 +27,7 @@ describe Puppet::SSL::CertificateAuthority do
describe "and the host is a CA host and the run_mode is master" do
before do
Puppet.settings.stubs(:value).with(:ca).returns true
- Puppet::Util::RunMode.any_instance.stubs(:master?).returns true
+ Puppet.run_mode.stubs(:master?).returns true
@ca = mock('ca')
Puppet::SSL::CertificateAuthority.stubs(:new).returns @ca
diff --git a/test/network/authorization.rb b/test/network/authorization.rb
index 56c5377..3c1f71e 100755
--- a/test/network/authorization.rb
+++ b/test/network/authorization.rb
@@ -83,7 +83,7 @@ class TestAuthConfig < Test::Unit::TestCase
assert_logged(:notice, /Denying/, "did not log call")
# Now set our run_mode to master, so calls are allowed
- Puppet::Util::RunMode.any_instance.stubs(:master?).returns true
+ Puppet.run_mode.stubs(:master?).returns true
assert(@obj.authorized?(@request),
"Denied call with no config file and master")
assert_logged(:debug, /Allowing/, "did not log call")
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index 99b0481..e2493b4 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -93,7 +93,7 @@ class TestWebrickServer < Test::Unit::TestCase
}
pid = fork {
- Puppet::Util::RunMode.any_instance.stubs(:master?).returns true
+ Puppet.run_mode.stubs(:master?).returns true
assert_nothing_raised() {
trap(:INT) { server.shutdown }
server.start
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list