diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-10-24 19:35:03 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-10-25 11:07:41 +1100 |
| commit | e8bce7a6c3d0941fb3b461d2f0487b3f249ff5f1 (patch) | |
| tree | 12c84c9fb1668708a57024debbf51fa1fd0cf9bd /spec/unit/network | |
| parent | e2ce790b57723453ac8f52e17b6c56335b64036c (diff) | |
Workaround #2668 - Compress facts so that the request size limit triggers less often
This is not the right fix, but more a hackish workaround.
Since 0.25, the facts are transmitted as GET parameters when a
node asks for a catalog. Most proxies or webserver have a size limit
which is sometimes reached. In this case the request is denied
and the node can't get its catalog.
The idea is to compress facts (some non-scientific studies show a
57% fact size decrease for an average node) when transmitting
those when asking for a catalog.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/network')
| -rwxr-xr-x | spec/unit/network/formats.rb | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/spec/unit/network/formats.rb b/spec/unit/network/formats.rb index de2e0afe3..b1ef9ec53 100755 --- a/spec/unit/network/formats.rb +++ b/spec/unit/network/formats.rb @@ -90,6 +90,91 @@ describe "Puppet Network Format" do end end + describe "base64 compressed yaml" do + before do + @yaml = Puppet::Network::FormatHandler.format(:b64_zlib_yaml) + end + + it "should have its mime type set to text/b64_zlib_yaml" do + @yaml.mime.should == "text/b64_zlib_yaml" + end + + it "should render by calling 'to_yaml' on the instance" do + instance = mock 'instance' + instance.expects(:to_yaml).returns "foo" + @yaml.render(instance) + end + + it "should fixup generated yaml on render" do + instance = mock 'instance', :to_yaml => "foo" + + @yaml.expects(:fixup).with("foo").returns "bar" + + @yaml.render(instance) + end + + it "should encode generated yaml on render" do + instance = mock 'instance', :to_yaml => "foo" + + @yaml.expects(:encode).with("foo").returns "bar" + + @yaml.render(instance).should == "bar" + end + + it "should render multiple instances by calling 'to_yaml' on the array" do + instances = [mock('instance')] + instances.expects(:to_yaml).returns "foo" + @yaml.render_multiple(instances) + end + + it "should fixup generated yaml on render" do + instances = [mock('instance')] + instances.stubs(:to_yaml).returns "foo" + + @yaml.expects(:fixup).with("foo").returns "bar" + + @yaml.render(instances) + end + + it "should encode generated yaml on render" do + instances = [mock('instance')] + instances.stubs(:to_yaml).returns "foo" + + @yaml.expects(:encode).with("foo").returns "bar" + + @yaml.render(instances).should == "bar" + end + + it "should intern by calling decode" do + text = "foo" + @yaml.expects(:decode).with("foo").returns "bar" + @yaml.intern(String, text).should == "bar" + end + + it "should intern multiples by calling 'decode'" do + text = "foo" + @yaml.expects(:decode).with("foo").returns "bar" + @yaml.intern_multiple(String, text).should == "bar" + end + + it "should decode by base64 decoding, uncompressing and Yaml loading" do + Base64.expects(:decode64).with("zorg").returns "foo" + Zlib::Inflate.expects(:inflate).with("foo").returns "baz" + YAML.expects(:load).with("baz").returns "bar" + @yaml.decode("zorg").should == "bar" + end + + it "should encode by compressing and base64 encoding" do + Zlib::Deflate.expects(:deflate).with("foo", Zlib::BEST_COMPRESSION).returns "bar" + Base64.expects(:encode64).with("bar").returns "baz" + @yaml.encode("foo").should == "baz" + end + + it "should fixup incorrect yaml to correct" do + @yaml.fixup("&id004 !ruby/object:Puppet::Relationship ?").should == "? &id004 !ruby/object:Puppet::Relationship" + end + end + it "should include a marshal format" do Puppet::Network::FormatHandler.format(:marshal).should_not be_nil end |
