Skip to content

Commit

Permalink
fix broken mdadm force_service param and rename it to service_force
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed May 20, 2014
1 parent 73a1f8c commit f236b7d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
class mdadm(
$config_file_manage = $::mdadm::params::config_file_manage,
$config_file_options = {},
$force_service = false,
$service_force = false,
$service_ensure = 'running',
$service_enable = true,
$raid_check_options = {},
) inherits mdadm::params {
validate_bool($config_file_manage)
validate_hash($config_file_options)
validate_bool($force_service)
validate_bool($service_force)
validate_re($service_ensure, '^running$|^stopped$')
validate_bool($service_enable)
validate_hash($raid_check_options)

if $::force_service {
if $service_force {
$use_service_ensure = $service_ensure
$use_service_enable = $service_enable
} elsif $::mdadm_arrays {
Expand All @@ -42,8 +42,8 @@
}

class { 'mdadm::mdmonitor':
ensure => $service_ensure,
enable => $service_enable,
ensure => $use_service_ensure,
enable => $use_service_enable,
}

class { 'mdadm::raid_check':
Expand Down
41 changes: 40 additions & 1 deletion spec/unit/classes/mdadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:osfamily => 'RedHat',
:operatingsystem => 'Scientific',
:operatingsystemmajrelease => 6,
:mdadm_arrays => '/dev/md0',
}
end

Expand All @@ -38,6 +39,44 @@
end
end # no params

context 'service_force =>' do
context 'true' do
let(:params) {{ :service_force => true }}
before { facts.delete(:mdadm_arrays) }

it do
should contain_service('mdmonitor').with({
:ensure => 'running',
:hasrestart => true,
:hasstatus => true,
:enable => true,
})
end
end

context 'false' do
let(:params) {{ :service_force => false }}
before { facts.delete(:mdadm_arrays) }

it do
should contain_service('mdmonitor').with({
:ensure => 'stopped',
:hasrestart => true,
:hasstatus => true,
:enable => false,
})
end
end

context 'foo' do
let(:params) {{ :service_force => 'foo' }}

it 'should fail' do
expect { should }.to raise_error(/is not a boolean/)
end
end
end # service_force

context 'raid_check_options =>' do
context '{}' do
let(:params) {{ :raid_check_options => {} }}
Expand Down Expand Up @@ -84,7 +123,7 @@
let(:params) {{ :raid_check_options => 'some_string' }}

it 'should fail' do
expect { should }.to raise_error /is not a Hash/
expect { should }.to raise_error(/is not a Hash/)
end
end

Expand Down

0 comments on commit f236b7d

Please sign in to comment.