summaryrefslogtreecommitdiffstats
path: root/spec/integration
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-06-02 23:08:52 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-06-06 19:57:59 +1000
commit0de70b7035ebc7f00ede73098684ee5db4b2de14 (patch)
treec7e4abf18f785b4959c46c78fed697e908ed304d /spec/integration
parent7b33b6da4bdcd2263e2c63b443e9bea6fbe8d161 (diff)
downloadpuppet-0de70b7035ebc7f00ede73098684ee5db4b2de14.tar.gz
puppet-0de70b7035ebc7f00ede73098684ee5db4b2de14.tar.xz
puppet-0de70b7035ebc7f00ede73098684ee5db4b2de14.zip
Switching Queueing to using JSON instead of YAML
This provides about a 75x speedup, so it's totally worth it. The downside is that queueing requires json, but only on the server side.
Diffstat (limited to 'spec/integration')
-rwxr-xr-xspec/integration/indirector/catalog/queue.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/integration/indirector/catalog/queue.rb b/spec/integration/indirector/catalog/queue.rb
new file mode 100755
index 000000000..22f29aac3
--- /dev/null
+++ b/spec/integration/indirector/catalog/queue.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/resource/catalog'
+
+Puppet::Resource::Catalog.indirection.terminus(:queue)
+
+describe Puppet::Resource::Catalog::Queue do
+ before do
+ @catalog = Puppet::Resource::Catalog.new
+
+ @one = Puppet::Resource.new(:file, "/one")
+ @two = Puppet::Resource.new(:file, "/two")
+ @catalog.add_resource(@one, @two)
+
+ @catalog.add_edge(@one, @two)
+
+ Puppet[:trace] = true
+ end
+
+ after { Puppet.settings.clear }
+
+ it "should render catalogs to json and send them via the queue client when catalogs are saved" do
+ terminus = Puppet::Resource::Catalog.indirection.terminus(:queue)
+
+ client = mock 'client'
+ terminus.stubs(:client).returns client
+
+ client.expects(:send_message).with(:catalog, @catalog.to_json)
+
+ request = Puppet::Indirector::Request.new(:catalog, :save, "foo", :instance => @catalog)
+
+ terminus.save(request)
+ end
+
+ it "should intern catalog messages when they are passed via a subscription" do
+ client = mock 'client'
+ Puppet::Resource::Catalog::Queue.stubs(:client).returns client
+
+ json = @catalog.to_json
+
+ client.expects(:subscribe).with(:catalog).yields(json)
+
+ Puppet.expects(:err).never
+
+ result = []
+ Puppet::Resource::Catalog::Queue.subscribe do |catalog|
+ result << catalog
+ end
+
+ catalog = result.shift
+ catalog.should be_instance_of(Puppet::Resource::Catalog)
+
+ catalog.resource(:file, "/one").should be_instance_of(Puppet::Resource)
+ catalog.resource(:file, "/two").should be_instance_of(Puppet::Resource)
+ catalog.should be_edge(catalog.resource(:file, "/one"), catalog.resource(:file, "/two"))
+ end
+end