Skip to content

Commit

Permalink
Merge pull request redhat-openstack#220 from cyberious/Sles12
Browse files Browse the repository at this point in the history
Updated testing and support for sles12
  • Loading branch information
Morgan Haskel committed Nov 4, 2014
2 parents 00e30e0 + 252d5b3 commit 4fd5093
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@
if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '12'
{
$service_name = 'ntpd'
$keys_file = '/etc/ntp.keys'
} else{
$service_name = 'ntp'
$keys_file = $default_keys_file
}
$config = $default_config
$keys_file = $default_keys_file
$driftfile = '/var/lib/ntp/drift/ntp.drift'
$package_name = $default_package_name
$restrict = [
Expand Down
54 changes: 37 additions & 17 deletions spec/acceptance/ntp_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper_acceptance'
require 'specinfra'

case fact('osfamily')
when 'RedHat', 'FreeBSD', 'Linux', 'Gentoo'
Expand All @@ -14,7 +15,21 @@
servicename = 'ntp'
end
end

shared_examples 'running' do
describe service(servicename) do
if !(fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12')
it { should be_running }
it { should be_enabled }
else
# hack until we either update SpecInfra or come up with alternative
it {
output = shell('service ntpd status')
expect(output.stdout).to match(/Active\:\s+active\s+\(running\)/)
expect(output.stdout).to match(/^\s+Loaded.*enabled\)$/)
}
end
end
end
describe 'ntp::service class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
describe 'basic test' do
it 'sets up the service' do
Expand All @@ -23,10 +38,7 @@ class { 'ntp': }
}, :catch_failures => true)
end

describe service(servicename) do
it { should be_enabled }
it { should be_running }
end
it_should_behave_like 'running'
end

describe 'service parameters' do
Expand All @@ -41,29 +53,37 @@ class { 'ntp':
EOS
apply_manifest(pp, :catch_failures => true)
end

describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
it_should_behave_like 'running'
end
end

describe 'service is unmanaged' do
it 'shouldnt stop the service' do
pp = <<-EOS
describe 'service is unmanaged' do
it 'shouldnt stop the service' do
pp = <<-EOS
class { 'ntp':
service_enable => false,
service_ensure => stopped,
service_manage => false,
service_name => '#{servicename}'
}
EOS
apply_manifest(pp, :catch_failures => true)
end
EOS
apply_manifest(pp, :catch_failures => true)
end

describe service(servicename) do
describe service(servicename) do
if !(fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12')
it { should be_running }
it { should be_enabled }
else
# hack until we either update SpecInfra or come up with alternative
output = shell('service ntpd status', :acceptable_exit_codes => [0, 3])
it 'should be disabled' do
expect(output.stdout).to match(/^\s+Loaded.*disabled\)$/)
end
it 'should be stopped' do
expect(output.stdout).to match(/Active\:\s+inactive/)
end
end
end
end

8 changes: 6 additions & 2 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
on host, "/bin/echo '' > #{host['hieraconf']}"
end
on host, "mkdir -p #{host['distmoduledir']}"
on host, apply_manifest('package{"git":ensure => present}')
on host, 'git clone -b 3.2.x https://github.com/puppetlabs/puppetlabs-stdlib /etc/puppetlabs/puppet/modules/stdlib'
if host['platform'] =~ /sles-12/
apply_manifest_on(host, 'package{"git":}')
on host, 'git clone -b 4.3.x https://github.com/puppetlabs/puppetlabs-stdlib /etc/puppetlabs/puppet/modules/stdlib'
else
on host, puppet_module_install('puppetlabs/stdlib')
end
end
end

Expand Down

0 comments on commit 4fd5093

Please sign in to comment.