summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-24 00:04:47 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit9fbb69f9d4de0e618954bc18b7501e300317022a (patch)
treeeb9ef70beb3e9938391b1bfd4d1ed4864d44c291 /spec
parent7e1e76e91579a49c07aa5cb5917a9800d59b8137 (diff)
downloadpuppet-9fbb69f9d4de0e618954bc18b7501e300317022a.tar.gz
puppet-9fbb69f9d4de0e618954bc18b7501e300317022a.tar.xz
puppet-9fbb69f9d4de0e618954bc18b7501e300317022a.zip
Adding support for only using cached catalogs
This basically allows a sysadmin to control when a client will compile a new catalog - with this option enabled, the client will use the cached catalog as long as it has one, only recompiling when run with the option disabled. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/configurer.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/unit/configurer.rb b/spec/unit/configurer.rb
index 48a197a37..6744f885d 100755
--- a/spec/unit/configurer.rb
+++ b/spec/unit/configurer.rb
@@ -292,6 +292,26 @@ describe Puppet::Configurer, "when retrieving a catalog" do
@agent.stubs(:convert_catalog).returns @catalog
end
+ describe "and configured to only retrieve a catalog from the cache" do
+ before do
+ Puppet.settings[:use_cached_catalog] = true
+ end
+
+ it "should first look in the cache for a catalog" do
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.never
+
+ @agent.retrieve_catalog.should == @catalog
+ end
+
+ it "should compile a new catalog if none is found in the cache" do
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
+
+ @agent.retrieve_catalog.should == @catalog
+ end
+ end
+
it "should use the Catalog class to get its catalog" do
Puppet::Resource::Catalog.expects(:find).returns @catalog
@@ -300,7 +320,7 @@ describe Puppet::Configurer, "when retrieving a catalog" do
it "should use its certname to retrieve the catalog" do
Facter.stubs(:value).returns "eh"
- Puppet.expects(:[]).with(:certname).returns "myhost.domain.com"
+ Puppet.settings[:certname] = "myhost.domain.com"
Puppet::Resource::Catalog.expects(:find).with { |name, options| name == "myhost.domain.com" }.returns @catalog
@agent.retrieve_catalog