-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#463) Ensure sensu::plugins are managed before checks #755
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ class { '::sensu': | |
let(:title) { 'puppet:///data/plug1' } | ||
|
||
context 'defaults' do | ||
|
||
it { should contain_file('/etc/sensu/plugins/plug1').with( | ||
:source => 'puppet:///data/plug1' | ||
) } | ||
|
@@ -28,7 +27,7 @@ class { '::sensu': | |
:source => 'puppet:///data/plug1' | ||
) } | ||
end | ||
end #file | ||
end | ||
|
||
context 'url' do | ||
let(:title) { 'https://raw.githubusercontent.com/sensu/sensu-community-plugins/master/plugins/system/check-mem.sh' } | ||
|
@@ -44,7 +43,6 @@ class { '::sensu': | |
:path => '/etc/sensu/plugins/check-mem.sh', | ||
:checksum => '1d58b78e9785f893889458f8e9fe8627' | ||
) } | ||
|
||
end | ||
|
||
context 'setting params' do | ||
|
@@ -59,7 +57,6 @@ class { '::sensu': | |
:path => '/var/sensu/plugins/check-mem.sh', | ||
:checksum => '1d58b78e9785f893889458f8e9fe8627' | ||
) } | ||
|
||
end | ||
|
||
context 'new plugin should provide source' do | ||
|
@@ -74,10 +71,8 @@ class { '::sensu': | |
:path => '/var/sensu/plugins/check-puppet-last-run.rb', | ||
:source => 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb' | ||
) } | ||
|
||
end | ||
|
||
end #url | ||
end | ||
|
||
context 'directory' do | ||
let(:title) { 'puppet:///data/sensu/plugins' } | ||
|
@@ -115,7 +110,7 @@ class { '::sensu': | |
'group' => 'sensu' | ||
) } | ||
end | ||
end #directory | ||
end | ||
|
||
context 'package' do | ||
let(:title) { 'sensu-plugins' } | ||
|
@@ -162,12 +157,34 @@ class { '::sensu': | |
let(:params) { { :type => 'package', :gem_install_options => [{ '-p' => 'http://user:[email protected]:8080' }], :pkg_provider => 'gem' } } | ||
it { should contain_package('sensu-plugins').with_install_options([{ '-p' => 'http://user:[email protected]:8080' }]) } | ||
end | ||
|
||
end #package | ||
end | ||
|
||
context 'default' do | ||
let(:params) { { :type => 'unknown' } } | ||
it { expect { should raise_error(Puppet::Error) } } | ||
end #default | ||
end | ||
|
||
describe 'ordering (#463)' do | ||
let(:pre_condition) do | ||
<<-'ENDofPUPPETcode' | ||
class { '::sensu': | ||
manage_plugins_dir => false, | ||
} | ||
sensu::check { 'ntp': | ||
command => 'check_ntp_time -H pool.ntp.org -w 30 -c 60', | ||
handlers => 'default', | ||
subscribers => 'sensu-test', | ||
} | ||
ENDofPUPPETcode | ||
end | ||
let(:title) { 'puppet:///data/plug1' } | ||
describe 'notifies the sensu-client service' do | ||
let(:expected) { { notify: ['Service[sensu-client]'] } } | ||
it { is_expected.to contain_sensu__plugin(title).with(expected)} | ||
end | ||
describe 'comes before sensu checks via Anchor[plugins_before_checks]' do | ||
let(:expected) { { before: ['Anchor[plugins_before_checks]'] } } | ||
it { is_expected.to contain_sensu__plugin(title).with(expected)} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to kill off the anchor pattern in the next big refactor after the data types. Is there another way we can do this, such as using the spaceship operator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about using the spaceship operator but didn't because it's very likely some end users will have virtual or exported check resources. Collections realize resources, which would be a PITA for the end users.
This isn't the full blown anchor pattern, which is more about class containment. This is more of a lightweight, "Here's a single, well-known reference point to establish before and after."
I chatted with some people in the Puppet slack, and the best alternative to the anchor idea was https://github.com/binford2k/binford2k-manifold, but I did get some validating feedback a single anchor is reasonable in this situation and I like how simple it is to explain. All plugins are managed before the anchor, all checks are managed after the anchor, the anchor always exists in the catalog.