[#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.
This commit is contained in:
Родитель
62e3b611e6
Коммит
174e02a2b7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче