Skip to content

Commit

Permalink
Clean up Apache acceptance test code
Browse files Browse the repository at this point in the history
This unifies the Apache stopping code and also removes mod_passenger on
RH since puppetlabs-apache doesn't deal well with it being installed but
not used. This will be relevant when using the reverse proxy setup.
  • Loading branch information
ekohl authored and mmoll committed Aug 30, 2019
1 parent 96b3e27 commit d54257e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
10 changes: 6 additions & 4 deletions spec/acceptance/foreman_basic_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman' do
apache_service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'

before(:context) do
case fact('osfamily')
when 'RedHat'
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo'
on default, 'service httpd stop', { :acceptable_exit_codes => [0, 5] }
on default, 'yum -y remove foreman* tfm-* mod_passenger && rm -rf /etc/yum.repos.d/foreman*.repo'
when 'Debian'
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] }
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] }
on default, 'rm -rf /etc/apt/sources.list.d/foreman*'
on default, 'service apache2 stop', { :acceptable_exit_codes => [0, 5] }
end

on default, "systemctl stop #{apache_service_name}", { :acceptable_exit_codes => [0, 5] }
end

let(:pp) do
Expand Down Expand Up @@ -61,7 +63,7 @@ class { '::foreman':

it_behaves_like 'a idempotent resource'

describe service(os[:family] == 'debian' ? 'apache2' : 'httpd') do
describe service(apache_service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
12 changes: 6 additions & 6 deletions spec/acceptance/foreman_journald_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman with journald' do
apache_service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'

before(:context) do
case fact('osfamily')
when 'RedHat'
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo'
on default, 'service httpd stop', { :acceptable_exit_codes => [0, 5] }
on default, 'yum -y remove foreman* tfm-* mod_passenger && rm -rf /etc/yum.repos.d/foreman*.repo'
when 'Debian'
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] }
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] }
on default, 'rm -rf /etc/apt/sources.list.d/foreman*'
on default, 'service apache2 stop', { :acceptable_exit_codes => [0, 5] }
end
end

service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'
on default, "systemctl stop #{apache_service_name}", { :acceptable_exit_codes => [0, 5] }
end

let(:pp) do
<<-EOS
Expand Down Expand Up @@ -64,7 +64,7 @@ class { '::foreman':

it_behaves_like 'a idempotent resource'

describe service(service_name) do
describe service(apache_service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
10 changes: 6 additions & 4 deletions spec/acceptance/foreman_prometheus_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman with prometheus' do
apache_service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'

before(:context) do
case fact('osfamily')
when 'RedHat'
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo'
on default, 'service httpd stop', { :acceptable_exit_codes => [0, 5] }
on default, 'yum -y remove foreman* tfm-* mod_passenger && rm -rf /etc/yum.repos.d/foreman*.repo'
when 'Debian'
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] }
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] }
on default, 'rm -rf /etc/apt/sources.list.d/foreman*'
on default, 'service apache2 stop', { :acceptable_exit_codes => [0, 5] }
end

on default, "systemctl stop #{apache_service_name}", { :acceptable_exit_codes => [0, 5] }
end

let(:pp) do
Expand Down Expand Up @@ -62,7 +64,7 @@ class { '::foreman':

it_behaves_like 'a idempotent resource'

describe service(os[:family] == 'debian' ? 'apache2' : 'httpd') do
describe service(apache_service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down
10 changes: 6 additions & 4 deletions spec/acceptance/foreman_statsd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman with statsd' do
apache_service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'

before(:context) do
case fact('osfamily')
when 'RedHat'
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo'
on default, 'service httpd stop', { :acceptable_exit_codes => [0, 5] }
on default, 'yum -y remove foreman* tfm-* mod_passenger && rm -rf /etc/yum.repos.d/foreman*.repo'
when 'Debian'
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] }
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] }
on default, 'rm -rf /etc/apt/sources.list.d/foreman*'
on default, 'service apache2 stop', { :acceptable_exit_codes => [0, 5] }
end

on default, "systemctl stop #{apache_service_name}", { :acceptable_exit_codes => [0, 5] }
end

let(:pp) do
Expand Down Expand Up @@ -62,7 +64,7 @@ class { '::foreman':

it_behaves_like 'a idempotent resource'

describe service(os[:family] == 'debian' ? 'apache2' : 'httpd') do
describe service(apache_service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
Expand Down

0 comments on commit d54257e

Please sign in to comment.