From 9753f95cc83bf5c455d6a5ae61f7da4c76b53868 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 4 Nov 2014 13:09:58 -0800 Subject: [PATCH] Updated testing and support for sles12 --- manifests/params.pp | 3 +- spec/acceptance/ntp_service_spec.rb | 54 ++++++++++++++++++++--------- spec/spec_helper_acceptance.rb | 8 +++-- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 500c982ef..f959b2e3d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 = [ diff --git a/spec/acceptance/ntp_service_spec.rb b/spec/acceptance/ntp_service_spec.rb index 7851bd07c..73edd656d 100644 --- a/spec/acceptance/ntp_service_spec.rb +++ b/spec/acceptance/ntp_service_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper_acceptance' +require 'specinfra' case fact('osfamily') when 'RedHat', 'FreeBSD', 'Linux', 'Gentoo' @@ -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 @@ -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 @@ -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 + diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3f5e41061..e130db60c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -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