diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-18 00:54:59 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-07-18 16:41:54 +1000 |
commit | d8937acb8c9b108e61330cbac703a17b2eaba9b3 (patch) | |
tree | 2e962357a87a10cd7eb76dadf752dd2b57e0c340 /spec | |
parent | a0fa09f6ee562dd1b61fe56dd4b914419d641986 (diff) | |
download | puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.tar.gz puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.tar.xz puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.zip |
You can now select the encoding format when transferring the catalog,
with 'yaml' still being the default but 'marshal' being an option.
This is because testing has shown drastic performance differences
between the two, with up to 70% of compile time being spent
in YAML code. Use the 'catalog_format' setting to choose your format,
and the setting must be set on the client.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/integration/defaults.rb | 4 | ||||
-rwxr-xr-x | spec/unit/network/client/master.rb | 96 |
2 files changed, 81 insertions, 19 deletions
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb index c506700c8..54b673a1a 100755 --- a/spec/integration/defaults.rb +++ b/spec/integration/defaults.rb @@ -40,4 +40,8 @@ describe "Puppet defaults" do Puppet.settings.element(:rundir).owner.should be_nil Puppet.settings.element(:rundir).group.should be_nil end + + it "should default to yaml as the catalog format" do + Puppet.settings[:catalog_format].should == "yaml" + end end diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb index 79ab8c86f..754fd0583 100755 --- a/spec/unit/network/client/master.rb +++ b/spec/unit/network/client/master.rb @@ -59,34 +59,92 @@ describe Puppet::Network::Client::Master, " when retrieving the catalog" do @client.getconfig end - it "should load the retrieved catalog using YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "when the catalog format is set to yaml" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "yaml" + end - config = mock 'config' - YAML.expects(:load).with("myconfig").returns(config) + it "should request a yaml-encoded catalog" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.expects(:getconfig).with { |*args| args[1] == "yaml" } - @client.stubs(:setclasses) + @client.getconfig + end - config.stubs(:classes) - config.stubs(:to_catalog).returns(config) - config.stubs(:host_config=) - config.stubs(:from_cache).returns(true) + it "should load the retrieved catalog using YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.getconfig + config = mock 'config' + YAML.expects(:load).with("myconfig").returns(config) + + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + YAML.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end - it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "from Marshal" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "marshal" + end - YAML.expects(:load).with("myconfig").raises(ArgumentError) + it "should load the retrieved catalog using Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.expects(:use_cached_config).with(true) + config = mock 'config' + Marshal.expects(:load).with("myconfig").returns(config) - @client.getconfig + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + Marshal.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end it "should set the classes.txt file with the classes listed in the retrieved catalog" do |