11require 'spec_helper_acceptance'
22
33describe 'splunk enterprise class' do
4+ init = shell ( '/bin/readlink /sbin/init' , acceptable_exit_codes : [ 0 , 1 ] ) . stdout
5+ service_name = if init . include? 'systemd'
6+ 'Splunkd'
7+ else
8+ 'splunk'
9+ end
10+
411 context 'default parameters' do
512 # Using puppet_apply as a helper
613 it 'works idempotently with no errors' do
@@ -17,13 +24,6 @@ class { '::splunk::enterprise': }
1724 it { is_expected . to be_installed }
1825 end
1926
20- init = shell ( '/bin/readlink /sbin/init' , acceptable_exit_codes : [ 0 , 1 ] ) . stdout
21- service_name = if init . include? 'systemd'
22- 'Splunkd'
23- else
24- 'splunk'
25- end
26-
2727 describe service ( service_name ) do
2828 it { is_expected . to be_enabled }
2929 it { is_expected . to be_running }
@@ -39,5 +39,21 @@ class { '::splunk::enterprise': }
3939 it { is_expected . to be_grouped_into 'root' }
4040 end
4141 end
42+
43+ # Uninstall so that splunkforwarder tests aren't affected by this set of tests
44+ context 'uninstalling splunk' do
45+ it do
46+ pp = <<-EOS
47+ service { '#{ service_name } ': ensure => stopped }
48+ package { 'splunk': ensure => purged }
49+ file { '/opt/splunk': ensure => absent, force => true, require => Package['splunk'] }
50+ file { '/etc/init.d/splunk': ensure => absent, require => Package['splunk'] }
51+ EOS
52+ apply_manifest ( pp , catch_failures : true )
53+ end
54+ describe package ( 'splunk' ) do
55+ it { is_expected . not_to be_installed }
56+ end
57+ end
4258 end
4359end
0 commit comments