Skip to content

Commit

Permalink
Fix RedHat acceptance tests
Browse files Browse the repository at this point in the history
Ensure we install nginx from the default repo: cleanup leftovers from
previous tests and skip repo management when testing nginx mail features
(sic).

Also, do not try to test passenger support on CentOS Stream which has no
support for it.
  • Loading branch information
smortex committed Aug 11, 2022
1 parent f91225b commit 72af1c7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
pkg_cmd = 'yum info nginx | grep "^From repo"'
pkg_remove_cmd = 'yum -y remove nginx nginx-filesystem passenger'
pkg_match = case fact('operatingsystemmajrelease')
when '8'
# Erf, CentOS 8 package nginx and passenger in appstream, but
# has no support for passenger-nginx
pkg_cmd = false

%r{appstream}
when '7' # https://blog.phusion.nl/2020/05/29/passenger-6-0-5/
%r{epel}
else
Expand Down
27 changes: 27 additions & 0 deletions spec/acceptance/nginx_mail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,39 @@
require 'spec_helper_acceptance'

describe 'nginx::resource::mailhost define:' do
it 'remove leftovers from previous tests' do
# The following breaks on CentOS Stream, but this workaround is only
# required for older versions of CentOS so we can ignore it.
pp = "
if fact('os.family') == 'RedHat' and versioncmp(fact('os.release.full'), '8.0') < 0 {
yumrepo { 'nginx-release':
ensure => absent,
}
yumrepo { 'passenger':
ensure => absent,
}
package { 'nginx':
ensure => absent,
}
}
"
apply_manifest(pp, catch_failures: true)
end

it 'runs successfully' do
pp = "
if fact('os.family') == 'RedHat' {
package { 'nginx-mod-mail':
ensure => installed,
}
$manage_repo = false
} else {
$manage_repo = true
}
class { 'nginx':
mail => true,
manage_repo => $manage_repo,
dynamic_modules => fact('os.family') ? {
'RedHat' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'],
default => [],
Expand All @@ -32,6 +55,10 @@ class { 'nginx':
"

apply_manifest(pp, catch_failures: true)
# The module produce different config when nginx is installed and when it
# is not installed prior to getting facts, so we need to re-apply the
# catalog.
apply_manifest(pp, catch_failures: true)
end

describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do
Expand Down

0 comments on commit 72af1c7

Please sign in to comment.