Skip to content

Commit

Permalink
Merge branch 'feature/concurrent-checks-paramter-260'
Browse files Browse the repository at this point in the history
closes #260
  • Loading branch information
bobapple committed Mar 16, 2017
2 parents d8a995c + 296acb2 commit f07c682
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,9 @@ Enables or disables the `checker` feature.
##### `ensure`
Either `present` or `absent`. Defines if the feature `checker` should be enabled. Defaults to `present`.

##### `concurrent_checks`
The maximum number of concurrent checks. Defaults to `512`.

#### Class: `icinga2::feature::mainlog`
Enables or disables the `mainlog` feature.

Expand Down
17 changes: 14 additions & 3 deletions manifests/feature/checker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
# [*ensure*]
# Set to present enables the feature checker, absent disabled it. Defaults to present.
#
# [*concurrent_checks*]
# The maximum number of concurrent checks. Defaults to 512.
#
#
class icinga2::feature::checker(
$ensure = present,
$ensure = present,
$concurrent_checks = undef,
) {

$conf_dir = $::icinga2::params::conf_dir
Expand All @@ -18,12 +22,19 @@
validate_re($ensure, [ '^present$', '^absent$' ],
"${ensure} isn't supported. Valid values are 'present' and 'absent'.")

if $concurrent_checks { validate_integer($concurrent_checks) }

# compose attributes
$attrs = {
concurrent_checks => $concurrent_checks,
}

# create object
icinga2::object { 'icinga2::object::CheckerComponent::checker':
object_name => 'checker',
object_type => 'CheckerComponent',
attrs => {},
attrs_list => [],
attrs => delete_undef_values($attrs),
attrs_list => keys($attrs),
target => "${conf_dir}/features-available/checker.conf",
order => '10',
notify => $ensure ? {
Expand Down
33 changes: 33 additions & 0 deletions spec/classes/checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
it { is_expected.to contain_icinga2__object('icinga2::object::CheckerComponent::checker')
.with({ 'target' => '/etc/icinga2/features-available/checker.conf' }) }
end


context "#{os} with concurrent_checks => 100" do
let(:params) { {:concurrent_checks => 100} }

it { is_expected.to contain_concat__fragment('icinga2::object::CheckerComponent::checker')
.with({ 'target' => '/etc/icinga2/features-available/checker.conf' })
.with_content(/concurrent_checks = 100/) }
end


context "#{os} with concurrent_checks => foo (not a valid integer)" do
let(:params) { {:concurrent_checks => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
end

end
end

Expand Down Expand Up @@ -74,4 +91,20 @@
it { is_expected.to contain_icinga2__object('icinga2::object::CheckerComponent::checker')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/checker.conf' }) }
end


context "Windows 2012 R2 with concurrent_checks => 100" do
let(:params) { {:concurrent_checks => 100} }

it { is_expected.to contain_concat__fragment('icinga2::object::CheckerComponent::checker')
.with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/checker.conf' })
.with_content(/concurrent_checks = 100/) }
end


context "Windows 2012 R2 with concurrent_checks => foo (not a valid integer)" do
let(:params) { {:concurrent_checks => 'foo'} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
end
end

0 comments on commit f07c682

Please sign in to comment.