summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-07-21 20:21:41 -0700
committerNick Lewis <nick@puppetlabs.com>2011-07-21 20:21:41 -0700
commitc5d70ed11f8f964523ca049d6c3d504de3840c1a (patch)
tree6f1872676315dde67aa865d5d177e18bdcf6e4a3
parent9c78759af57967d64eceeeb704a6673b81a76f30 (diff)
parentd198fedf65e472b384666fc9ae3bef487852068a (diff)
Merge branch 'remove-cacher'
-rw-r--r--lib/puppet/file_serving/configuration.rb16
-rw-r--r--lib/puppet/file_serving/mount.rb1
-rw-r--r--lib/puppet/file_serving/mount/file.rb21
-rw-r--r--lib/puppet/indirector/file_server.rb2
-rw-r--r--lib/puppet/indirector/indirection.rb8
-rw-r--r--lib/puppet/network/http_pool.rb1
-rw-r--r--lib/puppet/node/environment.rb10
-rw-r--r--lib/puppet/parameter.rb6
-rw-r--r--lib/puppet/resource/catalog.rb20
-rw-r--r--lib/puppet/ssl/certificate_authority.rb12
-rw-r--r--lib/puppet/ssl/host.rb13
-rw-r--r--lib/puppet/type.rb8
-rw-r--r--lib/puppet/type/file.rb23
-rwxr-xr-xlib/puppet/type/file/source.rb18
-rw-r--r--lib/puppet/util/autoload.rb2
-rw-r--r--lib/puppet/util/cacher.rb82
-rw-r--r--lib/puppet/util/settings.rb9
-rwxr-xr-xspec/integration/file_serving/content_spec.rb2
-rwxr-xr-xspec/integration/file_serving/metadata_spec.rb2
-rwxr-xr-xspec/integration/indirector/file_content/file_server_spec.rb2
-rwxr-xr-xspec/integration/network/server/webrick_spec.rb1
-rwxr-xr-xspec/integration/node/facts_spec.rb2
-rwxr-xr-xspec/integration/resource/catalog_spec.rb1
-rwxr-xr-xspec/integration/ssl/certificate_authority_spec.rb2
-rwxr-xr-xspec/integration/ssl/certificate_request_spec.rb6
-rwxr-xr-xspec/integration/ssl/certificate_revocation_list_spec.rb2
-rwxr-xr-xspec/integration/ssl/host_spec.rb1
-rwxr-xr-xspec/integration/transaction/report_spec.rb1
-rwxr-xr-xspec/shared_behaviours/file_server_terminus.rb2
-rwxr-xr-xspec/unit/file_serving/configuration_spec.rb60
-rwxr-xr-xspec/unit/file_serving/mount/file_spec.rb332
-rwxr-xr-xspec/unit/indirector/file_server_spec.rb2
-rwxr-xr-xspec/unit/indirector/indirection_spec.rb4
-rwxr-xr-xspec/unit/node/environment_spec.rb34
-rwxr-xr-xspec/unit/node/facts_spec.rb4
-rwxr-xr-xspec/unit/node_spec.rb4
-rwxr-xr-xspec/unit/parameter_spec.rb10
-rwxr-xr-xspec/unit/resource/catalog_spec.rb25
-rwxr-xr-xspec/unit/ssl/certificate_authority_spec.rb4
-rwxr-xr-xspec/unit/ssl/host_spec.rb12
-rwxr-xr-xspec/unit/transaction/report_spec.rb4
-rwxr-xr-xspec/unit/type/file/source_spec.rb22
-rwxr-xr-xspec/unit/type_spec.rb16
-rwxr-xr-xspec/unit/util/autoload_spec.rb4
-rwxr-xr-xspec/unit/util/cacher_spec.rb205
-rwxr-xr-xspec/unit/util/settings_spec.rb10
-rwxr-xr-xtest/lib/puppettest.rb1
-rwxr-xr-xtest/network/handler/master.rb5
-rwxr-xr-xtest/network/server/webrick.rb26
49 files changed, 350 insertions, 710 deletions
diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb
index 78e4de6cb..d88d57cb0 100644
--- a/lib/puppet/file_serving/configuration.rb
+++ b/lib/puppet/file_serving/configuration.rb
@@ -2,29 +2,27 @@
# Created by Luke Kanies on 2007-10-16.
# Copyright (c) 2007. All rights reserved.
+require 'monitor'
require 'puppet'
require 'puppet/file_serving'
require 'puppet/file_serving/mount'
require 'puppet/file_serving/mount/file'
require 'puppet/file_serving/mount/modules'
require 'puppet/file_serving/mount/plugins'
-require 'puppet/util/cacher'
class Puppet::FileServing::Configuration
require 'puppet/file_serving/configuration/parser'
- class << self
- include Puppet::Util::Cacher
- cached_attr(:configuration) { new }
+ extend MonitorMixin
+
+ def self.configuration
+ synchronize do
+ @configuration ||= new
+ end
end
Mount = Puppet::FileServing::Mount
- # Create our singleton configuration.
- def self.create
- configuration
- end
-
private_class_method :new
attr_reader :mounts
diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb
index 37dd89537..79290ab81 100644
--- a/lib/puppet/file_serving/mount.rb
+++ b/lib/puppet/file_serving/mount.rb
@@ -4,7 +4,6 @@
require 'puppet/network/authstore'
require 'puppet/util/logging'
-require 'puppet/util/cacher'
require 'puppet/file_serving'
require 'puppet/file_serving/metadata'
require 'puppet/file_serving/content'
diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb
index 7d622e4bf..7f5af7f52 100644
--- a/lib/puppet/file_serving/mount/file.rb
+++ b/lib/puppet/file_serving/mount/file.rb
@@ -1,18 +1,15 @@
-require 'puppet/util/cacher'
-
require 'puppet/file_serving/mount'
class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
- class << self
- include Puppet::Util::Cacher
-
- cached_attr(:localmap) do
- { "h" => Facter.value("hostname"),
- "H" => [Facter.value("hostname"),
- Facter.value("domain")].join("."),
- "d" => Facter.value("domain")
- }
- end
+ def self.localmap
+ @localmap ||= {
+ "h" => Facter.value("hostname"),
+ "H" => [
+ Facter.value("hostname"),
+ Facter.value("domain")
+ ].join("."),
+ "d" => Facter.value("domain")
+ }
end
def complete_path(relative_path, node)
diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb
index 46a08c97d..d6a8ab872 100644
--- a/lib/puppet/indirector/file_server.rb
+++ b/lib/puppet/indirector/file_server.rb
@@ -64,6 +64,6 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
# Our fileserver configuration, if needed.
def configuration
- Puppet::FileServing::Configuration.create
+ Puppet::FileServing::Configuration.configuration
end
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index d958a82ac..20b260b83 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -1,13 +1,11 @@
require 'puppet/util/docs'
require 'puppet/indirector/envelope'
require 'puppet/indirector/request'
-require 'puppet/util/cacher'
# The class that connects functional classes with their different collection
# back-ends. Each indirection has a set of associated terminus classes,
# each of which is a subclass of Puppet::Indirector::Terminus.
class Puppet::Indirector::Indirection
- include Puppet::Util::Cacher
include Puppet::Util::Docs
@@indirections = []
@@ -33,6 +31,8 @@ class Puppet::Indirector::Indirection
attr_accessor :name, :model
+ attr_reader :termini
+
# Create and return our cache terminus.
def cache
raise(Puppet::DevError, "Tried to cache when no cache class was set") unless cache_class
@@ -88,6 +88,7 @@ class Puppet::Indirector::Indirection
def initialize(model, name, options = {})
@model = model
@name = name
+ @termini = {}
@cache_class = nil
@terminus_class = nil
@@ -313,7 +314,4 @@ class Puppet::Indirector::Indirection
end
klass.new
end
-
- # Cache our terminus instances indefinitely, but make it easy to clean them up.
- cached_attr(:termini) { Hash.new }
end
diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb
index d4ec48d22..8baf48c77 100644
--- a/lib/puppet/network/http_pool.rb
+++ b/lib/puppet/network/http_pool.rb
@@ -1,6 +1,5 @@
require 'puppet/ssl/host'
require 'net/https'
-require 'puppet/util/cacher'
module Puppet::Network; end
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb
index 96fdc3c1e..f25bb65a9 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -95,7 +95,7 @@ class Puppet::Node::Environment
# Cache the modulepath, so that we aren't searching through
# all known directories all the time.
- cached_attr(:modulepath, :ttl => Puppet[:filetimeout]) do
+ cached_attr(:modulepath, Puppet[:filetimeout]) do
dirs = self[:modulepath].split(File::PATH_SEPARATOR)
dirs = ENV["PUPPETLIB"].split(File::PATH_SEPARATOR) + dirs if ENV["PUPPETLIB"]
validate_dirs(dirs)
@@ -103,7 +103,7 @@ class Puppet::Node::Environment
# Return all modules from this environment.
# Cache the list, because it can be expensive to create.
- cached_attr(:modules, :ttl => Puppet[:filetimeout]) do
+ cached_attr(:modules, Puppet[:filetimeout]) do
module_names = modulepath.collect { |path| Dir.entries(path) }.flatten.uniq
module_names.collect do |path|
begin
@@ -114,12 +114,6 @@ class Puppet::Node::Environment
end.compact
end
- # Cache the manifestdir, so that we aren't searching through
- # all known directories all the time.
- cached_attr(:manifestdir, :ttl => Puppet[:filetimeout]) do
- validate_dirs(self[:manifestdir].split(File::PATH_SEPARATOR))
- end
-
def to_s
name.to_s
end
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 29d60fc66..c97f93b23 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -2,7 +2,6 @@ require 'puppet/util/methodhelper'
require 'puppet/util/log_paths'
require 'puppet/util/logging'
require 'puppet/util/docs'
-require 'puppet/util/cacher'
class Puppet::Parameter
include Puppet::Util
@@ -10,7 +9,6 @@ class Puppet::Parameter
include Puppet::Util::LogPaths
include Puppet::Util::Logging
include Puppet::Util::MethodHelper
- include Puppet::Util::Cacher
require 'puppet/parameter/value_collection'
@@ -150,10 +148,6 @@ class Puppet::Parameter
self.fail(Puppet::DevError, msg)
end
- def expirer
- resource.catalog
- end
-
def fail(*args)
type = nil
if args[0].is_a?(Class)
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 8eb4266db..bb19f3ebc 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -3,7 +3,6 @@ require 'puppet/indirector'
require 'puppet/simple_graph'
require 'puppet/transaction'
-require 'puppet/util/cacher'
require 'puppet/util/pson'
require 'puppet/util/tagging'
@@ -20,7 +19,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
include Puppet::Util::Tagging
extend Puppet::Util::Pson
- include Puppet::Util::Cacher::Expirer
# The host name this is a catalog for.
attr_accessor :name
@@ -123,10 +121,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
def apply(options = {})
@applying = true
- # Expire all of the resource data -- this ensures that all
- # data we're operating against is entirely current.
- expire
-
Puppet::Util::Storage.load if host_config?
transaction = Puppet::Transaction.new(self, options[:report])
@@ -162,7 +156,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
return transaction
ensure
@applying = false
- cleanup
end
# Are we in the middle of applying the catalog?
@@ -197,14 +190,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
resource
end
- def dependent_data_expired?(ts)
- if applying?
- return super
- else
- return true
- end
- end
-
# Turn our catalog graph into an old-style tree of TransObjects and TransBuckets.
# LAK:NOTE(20081211): This is a pre-0.25 backward compatibility method.
# It can be removed as soon as xmlrpc is killed.
@@ -564,11 +549,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
private
- def cleanup
- # Expire any cached data the resources are keeping.
- expire
- end
-
# Verify that the given resource isn't defined elsewhere.
def fail_on_duplicate_type_and_title(resource)
# Short-curcuit the common case,
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index d65067c70..a4cbaf78a 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -1,6 +1,6 @@
+require 'monitor'
require 'puppet/ssl/host'
require 'puppet/ssl/certificate_request'
-require 'puppet/util/cacher'
# The class that knows how to sign certificates. It creates
# a 'special' SSL::Host whose name is 'ca', thus indicating
@@ -17,6 +17,8 @@ class Puppet::SSL::CertificateAuthority
require 'puppet/ssl/certificate_authority/interface'
require 'puppet/network/authstore'
+ extend MonitorMixin
+
class CertificateVerificationError < RuntimeError
attr_accessor :error_code
@@ -25,10 +27,10 @@ class Puppet::SSL::CertificateAuthority
end
end
- class << self
- include Puppet::Util::Cacher
-
- cached_attr(:singleton_instance) { new }
+ def self.singleton_instance
+ synchronize do
+ @singleton_instance ||= new
+ end
end
def self.ca?
diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
index b9215effd..08a8ace1f 100644
--- a/lib/puppet/ssl/host.rb
+++ b/lib/puppet/ssl/host.rb
@@ -4,7 +4,6 @@ require 'puppet/ssl/key'
require 'puppet/ssl/certificate'
require 'puppet/ssl/certificate_request'
require 'puppet/ssl/certificate_revocation_list'
-require 'puppet/util/cacher'
# The class that manages all aspects of our SSL certificates --
# private keys, public keys, requests, etc.
@@ -27,14 +26,10 @@ class Puppet::SSL::Host
# This accessor is used in instances for indirector requests to hold desired state
attr_accessor :desired_state
- class << self
- include Puppet::Util::Cacher
-
- cached_attr(:localhost) do
- result = new
- result.generate unless result.certificate
- result.key # Make sure it's read in
- result
+ def self.localhost
+ @localhost ||= new.tap do |l|
+ l.generate unless l.certificate
+ l.key # Make sure it's read in
end
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 15f340f55..963b925bf 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -9,7 +9,6 @@ require 'puppet/metatype/manager'
require 'puppet/util/errors'
require 'puppet/util/log_paths'
require 'puppet/util/logging'
-require 'puppet/util/cacher'
require 'puppet/file_collection/lookup'
require 'puppet/util/tagging'
@@ -21,7 +20,6 @@ class Type
include Puppet::Util::Errors
include Puppet::Util::LogPaths
include Puppet::Util::Logging
- include Puppet::Util::Cacher
include Puppet::FileCollection::Lookup
include Puppet::Util::Tagging
@@ -469,12 +467,6 @@ class Type
Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options))
end
- # Let the catalog determine whether a given cached value is
- # still valid or has expired.
- def expirer
- catalog
- end
-
# retrieve the 'should' value for a specified property
def should(name)
name = attr_alias(name)
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 8ab12ca2f..988416ab5 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -394,7 +394,7 @@ Puppet::Type.newtype(:file) do
@parameters.each do |name, param|
param.flush if param.respond_to?(:flush)
end
- @stat = nil
+ @stat = :needs_stat
end
def initialize(hash)
@@ -413,7 +413,7 @@ Puppet::Type.newtype(:file) do
end
end
- @stat = nil
+ @stat = :needs_stat
end
# Configure discovered resources to be purged.
@@ -623,7 +623,7 @@ Puppet::Type.newtype(:file) do
else
self.fail "Could not back up files of type #{s.ftype}"
end
- expire
+ @stat = :needs_stat
end
def retrieve
@@ -674,22 +674,27 @@ Puppet::Type.newtype(:file) do
# use either 'stat' or 'lstat', and we expect the properties to use the
# resulting stat object accordingly (mostly by testing the 'ftype'
# value).
- cached_attr(:stat) do
+ #
+ # We use the initial value :needs_stat to ensure we only stat the file once,
+ # but can also keep track of a failed stat (@stat == nil). This also allows
+ # us to re-stat on demand by setting @stat = :needs_stat.
+ def stat
+ return @stat unless @stat == :needs_stat
+
method = :stat
# Files are the only types that support links
if (self.class.name == :file and self[:links] != :follow) or self.class.name == :tidy
method = :lstat
end
- path = self[:path]
- begin
+ @stat = begin
::File.send(method, self[:path])
rescue Errno::ENOENT => error
- return nil
+ nil
rescue Errno::EACCES => error
warning "Could not stat; permission denied"
- return nil
+ nil
end
end
@@ -776,7 +781,7 @@ Puppet::Type.newtype(:file) do
next unless [:mode, :owner, :group, :seluser, :selrole, :seltype, :selrange].include?(thing.name)
# Make sure we get a new stat objct
- expire
+ @stat = :needs_stat
currentvalue = thing.retrieve
thing.sync unless thing.safe_insync?(currentvalue)
end
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 49e885865..222b85dbb 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -95,13 +95,14 @@ module Puppet
end
# Look up (if necessary) and return remote content.
- cached_attr(:content) do
+ def content
+ return @content if @content
raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)
fail "Could not find any content at %s" % metadata.source
end
- tmp.content
+ @content = tmp.content
end
# Copy the values from the source to the resource. Yay.
@@ -137,25 +138,28 @@ module Puppet
! (metadata.nil? or metadata.ftype.nil?)
end
+ attr_writer :metadata
+
# Provide, and retrieve if necessary, the metadata for this file. Fail
# if we can't find data about this host, and fail if there are any
# problems in our query.
- cached_attr(:metadata) do
+ def metadata
+ return @metadata if @metadata
return nil unless value
result = nil
value.each do |source|
begin
if data = Puppet::FileServing::Metadata.indirection.find(source)
- result = data
- result.source = source
+ @metadata = data
+ @metadata.source = source
break
end
rescue => detail
fail detail, "Could not retrieve file metadata for #{source}: #{detail}"
end
end
- fail "Could not retrieve information from source(s) #{value.join(", ")}" unless result
- result
+ fail "Could not retrieve information from source(s) #{value.join(", ")}" unless @metadata
+ @metadata
end
def local?
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index 6537a4a4e..2e8710ab1 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -1,5 +1,4 @@
require 'puppet/util/warnings'
-require 'puppet/util/cacher'
# Autoload paths, either based on names or all at once.
class Puppet::Util::Autoload
@@ -7,7 +6,6 @@ class Puppet::Util::Autoload
include Puppet::Util
include Puppet::Util::Warnings
- include Puppet::Util::Cacher
include Puppet::Util::Autoload::FileCache
@autoloaders = {}
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb
index 3dddec0d4..136c9973e 100644
--- a/lib/puppet/util/cacher.rb
+++ b/lib/puppet/util/cacher.rb
@@ -1,25 +1,6 @@
require 'monitor'
module Puppet::Util::Cacher
- module Expirer
- attr_reader :timestamp
-
- # Cause all cached values to be considered expired.
- def expire
- @timestamp = Time.now
- end
-
- # Is the provided timestamp earlier than our expiration timestamp?
- # If it is, then the associated value is expired.
- def dependent_data_expired?(ts)
- return false unless timestamp
-
- timestamp > ts
- end
- end
-
- extend Expirer
-
# Our module has been extended in a class; we can only add the Instance methods,
# which become *class* methods in the class.
def self.extended(other)
@@ -40,27 +21,26 @@ module Puppet::Util::Cacher
module ClassMethods
# Provide a means of defining an attribute whose value will be cached.
# Must provide a block capable of defining the value if it's flushed..
- def cached_attr(name, options = {}, &block)
+ def cached_attr(name, ttl, &block)
init_method = "init_#{name}"
define_method(init_method, &block)
+ set_attr_ttl(name, ttl)
+
define_method(name) do
cached_value(name)
end
define_method(name.to_s + "=") do |value|
# Make sure the cache timestamp is set
- cache_timestamp
- value_cache.synchronize { value_cache[name] = value }
- end
-
- if ttl = options[:ttl]
- set_attr_ttl(name, ttl)
+ value_cache.synchronize do
+ value_cache[name] = value
+ set_expiration(name)
+ end
end
end
def attr_ttl(name)
- return nil unless @attr_ttls
@attr_ttls[name]
end
@@ -72,57 +52,25 @@ module Puppet::Util::Cacher
# Methods that get added to instances.
module InstanceMethods
-
- def expire
- # Only expire if we have an expirer. This is
- # mostly so that we can comfortably handle cases
- # like Puppet::Type instances, which use their
- # catalog as their expirer, and they often don't
- # have a catalog.
- if e = expirer
- e.expire
- end
- end
-
- def expirer
- Puppet::Util::Cacher
- end
-
private
- def cache_timestamp
- @cache_timestamp ||= Time.now
- end
-
def cached_value(name)
value_cache.synchronize do
- # Allow a nil expirer, in which case we regenerate the value every time.
- if expired_by_expirer?(name)
- value_cache.clear
- @cache_timestamp = Time.now
- elsif expired_by_ttl?(name)
- value_cache.delete(name)
+ if value_cache[name].nil? or expired_by_ttl?(name)
+ value_cache[name] = send("init_#{name}")
+ set_expiration(name)
end
- value_cache[name] = send("init_#{name}") unless value_cache.include?(name)
value_cache[name]
end
end
- def expired_by_expirer?(name)
- if expirer.nil?
- return true unless self.class.attr_ttl(name)
- end
- expirer.dependent_data_expired?(cache_timestamp)
- end
-
def expired_by_ttl?(name)
- return false unless self.class.respond_to?(:attr_ttl)
- return false unless ttl = self.class.attr_ttl(name)
-
- @ttl_timestamps ||= {}
- @ttl_timestamps[name] ||= Time.now
+ @attr_expirations[name] < Time.now
+ end
- (Time.now - @ttl_timestamps[name]) > ttl
+ def set_expiration(name)
+ @attr_expirations ||= {}
+ @attr_expirations[name] = Time.now + self.class.attr_ttl(name)
end
def value_cache
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 4559e9af3..caaf61b7b 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -2,13 +2,11 @@ require 'puppet'
require 'sync'
require 'getoptlong'
require 'puppet/external/event-loop'
-require 'puppet/util/cacher'
require 'puppet/util/loadedfile'
# The class for handling configuration files.
class Puppet::Util::Settings
include Enumerable
- include Puppet::Util::Cacher
require 'puppet/util/settings/setting'
require 'puppet/util/settings/file_setting'
@@ -401,11 +399,10 @@ class Puppet::Util::Settings
}
end
- # Cache this in an easily clearable way, since we were
- # having trouble cleaning it up after tests.
- cached_attr(:file) do
+ def file
+ return @file if @file
if path = self[:config] and FileTest.exist?(path)
- Puppet::Util::LoadedFile.new(path)
+ @file = Puppet::Util::LoadedFile.new(path)
end
end
diff --git a/spec/integration/file_serving/content_spec.rb b/spec/integration/file_serving/content_spec.rb
index a95ddc520..e82b726fe 100755
--- a/spec/integration/file_serving/content_spec.rb
+++ b/spec/integration/file_serving/content_spec.rb
@@ -15,6 +15,4 @@ describe Puppet::FileServing::Content, " when finding files" do
@test_class = Puppet::FileServing::Content
@indirection = Puppet::FileServing::Content.indirection
end
-
- after { Puppet::Util::Cacher.expire }
end
diff --git a/spec/integration/file_serving/metadata_spec.rb b/spec/integration/file_serving/metadata_spec.rb
index ba7d3311f..8b4d53d6b 100755
--- a/spec/integration/file_serving/metadata_spec.rb
+++ b/spec/integration/file_serving/metadata_spec.rb
@@ -16,6 +16,4 @@ describe Puppet::FileServing::Metadata, " when finding files" do
@test_class = Puppet::FileServing::Metadata
@indirection = Puppet::FileServing::Metadata.indirection
end
-
- after { Puppet::Util::Cacher.expire }
end
diff --git a/spec/integration/indirector/file_content/file_server_spec.rb b/spec/integration/indirector/file_content/file_server_spec.rb
index 2a8c134a4..86b75006a 100755
--- a/spec/integration/indirector/file_content/file_server_spec.rb
+++ b/spec/integration/indirector/file_content/file_server_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::Indirector::FileContent::FileServer, " when finding files", :fa
before do
@terminus = Puppet::Indirector::FileContent::FileServer.new
@test_class = Puppet::FileServing::Content
+ Puppet::FileServing::Configuration.instance_variable_set(:@configuration, nil)
end
it "should find plugin file content in the environment specified in the request" do
@@ -62,7 +63,6 @@ describe Puppet::Indirector::FileContent::FileServer, " when finding files", :fa
end
it "should find file content in files when node name expansions are used" do
- Puppet::Util::Cacher.expire
FileTest.stubs(:exists?).returns true
FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true)
diff --git a/spec/integration/network/server/webrick_spec.rb b/spec/integration/network/server/webrick_spec.rb
index 81c35af4f..2390fcab1 100755
--- a/spec/integration/network/server/webrick_spec.rb
+++ b/spec/integration/network/server/webrick_spec.rb
@@ -32,7 +32,6 @@ describe Puppet::Network::Server do
system("rm -rf #{@dir}")
Puppet::SSL::Host.ca_location = :none
- Puppet::Util::Cacher.expire
end
describe "before listening" do
diff --git a/spec/integration/node/facts_spec.rb b/spec/integration/node/facts_spec.rb
index f54d7f9aa..4ec4bc821 100755
--- a/spec/integration/node/facts_spec.rb
+++ b/spec/integration/node/facts_spec.rb
@@ -7,8 +7,6 @@ require 'spec_helper'
describe Puppet::Node::Facts do
describe "when using the indirector" do
- after { Puppet::Util::Cacher.expire }
-
it "should expire any cached node instances when it is saved" do
Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml
diff --git a/spec/integration/resource/catalog_spec.rb b/spec/integration/resource/catalog_spec.rb
index 41a475d98..ae15ee453 100755
--- a/spec/integration/resource/catalog_spec.rb
+++ b/spec/integration/resource/catalog_spec.rb
@@ -13,7 +13,6 @@ describe Puppet::Resource::Catalog do
end
describe "when using the indirector" do
- after { Puppet::Util::Cacher.expire }
before do
# This is so the tests work w/out networking.
Facter.stubs(:to_hash).returns({"hostname" => "foo.domain.com"})
diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb
index c6ff58ed0..68b2401fb 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -29,8 +29,6 @@ describe Puppet::SSL::CertificateAuthority, :fails_on_windows => true do
system("rm -rf #{@dir}")
Puppet.settings.clear
- Puppet::Util::Cacher.expire
-
Puppet::SSL::CertificateAuthority.instance_variable_set("@instance", nil)
}
diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb
index 31bb48d66..07a4d9269 100755
--- a/spec/integration/ssl/certificate_request_spec.rb
+++ b/spec/integration/ssl/certificate_request_spec.rb
@@ -28,14 +28,14 @@ describe Puppet::SSL::CertificateRequest, :fails_on_windows => true do
@csr = Puppet::SSL::CertificateRequest.new("luke.madstop.com")
@key = OpenSSL::PKey::RSA.new(512)
+
+ # This is necessary so the terminus instances don't lie around.
+ Puppet::SSL::CertificateRequest.indirection.termini.clear
end
after do
system("rm -rf #{@dir}")
Puppet.settings.clear
-
- # This is necessary so the terminus instances don't lie around.
- Puppet::Util::Cacher.expire
end
it "should be able to generate CSRs" do
diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb b/spec/integration/ssl/certificate_revocation_list_spec.rb
index 95f0e6314..5d2b102f5 100755
--- a/spec/integration/ssl/certificate_revocation_list_spec.rb
+++ b/spec/integration/ssl/certificate_revocation_list_spec.rb
@@ -29,7 +29,7 @@ describe Puppet::SSL::CertificateRevocationList, :fails_on_windows => true do
Puppet.settings.clear
# This is necessary so the terminus instances don't lie around.
- Puppet::Util::Cacher.expire
+ Puppet::SSL::Host.indirection.termini.clear
}
it "should be able to read in written out CRLs with no revoked certificates" do
diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb
index 2da5bcfe3..53ff88ea4 100755
--- a/spec/integration/ssl/host_spec.rb
+++ b/spec/integration/ssl/host_spec.rb
@@ -30,7 +30,6 @@ describe Puppet::SSL::Host, :fails_on_windows => true do
system("rm -rf #{@dir}")
Puppet.settings.clear
- Puppet::Util::Cacher.expire
}
it "should be considered a CA host if its name is equal to 'ca'" do
diff --git a/spec/integration/transaction/report_spec.rb b/spec/integration/transaction/report_spec.rb
index 183d93f76..315c0c099 100755
--- a/spec/integration/transaction/report_spec.rb
+++ b/spec/integration/transaction/report_spec.rb
@@ -8,7 +8,6 @@ require 'spec_helper'
describe Puppet::Transaction::Report do
describe "when using the indirector" do
after do
- Puppet::Util::Cacher.expire
Puppet.settings.stubs(:use)
end
diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb
index f59169382..88ed47ebb 100755
--- a/spec/shared_behaviours/file_server_terminus.rb
+++ b/spec/shared_behaviours/file_server_terminus.rb
@@ -7,7 +7,7 @@ shared_examples_for "Puppet::Indirector::FileServerTerminus" do
# This only works if the shared behaviour is included before
# the 'before' block in the including context.
before do
- Puppet::Util::Cacher.expire
+ Puppet::FileServing::Configuration.instance_variable_set(:@configuration, nil)
FileTest.stubs(:exists?).returns true
FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true)
diff --git a/spec/unit/file_serving/configuration_spec.rb b/spec/unit/file_serving/configuration_spec.rb
index ed8663853..a1546c987 100755
--- a/spec/unit/file_serving/configuration_spec.rb
+++ b/spec/unit/file_serving/configuration_spec.rb
@@ -3,26 +3,6 @@ require 'spec_helper'
require 'puppet/file_serving/configuration'
-describe Puppet::FileServing::Configuration, :fails_on_windows => true do
- it "should make :new a private method" do
- proc { Puppet::FileServing::Configuration.new }.should raise_error
- end
-
- it "should return the same configuration each time :create is called" do
- Puppet::FileServing::Configuration.create.should equal(Puppet::FileServing::Configuration.create)
- end
-
- it "should have a method for removing the current configuration instance" do
- old = Puppet::FileServing::Configuration.create
- Puppet::Util::Cacher.expire
- Puppet::FileServing::Configuration.create.should_not equal(old)
- end
-
- after do
- Puppet::Util::Cacher.expire
- end
-end
-
describe Puppet::FileServing::Configuration do
include PuppetSpec::Files
@@ -33,14 +13,22 @@ describe Puppet::FileServing::Configuration do
end
after :each do
- Puppet::Util::Cacher.expire
+ Puppet::FileServing::Configuration.instance_variable_set(:@configuration, nil)
+ end
+
+ it "should make :new a private method" do
+ proc { Puppet::FileServing::Configuration.new }.should raise_error
+ end
+
+ it "should return the same configuration each time 'configuration' is called" do
+ Puppet::FileServing::Configuration.configuration.should equal(Puppet::FileServing::Configuration.configuration)
end
describe "when initializing" do
it "should work without a configuration file" do
FileTest.stubs(:exists?).with(@path).returns(false)
- proc { Puppet::FileServing::Configuration.create }.should_not raise_error
+ proc { Puppet::FileServing::Configuration.configuration }.should_not raise_error
end
it "should parse the configuration file if present" do
@@ -48,11 +36,11 @@ describe Puppet::FileServing::Configuration do
@parser = mock 'parser'
@parser.expects(:parse).returns({})
Puppet::FileServing::Configuration::Parser.stubs(:new).returns(@parser)
- Puppet::FileServing::Configuration.create
+ Puppet::FileServing::Configuration.configuration
end
it "should determine the path to the configuration file from the Puppet settings" do
- Puppet::FileServing::Configuration.create
+ Puppet::FileServing::Configuration.configuration
end
end
@@ -66,18 +54,18 @@ describe Puppet::FileServing::Configuration do
it "should set the mount list to the results of parsing" do
@parser.expects(:parse).returns("one" => mock("mount"))
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
config.mounted?("one").should be_true
end
it "should not raise exceptions" do
@parser.expects(:parse).raises(ArgumentError)
- proc { Puppet::FileServing::Configuration.create }.should_not raise_error
+ proc { Puppet::FileServing::Configuration.configuration }.should_not raise_error
end
it "should replace the existing mount list with the results of reparsing" do
@parser.expects(:parse).returns("one" => mock("mount"))
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
config.mounted?("one").should be_true
# Now parse again
@parser.expects(:parse).returns("two" => mock('other'))
@@ -89,7 +77,7 @@ describe Puppet::FileServing::Configuration do
it "should not replace the mount list until the file is entirely parsed successfully" do
@parser.expects(:parse).returns("one" => mock("mount"))
@parser.expects(:parse).raises(ArgumentError)
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
# Now parse again, so the exception gets thrown
config.send(:readconfig, false)
config.mounted?("one").should be_true
@@ -97,7 +85,7 @@ describe Puppet::FileServing::Configuration do
it "should add modules and plugins mounts even if the file does not exist" do
FileTest.expects(:exists?).returns false # the file doesn't exist
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
config.mounted?("modules").should be_true
config.mounted?("plugins").should be_true
end
@@ -112,7 +100,7 @@ describe Puppet::FileServing::Configuration do
Puppet::FileServing::Mount::Plugins.stubs(:new).returns(plugins)
plugins.expects(:allow).with('*')
- Puppet::FileServing::Configuration.create
+ Puppet::FileServing::Configuration.configuration
end
it "should not allow access from all to modules and plugins if the fileserver.conf provided some rules" do
@@ -126,13 +114,13 @@ describe Puppet::FileServing::Configuration do
Puppet::FileServing::Mount::Plugins.stubs(:new).returns(plugins)
plugins.expects(:allow).with('*').never
- Puppet::FileServing::Configuration.create
+ Puppet::FileServing::Configuration.configuration
end
it "should add modules and plugins mounts even if they are not returned by the parser" do
@parser.expects(:parse).returns("one" => mock("mount"))
FileTest.expects(:exists?).returns true # the file doesn't exist
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
config.mounted?("modules").should be_true
config.mounted?("plugins").should be_true
end
@@ -140,13 +128,13 @@ describe Puppet::FileServing::Configuration do
describe "when finding the specified mount" do
it "should choose the named mount if one exists" do
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
config.expects(:mounts).returns("one" => "foo")
config.find_mount("one", mock('env')).should == "foo"
end
it "should use the provided environment to find a matching module if the named module cannot be found" do
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
mod = mock 'module'
env = mock 'environment'
@@ -159,7 +147,7 @@ describe Puppet::FileServing::Configuration do
end
it "should return nil if there is no such named mount and no module with the same name exists" do
- config = Puppet::FileServing::Configuration.create
+ config = Puppet::FileServing::Configuration.configuration
env = mock 'environment'
env.expects(:module).with("foo").returns nil
@@ -172,7 +160,7 @@ describe Puppet::FileServing::Configuration do
describe "when finding the mount name and relative path in a request key" do
before do
- @config = Puppet::FileServing::Configuration.create
+ @config = Puppet::FileServing::Configuration.configuration
@config.stubs(:find_mount)
@request = stub 'request', :key => "foo/bar/baz", :options => {}, :node => nil, :environment => mock("env")
diff --git a/spec/unit/file_serving/mount/file_spec.rb b/spec/unit/file_serving/mount/file_spec.rb
index 70c804abd..1ee004c10 100755
--- a/spec/unit/file_serving/mount/file_spec.rb
+++ b/spec/unit/file_serving/mount/file_spec.rb
@@ -10,12 +10,6 @@ module FileServingMountTesting
end
describe Puppet::FileServing::Mount::File do
- it "should provide a method for clearing its cached host information" do
- old = Puppet::FileServing::Mount::File.localmap
- Puppet::Util::Cacher.expire
- Puppet::FileServing::Mount::File.localmap.should_not equal(old)
- end
-
it "should be invalid if it does not have a path" do
lambda { Puppet::FileServing::Mount::File.new("foo").validate }.should raise_error(ArgumentError)
end
@@ -27,169 +21,169 @@ describe Puppet::FileServing::Mount::File do
mount.path = "/foo"
lambda { mount.validate }.should_not raise_error(ArgumentError)
end
-end
-
-describe Puppet::FileServing::Mount::File, " when setting the path" do
- before do
- @mount = Puppet::FileServing::Mount::File.new("test")
- @dir = "/this/path/does/not/exist"
- end
-
- it "should fail if the path is not a directory" do
- FileTest.expects(:directory?).returns(false)
- proc { @mount.path = @dir }.should raise_error(ArgumentError)
- end
-
- it "should fail if the path is not readable" do
- FileTest.expects(:directory?).returns(true)
- FileTest.expects(:readable?).returns(false)
- proc { @mount.path = @dir }.should raise_error(ArgumentError)
- end
-end
-
-describe Puppet::FileServing::Mount::File, " when substituting hostnames and ip addresses into file paths" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @host = "host.domain.com"
- end
-
- it "should replace incidences of %h in the path with the client's short name" do
- @mount.path = "/dir/%h/yay"
- @mount.path(@host).should == "/dir/host/yay"
- end
-
- it "should replace incidences of %H in the path with the client's fully qualified name" do
- @mount.path = "/dir/%H/yay"
- @mount.path(@host).should == "/dir/host.domain.com/yay"
- end
-
- it "should replace incidences of %d in the path with the client's domain name" do
- @mount.path = "/dir/%d/yay"
- @mount.path(@host).should == "/dir/domain.com/yay"
- end
-
- it "should perform all necessary replacements" do
- @mount.path = "/%h/%d/%H"
- @mount.path(@host).should == "/host/domain.com/host.domain.com"
- end
-
- it "should use local host information if no client data is provided" do
- stub_facter("myhost.mydomain.com")
- @mount.path = "/%h/%d/%H"
- @mount.path.should == "/myhost/mydomain.com/myhost.mydomain.com"
- end
-
- after do
- Puppet::Util::Cacher.expire
- end
-end
-
-describe Puppet::FileServing::Mount::File, "when determining the complete file path" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
- end
-
- it "should return nil if the file is absent" do
- FileTest.stubs(:exist?).returns(false)
- @mount.complete_path("/my/path", nil).should be_nil
- end
-
- it "should write a log message if the file is absent" do
- FileTest.stubs(:exist?).returns(false)
-
- Puppet.expects(:info).with("File does not exist or is not accessible: /mount/my/path")
-
- @mount.complete_path("/my/path", nil)
- end
-
- it "should return the file path if the file is present" do
- FileTest.stubs(:exist?).with("/my/path").returns(true)
- @mount.complete_path("/my/path", nil).should == "/mount/my/path"
- end
-
- it "should treat a nil file name as the path to the mount itself" do
- FileTest.stubs(:exist?).returns(true)
- @mount.complete_path(nil, nil).should == "/mount"
- end
-
- it "should use the client host name if provided in the options" do
- @mount.path = "/mount/%h"
- @mount.complete_path("/my/path", @host).should == "/mount/host/my/path"
- end
-
- it "should perform replacements on the base path" do
- @mount.path = "/blah/%h"
- @mount.complete_path("/my/stuff", @host).should == "/blah/host/my/stuff"
- end
-
- it "should not perform replacements on the per-file path" do
- @mount.path = "/blah"
- @mount.complete_path("/%h/stuff", @host).should == "/blah/%h/stuff"
- end
-
- it "should look for files relative to its base directory" do
- @mount.complete_path("/my/stuff", @host).should == "/mount/my/stuff"
- end
-end
-
-describe Puppet::FileServing::Mount::File, "when finding files" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
-
- @request = stub 'request', :node => "foo"
- end
-
- it "should return the results of the complete file path" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
- @mount.find("/my/path", @request).should == "eh"
- end
-end
-
-describe Puppet::FileServing::Mount::File, "when searching for files" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
-
- @request = stub 'request', :node => "foo"
- end
-
- it "should return the results of the complete file path as an array" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
- @mount.search("/my/path", @request).should == ["eh"]
- end
- it "should return nil if the complete path is nil" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns nil
- @mount.search("/my/path", @request).should be_nil
+ describe "when setting the path" do
+ before do
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @dir = "/this/path/does/not/exist"
+ end
+
+ it "should fail if the path is not a directory" do
+ FileTest.expects(:directory?).returns(false)
+ proc { @mount.path = @dir }.should raise_error(ArgumentError)
+ end
+
+ it "should fail if the path is not readable" do
+ FileTest.expects(:directory?).returns(true)
+ FileTest.expects(:readable?).returns(false)
+ proc { @mount.path = @dir }.should raise_error(ArgumentError)
+ end
+ end
+
+ describe "when substituting hostnames and ip addresses into file paths" do
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @host = "host.domain.com"
+ end
+
+ after :each do
+ Puppet::FileServing::Mount::File.instance_variable_set(:@localmap, nil)
+ end
+
+ it "should replace incidences of %h in the path with the client's short name" do
+ @mount.path = "/dir/%h/yay"
+ @mount.path(@host).should == "/dir/host/yay"
+ end
+
+ it "should replace incidences of %H in the path with the client's fully qualified name" do
+ @mount.path = "/dir/%H/yay"
+ @mount.path(@host).should == "/dir/host.domain.com/yay"
+ end
+
+ it "should replace incidences of %d in the path with the client's domain name" do
+ @mount.path = "/dir/%d/yay"
+ @mount.path(@host).should == "/dir/domain.com/yay"
+ end
+
+ it "should perform all necessary replacements" do
+ @mount.path = "/%h/%d/%H"
+ @mount.path(@host).should == "/host/domain.com/host.domain.com"
+ end
+
+ it "should use local host information if no client data is provided" do
+ stub_facter("myhost.mydomain.com")
+ @mount.path = "/%h/%d/%H"
+ @mount.path.should == "/myhost/mydomain.com/myhost.mydomain.com"
+ end
+ end
+
+ describe "when determining the complete file path" do
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+ end
+
+ it "should return nil if the file is absent" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.complete_path("/my/path", nil).should be_nil
+ end
+
+ it "should write a log message if the file is absent" do
+ FileTest.stubs(:exist?).returns(false)
+
+ Puppet.expects(:info).with("File does not exist or is not accessible: /mount/my/path")
+
+ @mount.complete_path("/my/path", nil)
+ end
+
+ it "should return the file path if the file is present" do
+ FileTest.stubs(:exist?).with("/my/path").returns(true)
+ @mount.complete_path("/my/path", nil).should == "/mount/my/path"
+ end
+
+ it "should treat a nil file name as the path to the mount itself" do
+ FileTest.stubs(:exist?).returns(true)
+ @mount.complete_path(nil, nil).should == "/mount"
+ end
+
+ it "should use the client host name if provided in the options" do
+ @mount.path = "/mount/%h"
+ @mount.complete_path("/my/path", @host).should == "/mount/host/my/path"
+ end
+
+ it "should perform replacements on the base path" do
+ @mount.path = "/blah/%h"
+ @mount.complete_path("/my/stuff", @host).should == "/blah/host/my/stuff"
+ end
+
+ it "should not perform replacements on the per-file path" do
+ @mount.path = "/blah"
+ @mount.complete_path("/%h/stuff", @host).should == "/blah/%h/stuff"
+ end
+
+ it "should look for files relative to its base directory" do
+ @mount.complete_path("/my/stuff", @host).should == "/mount/my/stuff"
+ end
+ end
+
+ describe "when finding files" do
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+
+ @request = stub 'request', :node => "foo"
+ end
+
+ it "should return the results of the complete file path" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
+ @mount.find("/my/path", @request).should == "eh"
+ end
+ end
+
+ describe "when searching for files" do
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+
+ @request = stub 'request', :node => "foo"
+ end
+
+ it "should return the results of the complete file path as an array" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
+ @mount.search("/my/path", @request).should == ["eh"]
+ end
+
+ it "should return nil if the complete path is nil" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns nil
+ @mount.search("/my/path", @request).should be_nil
+ end
end
end
diff --git a/spec/unit/indirector/file_server_spec.rb b/spec/unit/indirector/file_server_spec.rb
index 6df715fb1..96fe101d5 100755
--- a/spec/unit/indirector/file_server_spec.rb
+++ b/spec/unit/indirector/file_server_spec.rb
@@ -27,7 +27,7 @@ describe Puppet::Indirector::FileServer do
@uri = "puppet://host/my/local/file"
@configuration = mock 'configuration'
- Puppet::FileServing::Configuration.stubs(:create).returns(@configuration)
+ Puppet::FileServing::Configuration.stubs(:configuration).returns(@configuration)
@request = Puppet::Indirector::Request.new(:myind, :mymethod, @uri, :environment => "myenv")
end
diff --git a/spec/unit/indirector/indirection_spec.rb b/spec/unit/indirector/indirection_spec.rb
index 4bbc855b1..c33fdf165 100755
--- a/spec/unit/indirector/indirection_spec.rb
+++ b/spec/unit/indirector/indirection_spec.rb
@@ -102,9 +102,6 @@ shared_examples_for "Delegation Authorizer" do
end
describe Puppet::Indirector::Indirection do
- after do
- Puppet::Util::Cacher.expire
- end
describe "when initializing" do
# (LAK) I've no idea how to test this, really.
it "should store a reference to itself before it consumes its options" do
@@ -643,7 +640,6 @@ describe Puppet::Indirector::Indirection do
after :each do
@indirection.delete
- Puppet::Util::Cacher.expire
end
end
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb
index 144e82e0c..f3772749a 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -1,6 +1,8 @@
#!/usr/bin/env rspec
require 'spec_helper'
+require 'tmpdir'
+
require 'puppet/node/environment'
require 'puppet/util/execution'
@@ -10,10 +12,6 @@ describe Puppet::Node::Environment do
Puppet::Node::Environment.clear
end
- it "should include the Cacher module" do
- Puppet::Node::Environment.ancestors.should be_include(Puppet::Util::Cacher)
- end
-
it "should use the filetimeout for the ttl for the modulepath" do
Puppet::Node::Environment.attr_ttl(:modulepath).should == Integer(Puppet[:filetimeout])
end
@@ -22,10 +20,6 @@ describe Puppet::Node::Environment do
Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
end
- it "should use the filetimeout for the ttl for the manifestdir" do
- Puppet::Node::Environment.attr_ttl(:manifestdir).should == Integer(Puppet[:filetimeout])
- end
-
it "should use the default environment if no name is provided while initializing an environment" do
Puppet.settings.expects(:value).with(:environment).returns("one")
Puppet::Node::Environment.new.name.should == :one
@@ -109,27 +103,15 @@ describe Puppet::Node::Environment do
end
end
- [:modulepath, :manifestdir].each do |setting|
- it "should validate the #{setting} directories" do
- path = %w{/one /two}.join(File::PATH_SEPARATOR)
-
- env = Puppet::Node::Environment.new("testing")
- env.stubs(:[]).with(setting).returns path
-
- env.expects(:validate_dirs).with(%w{/one /two})
-
- env.send(setting)
- end
+ it "should validate the modulepath directories" do
+ real_file = Dir.mktmpdir
+ path = %W[/one /two #{real_file}].join(File::PATH_SEPARATOR)
- it "should return the validated dirs for #{setting}" do
- path = %w{/one /two}.join(File::PATH_SEPARATOR)
+ Puppet[:modulepath] = path
- env = Puppet::Node::Environment.new("testing")
- env.stubs(:[]).with(setting).returns path
- env.stubs(:validate_dirs).returns %w{/one /two}
+ env = Puppet::Node::Environment.new("testing")
- env.send(setting).should == %w{/one /two}
- end
+ env.modulepath.should == [real_file]
end
it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index 6d2b0a7ac..b3a0f92dd 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -68,10 +68,6 @@ describe Puppet::Node::Facts, "when indirecting" do
before do
@indirection = stub 'indirection', :request => mock('request'), :name => :facts
- # We have to clear the cache so that the facts ask for our indirection stub,
- # instead of anything that might be cached.
- Puppet::Util::Cacher.expire
-
@facts = Puppet::Node::Facts.new("me", "one" => "two")
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 476b0d6e5..5f3e3b44d 100755
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -207,10 +207,6 @@ describe Puppet::Node, "when indirecting" do
it "should not have a cache class defined" do
Puppet::Node.indirection.cache_class.should be_nil
end
-
- after do
- Puppet::Util::Cacher.expire
- end
end
describe Puppet::Node, "when generating the list of names to search through" do
diff --git a/spec/unit/parameter_spec.rb b/spec/unit/parameter_spec.rb
index 04556c013..1ed211957 100755
--- a/spec/unit/parameter_spec.rb
+++ b/spec/unit/parameter_spec.rb
@@ -25,16 +25,6 @@ describe Puppet::Parameter do
@parameter.to_s.should == @parameter.name.to_s
end
- it "should be able to use cached attributes" do
- Puppet::Parameter.ancestors.should be_include(Puppet::Util::Cacher)
- end
-
- it "should use the resource catalog for expiration" do
- catalog = mock 'catalog'
- @resource.stubs(:catalog).returns catalog
- @parameter.expirer.should equal(catalog)
- end
-
[:line, :file, :version].each do |data|
it "should return its resource's #{data} as its #{data}" do
@resource.expects(data).returns "foo"
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb
index 5b914dac3..c03f05dee 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -10,23 +10,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
Puppet::Util::Storage.stubs(:store)
end
- it "should be an Expirer" do
- Puppet::Resource::Catalog.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
- end
-
- it "should always be expired if it's not applying" do
- @catalog = Puppet::Resource::Catalog.new("host")
- @catalog.expects(:applying?).returns false
- @catalog.should be_dependent_data_expired(Time.now)
- end
-
- it "should not be expired if it's applying and the timestamp is late enough" do
- @catalog = Puppet::Resource::Catalog.new("host")
- @catalog.expire
- @catalog.expects(:applying?).returns true
- @catalog.should_not be_dependent_data_expired(Time.now)
- end
-
it "should be able to write its list of classes to the class file" do
@catalog = Puppet::Resource::Catalog.new("host")
@@ -644,11 +627,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
@catalog.apply(:ignoreschedules => true)
end
- it "should expire cached data in the resources both before and after the transaction" do
- @catalog.expects(:expire).times(2)
- @catalog.apply
- end
-
describe "host catalogs" do
# super() doesn't work in the setup method for some reason
@@ -809,8 +787,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
@real_indirection = Puppet::Resource::Catalog.indirection
@indirection = stub 'indirection', :name => :catalog
-
- Puppet::Util::Cacher.expire
end
it "should use the value of the 'catalog_terminus' setting to determine its terminus class" do
@@ -829,7 +805,6 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
after do
- Puppet::Util::Cacher.expire
@real_indirection.reset_terminus_class
end
end
diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb
index 3aedfdc25..3c5780a43 100755
--- a/spec/unit/ssl/certificate_authority_spec.rb
+++ b/spec/unit/ssl/certificate_authority_spec.rb
@@ -5,7 +5,7 @@ require 'puppet/ssl/certificate_authority'
describe Puppet::SSL::CertificateAuthority do
after do
- Puppet::Util::Cacher.expire
+ Puppet::SSL::CertificateAuthority.instance_variable_set(:@singleton_instance, nil)
Puppet.settings.clearused
end
@@ -25,7 +25,7 @@ describe Puppet::SSL::CertificateAuthority do
describe "when finding an existing instance" 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[:ca] = true
Puppet.run_mode.stubs(:master?).returns true
@ca = mock('ca')
diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb
index e1680941f..f00451619 100755
--- a/spec/unit/ssl/host_spec.rb
+++ b/spec/unit/ssl/host_spec.rb
@@ -13,7 +13,7 @@ describe Puppet::SSL::Host, :fails_on_windows => true do
after do
# Cleaned out any cached localhost instance.
- Puppet::Util::Cacher.expire
+ Puppet::SSL::Host.instance_variable_set(:@localhost, nil)
Puppet::SSL::Host.ca_location = :none
end
@@ -82,16 +82,6 @@ describe Puppet::SSL::Host, :fails_on_windows => true do
Puppet::SSL::Host.localhost.should == Puppet::SSL::Host.localhost
end
- it "should be able to expire the cached instance" do
- one = stub 'host1', :certificate => "eh", :key => 'foo'
- two = stub 'host2', :certificate => "eh", :key => 'foo'
- Puppet::SSL::Host.expects(:new).times(2).returns(one).then.returns(two)
-
- Puppet::SSL::Host.localhost.should equal(one)
- Puppet::Util::Cacher.expire
- Puppet::SSL::Host.localhost.should equal(two)
- end
-
it "should be able to verify its certificate matches its key" do
Puppet::SSL::Host.new("foo").should respond_to(:certificate_matches_key?)
end
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index 033c4c740..0a6ab8b5f 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -103,10 +103,6 @@ describe Puppet::Transaction::Report do
report.expects(:host).returns "me"
report.name.should == "me"
end
-
- after do
- Puppet::Util::Cacher.expire
- end
end
describe "when computing exit status" do
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb
index 5129d1e01..c696feaf8 100755
--- a/spec/unit/type/file/source_spec.rb
+++ b/spec/unit/type/file/source_spec.rb
@@ -31,14 +31,6 @@ describe Puppet::Type.type(:file).attrclass(:source) do
end
end
- it "should have a method for retrieving its metadata" do
- source.new(:resource => @resource).must respond_to(:metadata)
- end
-
- it "should have a method for setting its metadata" do
- source.new(:resource => @resource).must respond_to(:metadata=)
- end
-
describe "when returning the metadata", :fails_on_windows => true do
before do
@metadata = stub 'metadata', :source= => nil
@@ -94,20 +86,6 @@ describe Puppet::Type.type(:file).attrclass(:source) do
lambda { @source.metadata }.should raise_error(RuntimeError)
end
-
- it "should expire the metadata appropriately" do
- expirer = stub 'expired', :dependent_data_expired? => true
-
- metadata = stub 'metadata', :source= => nil
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz).returns metadata
-
- @source = source.new(:resource => @resource, :value => [@feebooz])
- @source.metadata = "foo"
-
- @source.stubs(:expirer).returns expirer
-
- @source.metadata.should_not == "foo"
- end
end
it "should have a method for setting the desired values on the resource" do
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index 73150af48..218c626d2 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -4,10 +4,6 @@ require 'spec_helper'
describe Puppet::Type, :'fails_on_windows' => true do
include PuppetSpec::Files
- it "should include the Cacher module" do
- Puppet::Type.ancestors.should be_include(Puppet::Util::Cacher)
- end
-
it "should consider a parameter to be valid if it is a valid parameter" do
Puppet::Type.type(:mount).should be_valid_parameter(:path)
end
@@ -20,18 +16,6 @@ describe Puppet::Type, :'fails_on_windows' => true do
Puppet::Type.type(:mount).should be_valid_parameter(:noop)
end
- it "should use its catalog as its expirer" do
- catalog = Puppet::Resource::Catalog.new
- resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
- resource.catalog = catalog
- resource.expirer.should equal(catalog)
- end
-
- it "should do nothing when asked to expire when it has no catalog" do
- resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
- lambda { resource.expire }.should_not raise_error
- end
-
it "should be able to retrieve a property by name" do
resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index 100975f27..47ee54e1f 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -12,10 +12,6 @@ describe Puppet::Util::Autoload do
@autoload.stubs(:eachdir).yields "/my/dir"
end
- it "should use the Cacher module" do
- Puppet::Util::Autoload.ancestors.should be_include(Puppet::Util::Cacher)
- end
-
describe "when building the search path" do
before :each do
@dira = make_absolute('/a')
diff --git a/spec/unit/util/cacher_spec.rb b/spec/unit/util/cacher_spec.rb
index fe93afd2b..16414c858 100755
--- a/spec/unit/util/cacher_spec.rb
+++ b/spec/unit/util/cacher_spec.rb
@@ -3,182 +3,105 @@ require 'spec_helper'
require 'puppet/util/cacher'
-class ExpirerTest
- include Puppet::Util::Cacher::Expirer
-end
-
class CacheTest
- @@init_count = 0
-
- include Puppet::Util::Cacher
- cached_attr(:instance_cache) { Time.now }
-end
+ @@count = 0
-describe Puppet::Util::Cacher::Expirer do
- before do
- @expirer = ExpirerTest.new
+ def self.count
+ @@count
end
- it "should be able to test whether a timestamp is expired" do
- @expirer.should respond_to(:dependent_data_expired?)
- end
-
- it "should be able to expire all values" do
- @expirer.should respond_to(:expire)
- end
-
- it "should consider any value to be valid if it has never been expired" do
- @expirer.should_not be_dependent_data_expired(Time.now)
- end
+ include Puppet::Util::Cacher
- it "should consider any value created after expiration to be expired" do
- @expirer.expire
- @expirer.should be_dependent_data_expired(Time.now - 1)
+ cached_attr(:instance_cache, 10) do
+ @@count += 1
+ {:number => @@count}
end
end
describe Puppet::Util::Cacher do
- it "should be extended with the Expirer module" do
- Puppet::Util::Cacher.singleton_class.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
+ before :each do
+ CacheTest.set_attr_ttl(:instance_cache, 10)
+ @object = CacheTest.new
end
- it "should support defining cached attributes", :'fails_on_ruby_1.9.2' => true do
- CacheTest.methods.should be_include("cached_attr")
+ it "should return a value calculated from the provided block" do
+ @object.instance_cache.should == {:number => CacheTest.count}
end
- it "should default to the Cacher module as its expirer" do
- CacheTest.new.expirer.should equal(Puppet::Util::Cacher)
+ it "should return the cached value from the getter every time if the value is not expired" do
+ @object.instance_cache.should equal(@object.instance_cache)
end
- describe "when using cached attributes" do
- before do
- @expirer = ExpirerTest.new
- @object = CacheTest.new
+ it "should regenerate and return a new value using the provided block if the value has expired" do
+ initial = @object.instance_cache
- @object.stubs(:expirer).returns @expirer
- end
-
- it "should create a getter for the cached attribute" do
- @object.should respond_to(:instance_cache)
- end
-
- it "should return a value calculated from the provided block" do
- time = Time.now
- Time.stubs(:now).returns time
- @object.instance_cache.should equal(time)
- end
+ # Ensure the value is expired immediately
+ CacheTest.set_attr_ttl(:instance_cache, -10)
+ @object.send(:set_expiration, :instance_cache)
- it "should return the cached value from the getter every time if the value is not expired" do
- @object.instance_cache.should equal(@object.instance_cache)
- end
-
- it "should regenerate and return a new value using the provided block if the value has been expired" do
- value = @object.instance_cache
- @expirer.expire
- @object.instance_cache.should_not equal(value)
- end
+ @object.instance_cache.should_not equal(initial)
+ end
- it "should be able to trigger expiration on its expirer" do
- @expirer.expects(:expire)
- @object.expire
- end
+ it "should be able to cache false values" do
+ @object.expects(:init_instance_cache).once.returns false
+ @object.instance_cache.should be_false
+ @object.instance_cache.should be_false
+ end
- it "should do nothing when asked to expire when no expirer is available" do
- cacher = CacheTest.new
- class << cacher
- def expirer
- nil
- end
- end
- lambda { cacher.expire }.should_not raise_error
- end
+ it "should cache values again after expiration" do
+ initial = @object.instance_cache
- it "should be able to cache false values" do
- @object.expects(:init_instance_cache).returns false
- @object.instance_cache.should be_false
- @object.instance_cache.should be_false
- end
+ # Ensure the value is expired immediately
+ CacheTest.set_attr_ttl(:instance_cache, -10)
+ @object.send(:set_expiration, :instance_cache)
- it "should cache values again after expiration" do
- @object.instance_cache
- @expirer.expire
- @object.instance_cache.should equal(@object.instance_cache)
- end
+ # Reset ttl so this new value doesn't get expired
+ CacheTest.set_attr_ttl(:instance_cache, 10)
+ after_expiration = @object.instance_cache
- it "should always consider a value expired if it has no expirer" do
- @object.stubs(:expirer).returns nil
- @object.instance_cache.should_not equal(@object.instance_cache)
- end
+ after_expiration.should_not == initial
+ @object.instance_cache.should == after_expiration
+ end
- it "should allow writing of the attribute" do
- @object.should respond_to(:instance_cache=)
- end
+ it "should allow writing of the attribute" do
+ initial = @object.instance_cache
- it "should correctly configure timestamps for expiration when the cached attribute is written to" do
- @object.instance_cache = "foo"
- @expirer.expire
- @object.instance_cache.should_not == "foo"
- end
+ @object.instance_cache = "another value"
+ @object.instance_cache.should == "another value"
+ end
- it "should allow specification of a ttl for cached attributes" do
- klass = Class.new do
- include Puppet::Util::Cacher
- end
+ it "should update the expiration when the cached attribute is set manually" do
+ # Freeze time
+ now = Time.now
+ Time.stubs(:now).returns now
- klass.cached_attr(:myattr, :ttl => 5) { Time.now }
+ @object.instance_cache
- klass.attr_ttl(:myattr).should == 5
- end
+ # Set expiration to something far in the future
+ CacheTest.set_attr_ttl(:instance_cache, 60)
+ @object.send(:set_expiration, :instance_cache)
- it "should allow specification of a ttl as a string" do
- klass = Class.new do
- include Puppet::Util::Cacher
- end
+ CacheTest.set_attr_ttl(:instance_cache, 10)
- klass.cached_attr(:myattr, :ttl => "5") { Time.now }
+ @object.instance_cache = "foo"
+ @object.instance_variable_get(:@attr_expirations)[:instance_cache].should == now + 10
+ end
- klass.attr_ttl(:myattr).should == 5
+ it "should allow specification of a ttl as a string" do
+ klass = Class.new do
+ include Puppet::Util::Cacher
end
- it "should fail helpfully if the ttl cannot be converted to an integer" do
- klass = Class.new do
- include Puppet::Util::Cacher
- end
-
- lambda { klass.cached_attr(:myattr, :ttl => "yep") { Time.now } }.should raise_error(ArgumentError)
- end
+ klass.cached_attr(:myattr, "5") { 10 }
- it "should not check for a ttl expiration if the class does not support that method" do
- klass = Class.new do
- extend Puppet::Util::Cacher
- end
+ klass.attr_ttl(:myattr).should == 5
+ end
- klass.singleton_class.cached_attr(:myattr) { "eh" }
- klass.myattr
+ it "should fail helpfully if the ttl cannot be converted to an integer" do
+ klass = Class.new do
+ include Puppet::Util::Cacher
end
- it "should automatically expire cached attributes whose ttl has expired, even if no expirer is present" do
- klass = Class.new do
- def self.to_s
- "CacheTestClass"
- end
- include Puppet::Util::Cacher
- attr_accessor :value
- end
-
- klass.cached_attr(:myattr, :ttl => 5) { self.value += 1; self.value }
-
- now = Time.now
- later = Time.now + 15
-
- instance = klass.new
- instance.value = 0
- instance.myattr.should == 1
-
- Time.expects(:now).returns later
-
- # This call should get the new Time value, which should expire the old value
- instance.myattr.should == 2
- end
+ lambda { klass.cached_attr(:myattr, "yep") { 10 } }.should raise_error(ArgumentError)
end
end
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index f7cb19936..76f229c0f 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -606,16 +606,6 @@ describe Puppet::Util::Settings do
@settings.reparse
end
- it "should use a cached LoadedFile instance" do
- first = mock 'first'
- second = mock 'second'
- Puppet::Util::LoadedFile.expects(:new).times(2).with("/test/file").returns(first).then.returns(second)
-
- @settings.file.should equal(first)
- Puppet::Util::Cacher.expire
- @settings.file.should equal(second)
- end
-
it "should replace in-memory values with on-file values" do
# Init the value
text = "[main]\none = disk-init\n"
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index a60092cf7..6bae80a01 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -280,7 +280,6 @@ module PuppetTest
Puppet::Util::Storage.clear
Puppet.clear
Puppet.settings.clear
- Puppet::Util::Cacher.expire
@memoryatend = Puppet::Util.memory
diff = @memoryatend - @memoryatstart
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 4c0374a76..9326e4b38 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -16,11 +16,6 @@ class TestMaster < Test::Unit::TestCase
Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
end
- def teardown
- super
- Puppet::Util::Cacher.expire
- end
-
def test_freshness_is_always_now
now1 = mock 'now1'
Time.stubs(:now).returns(now1)
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index 9eed5d862..e1fd68921 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -11,10 +11,7 @@ class TestWebrickServer < Test::Unit::TestCase
def setup
Puppet::Util::SUIDManager.stubs(:asuser).yields
- super
- end
-
- def teardown
+ Puppet::SSL::Host.instance_variable_set(:@localhost, nil)
super
end
@@ -23,11 +20,8 @@ class TestWebrickServer < Test::Unit::TestCase
def test_basics
server = nil
assert_raise(Puppet::Error, "server succeeded with no cert") do
-
- server = Puppet::Network::HTTPServer::WEBrick.new(
-
+ server = Puppet::Network::HTTPServer::WEBrick.new(
:Port => @@port,
-
:Handlers => {
:Status => nil
}
@@ -35,11 +29,8 @@ class TestWebrickServer < Test::Unit::TestCase
end
assert_nothing_raised("Could not create simple server") do
-
- server = Puppet::Network::HTTPServer::WEBrick.new(
-
+ server = Puppet::Network::HTTPServer::WEBrick.new(
:Port => @@port,
-
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
@@ -75,11 +66,8 @@ class TestWebrickServer < Test::Unit::TestCase
client = nil
assert_nothing_raised {
-
- client = Puppet::Network::Client.status.new(
-
+ client = Puppet::Network::Client.status.new(
:Server => "localhost",
-
:Port => @@port
)
}
@@ -90,17 +78,13 @@ class TestWebrickServer < Test::Unit::TestCase
server = nil
Puppet[:certdnsnames] = "localhost"
assert_nothing_raised {
-
- server = Puppet::Network::HTTPServer::WEBrick.new(
-
+ server = Puppet::Network::HTTPServer::WEBrick.new(
:Port => @@port,
-
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
}
)
-
}
pid = fork {