From 72af1c7880b4b63883041c64461fa0a6ef14741e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 10 Aug 2022 14:46:05 -1000 Subject: [PATCH] Fix RedHat acceptance tests 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. --- spec/acceptance/class_spec.rb | 6 ++++++ spec/acceptance/nginx_mail_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 10a41dd9d..e741981d5 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -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 diff --git a/spec/acceptance/nginx_mail_spec.rb b/spec/acceptance/nginx_mail_spec.rb index f1b7bb5c9..1fa398381 100644 --- a/spec/acceptance/nginx_mail_spec.rb +++ b/spec/acceptance/nginx_mail_spec.rb @@ -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 => [], @@ -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