Skip to content

Commit

Permalink
Test against older versions of Splunk
Browse files Browse the repository at this point in the history
Also include basic testing for old versions:
- 7.4.2.4 (EOL)
- 8.2.9 (EOL)
- 9.0.0
  • Loading branch information
siegy22 committed Mar 18, 2024
1 parent dfc051b commit a32813b
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 8 deletions.
48 changes: 47 additions & 1 deletion spec/acceptance/splunk_enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,51 @@
'splunk'
end

OLD_SPLUNK_VERSIONS.each do |version, build|
context "Splunk version #{version}" do
after(:all) do
pp = <<-EOS
service { '#{service_name}': ensure => stopped }
package { 'splunk': ensure => purged }
file { '/opt/splunk': ensure => absent, force => true, require => Package['splunk'] }
file { '/etc/init.d/splunk': ensure => absent, require => Package['splunk'] }
file { '/etc/systemd/system/Splunkd.service': ensure => absent, require => Package['splunk'] }
EOS
apply_manifest(pp, catch_failures: true)
end

it 'works idempotently with no errors' do
pp = <<-EOS
class { 'splunk::params': version => '#{version}', build => '#{build}' }
class { 'splunk::enterprise': }
# See https://community.splunk.com/t5/Installation/Why-am-I-getting-an-error-to-start-a-fresh-Splunk-instance-in-my/m-p/336938
file_line { 'file_locking':
path => '/opt/splunk/etc/splunk-launch.conf',
line => 'OPTIMISTIC_ABOUT_FILE_LOCKING=1',
before => Exec['enable_splunk'],
require => Package['splunk'],
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# give splunk some time to start
sleep(10)
end

describe package('splunk') do
it { is_expected.to be_installed }
end

describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end

context 'default parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand All @@ -20,7 +65,8 @@ class { 'splunk::enterprise': }
file_line { 'file_locking':
path => '/opt/splunk/etc/splunk-launch.conf',
line => 'OPTIMISTIC_ABOUT_FILE_LOCKING=1',
require => Class['splunk::enterprise'],
before => Exec['enable_splunk'],
require => Package['splunk'],
}
EOS

Expand Down
51 changes: 44 additions & 7 deletions spec/acceptance/splunk_forwarder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@
require 'spec_helper_acceptance'

describe 'splunk::forwarder class' do
init = shell('/bin/readlink /sbin/init', acceptable_exit_codes: [0, 1]).stdout
service_name = if init.include? 'systemd'
'SplunkForwarder'
else
'splunk'
end

OLD_SPLUNK_VERSIONS.each do |version, build|
context "Splunk forwarder version #{version}" do
after(:all) do
pp = <<-EOS
service { '#{service_name}': ensure => stopped }
package { 'splunkforwarder': ensure => purged }
file { '/opt/splunkforwarder': ensure => absent, force => true, require => Package['splunkforwarder'] }
file { '/opt/splunk': ensure => absent, force => true, require => Package['splunkforwarder'] }
file { '/etc/systemd/system/SplunkForwarder.service': ensure => absent, require => Package['splunkforwarder'] }
EOS
apply_manifest(pp, catch_failures: true)
end

it 'works idempotently with no errors' do
pp = <<-EOS
class { 'splunk::params': version => '#{version}', build => '#{build}' }
class { 'splunk::forwarder':
splunkd_port => 8090,
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('splunkforwarder') do
it { is_expected.to be_installed }
end

describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end

context 'default parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand Down Expand Up @@ -32,13 +76,6 @@ class { 'splunk::forwarder':
it { is_expected.to be_installed }
end

init = shell('/bin/readlink /sbin/init', acceptable_exit_codes: [0, 1]).stdout
service_name = if init.include? 'systemd'
'SplunkForwarder'
else
'splunk'
end

describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
Expand Down
5 changes: 5 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
require 'voxpupuli/acceptance/spec_helper_acceptance'
require 'splunk_data'

OLD_SPLUNK_VERSIONS = [
['7.2.4.2', 'fb30470262e3'],
['9.0.0', '6818ac46f2ec'],
].freeze

configure_beaker do |host|
# Need to stage the Splunk/Splunkforwarder packages here.

Expand Down

0 comments on commit a32813b

Please sign in to comment.