From ddad4455cc914862f16c2e8cae96812e244b0a1d Mon Sep 17 00:00:00 2001 From: Philip Potter Date: Thu, 12 Jul 2012 17:05:23 +0100 Subject: Make the anchor type propagate refresh events Without this patch the anchor resource does not propogate refresh events, making it difficult to subscribe to a class which has been notified by another resource. --- lib/puppet/type/anchor.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/puppet/type/anchor.rb b/lib/puppet/type/anchor.rb index 6b81732..fe1e5aa 100644 --- a/lib/puppet/type/anchor.rb +++ b/lib/puppet/type/anchor.rb @@ -38,4 +38,9 @@ Puppet::Type.newtype(:anchor) do desc "The name of the anchor resource." end + def refresh + # We don't do anything with them, but we need this to + # show that we are "refresh aware" and not break the + # chain of propagation. + end end -- cgit v1.2.3 From d2e692dce3794a57da78bb4624b182d1b379ae6a Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 11 Apr 2013 17:55:40 -0700 Subject: Add behavior example for anchor refresh propagation Without this patch we don't have a spec test to make sure the anchor resource type passes notify events along. This patch addresses the problem by using RSpec Puppet to build a catalog, apply the catalog, then pull a resource out of the transaction and make sure the resource was triggered. --- spec/classes/anchor_spec.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 spec/classes/anchor_spec.rb diff --git a/spec/classes/anchor_spec.rb b/spec/classes/anchor_spec.rb new file mode 100644 index 0000000..2dd17de --- /dev/null +++ b/spec/classes/anchor_spec.rb @@ -0,0 +1,32 @@ +require 'puppet' +require 'rspec-puppet' + +describe "anchorrefresh" do + let(:node) { 'testhost.example.com' } + let :pre_condition do + <<-ANCHORCLASS +class anchored { + anchor { 'anchored::begin': } + ~> anchor { 'anchored::end': } +} + +class anchorrefresh { + notify { 'first': } + ~> class { 'anchored': } + ~> anchor { 'final': } +} + ANCHORCLASS + end + + def apply_catalog_and_return_exec_rsrc + catalog = subject.to_ral + transaction = catalog.apply + transaction.resource_status("Anchor[final]") + end + + it 'propagates events through the anchored class' do + resource = apply_catalog_and_return_exec_rsrc + + expect(resource.restarted).to eq(true) + end +end -- cgit v1.2.3