comparison modules/apache/spec/acceptance/class_spec.rb @ 257:675c1cc61eaf

Update Apache module to get CentOS 8 support Unfortunately it only fixes some bits. mod_wsgi still needs other approaches This also overrides the vhost modification to make them come last in the import order (after module loading)
author IBBoard <dev@ibboard.co.uk>
date Sun, 22 Dec 2019 14:43:29 -0500
parents 37675581a273
children d9352a684e62
comparison
equal deleted inserted replaced
252:47750947f4dc 257:675c1cc61eaf
1 require 'spec_helper_acceptance' 1 require 'spec_helper_acceptance'
2 require_relative './version.rb'
2 3
3 describe 'apache class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do 4 describe 'apache class' do
4 case fact('osfamily') 5 context 'default parameters' do
5 when 'RedHat' 6 let(:pp) { "class { 'apache': }" }
6 package_name = 'httpd'
7 service_name = 'httpd'
8 when 'Debian'
9 package_name = 'apache2'
10 service_name = 'apache2'
11 when 'FreeBSD'
12 package_name = 'apache24'
13 service_name = 'apache24'
14 end
15 7
16 context 'default parameters' do 8 it_behaves_like "a idempotent resource"
17 it 'should work with no errors' do
18 pp = <<-EOS
19 class { 'apache': }
20 EOS
21 9
22 # Run it twice and test for idempotency 10 describe 'apache_version fact' do
23 apply_manifest(pp, :catch_failures => true) 11 before :all do
24 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero 12 apply_manifest("include apache", :catch_failures => true)
13 version_check_pp = <<-EOS
14 notice("apache_version = >${apache_version}<")
15 EOS
16 @result = apply_manifest(version_check_pp, :catch_failures => true)
17 end
18
19 it {
20 expect(@result.output).to match(/apache_version = >#{$apache_version}.*</)
21 }
25 end 22 end
26 23
27 describe package(package_name) do 24 describe package($package_name) do
28 it { is_expected.to be_installed } 25 it { is_expected.to be_installed }
29 end 26 end
30 27
31 describe service(service_name) do 28 describe service($service_name) do
32 it { is_expected.to be_enabled } 29 if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
30 pending 'Should be enabled - Bug 760616 on Debian 8'
31 else
32 it { should be_enabled }
33 end
33 it { is_expected.to be_running } 34 it { is_expected.to be_running }
34 end 35 end
35 36
36 describe port(80) do 37 describe port(80) do
37 it { should be_listening } 38 it { should be_listening }
38 end 39 end
39 end 40 end
40 41
41 context 'custom site/mod dir parameters' do 42 context 'custom site/mod dir parameters' do
42 # Using puppet_apply as a helper 43 # Using puppet_apply as a helper
43 it 'should work with no errors' do 44 let(:pp) do
44 pp = <<-EOS 45 <<-EOS
45 if $::osfamily == 'RedHat' and $::selinux { 46 if $::osfamily == 'RedHat' and "$::selinux" == "true" {
46 $semanage_package = $::operatingsystemmajrelease ? { 47 $semanage_package = $::operatingsystemmajrelease ? {
47 '5' => 'policycoreutils', 48 '5' => 'policycoreutils',
48 default => 'policycoreutils-python', 49 default => 'policycoreutils-python',
50 }
51
52 package { $semanage_package: ensure => installed }
53 exec { 'set_apache_defaults':
54 command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
55 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
56 subscribe => Package[$semanage_package],
57 refreshonly => true,
58 }
59 exec { 'restorecon_apache':
60 command => 'restorecon -Rv /apache_spec',
61 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
62 before => Service['httpd'],
63 require => Class['apache'],
64 subscribe => Exec['set_apache_defaults'],
65 refreshonly => true,
66 }
49 } 67 }
50 68 file { '/apache_spec': ensure => directory, }
51 package { $semanage_package: ensure => installed } 69 file { '/apache_spec/apache_custom': ensure => directory, }
52 exec { 'set_apache_defaults': 70 class { 'apache':
53 command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"', 71 mod_dir => '/apache_spec/apache_custom/mods',
54 path => '/bin:/usr/bin/:/sbin:/usr/sbin', 72 vhost_dir => '/apache_spec/apache_custom/vhosts',
55 subscribe => Package[$semanage_package],
56 refreshonly => true,
57 } 73 }
58 exec { 'restorecon_apache':
59 command => 'restorecon -Rv /apache_spec',
60 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
61 before => Service['httpd'],
62 require => Class['apache'],
63 subscribe => Exec['set_apache_defaults'],
64 refreshonly => true,
65 }
66 }
67 file { '/apache_spec': ensure => directory, }
68 file { '/apache_spec/apache_custom': ensure => directory, }
69 class { 'apache':
70 mod_dir => '/apache_spec/apache_custom/mods',
71 vhost_dir => '/apache_spec/apache_custom/vhosts',
72 }
73 EOS 74 EOS
74
75 # Run it twice and test for idempotency
76 apply_manifest(pp, :catch_failures => true)
77 apply_manifest(pp, :catch_changes => true)
78 end 75 end
79 76
80 describe service(service_name) do 77 # Run it twice and test for idempotency
81 it { is_expected.to be_enabled } 78 it_behaves_like "a idempotent resource"
79
80 describe service($service_name) do
81 if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
82 pending 'Should be enabled - Bug 760616 on Debian 8'
83 else
84 it { should be_enabled }
85 end
82 it { is_expected.to be_running } 86 it { is_expected.to be_running }
83 end 87 end
84 end 88 end
85 end 89 end