From 96e21d15d37de860af2d6b6e8136bc6968d0e9ea Mon Sep 17 00:00:00 2001 From: Mike van Goor Date: Wed, 31 Jul 2024 11:01:29 +0200 Subject: [PATCH] php on el9 requires different inspec tests and fix opensuse Signed-off-by: Mike van Goor --- .github/workflows/ci.yml | 6 +- kitchen.yml | 9 +-- .../mod_auth_cas/controls/default.rb | 2 +- test/integration/mod_php/controls/default.rb | 35 ---------- test/integration/php/controls/default.rb | 69 +++++++++++++++++++ test/integration/{mod_php => php}/inspec.yml | 2 +- 6 files changed, 80 insertions(+), 43 deletions(-) delete mode 100644 test/integration/mod_php/controls/default.rb create mode 100644 test/integration/php/controls/default.rb rename test/integration/{mod_php => php}/inspec.yml (91%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b00fbb02..2ef298066 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,8 @@ jobs: - debian-12 - fedora-latest - opensuse-leap-15 + - oraclelinux-8 + - oraclelinux-9 - rockylinux-8 - rockylinux-9 - ubuntu-2004 @@ -39,16 +41,16 @@ jobs: - basic-site - default - mod-auth-cas - - mod-php + - php - module-template - mod-wsgi - ports - ssl - install-override exclude: + # TODO: disabled due to https://github.com/chef/chef/pull/13691 - os: amazonlinux-2023 suite: mod-wsgi - # TODO: disabled due to https://github.com/chef/chef/pull/13691 - os: opensuse-leap-15 suite: mod-wsgi steps: diff --git a/kitchen.yml b/kitchen.yml index a5987898b..bc6acb4f3 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -16,17 +16,18 @@ platforms: - name: almalinux-8 - name: almalinux-9 - name: amazonlinux-2023 - - name: centos-stream-8 - name: centos-stream-9 - - name: debian-10 - name: debian-11 - name: debian-12 + - name: fedora-latest - name: opensuse-leap-15 + - name: oraclelinux-8 + - name: oraclelinux-9 - name: rockylinux-8 - name: rockylinux-9 - - name: ubuntu-18.04 - name: ubuntu-20.04 - name: ubuntu-22.04 + - name: ubuntu-24.04 suites: - name: default @@ -47,7 +48,7 @@ suites: - name: module_template run_list: - recipe[test::module_template] - - name: mod_php + - name: php run_list: - recipe[test::php] - name: mod_wsgi diff --git a/test/integration/mod_auth_cas/controls/default.rb b/test/integration/mod_auth_cas/controls/default.rb index 344ded290..f4ad8746b 100644 --- a/test/integration/mod_auth_cas/controls/default.rb +++ b/test/integration/mod_auth_cas/controls/default.rb @@ -4,7 +4,7 @@ httpd_command = case os.family - when 'fedora', 'amazon' + when 'fedora', 'amazon', 'suse' 'httpd -M' when 'redhat' os.release.to_i >= 9 ? 'httpd -M' : 'apachectl -M' diff --git a/test/integration/mod_php/controls/default.rb b/test/integration/mod_php/controls/default.rb deleted file mode 100644 index c45d24d58..000000000 --- a/test/integration/mod_php/controls/default.rb +++ /dev/null @@ -1,35 +0,0 @@ -include_controls 'apache2-default' do - skip_control 'welcome-page' -end - -control 'PHP module enabled & running' do - impact 1 - desc 'php module should be enabled with config' - - describe command('apachectl -M') do - its('stdout') { should match(/php/) } - end - - case os['family'] - when 'debian', 'suse' - describe file('/etc/apache2/mods-available/php.conf') do - it { should exist } - its('content') { should match %r{SetHandler application/x-httpd-php} } - end - when 'freebsd' - describe file('/usr/local/etc/apache24/mods-available/php.conf') do - it { should exist } - its('content') { should match %r{SetHandler application/x-httpd-php} } - end - else - describe file('/etc/httpd/mods-available/php.conf') do - it { should exist } - its('content') { should match %r{SetHandler application/x-httpd-php} } - end - end - - describe http('localhost/info.php') do - its('status') { should eq 200 } - its('body') { should match /PHP Version/ } - end -end diff --git a/test/integration/php/controls/default.rb b/test/integration/php/controls/default.rb new file mode 100644 index 000000000..e55d23dd9 --- /dev/null +++ b/test/integration/php/controls/default.rb @@ -0,0 +1,69 @@ +include_controls 'apache2-default' do + skip_control 'welcome-page' +end + +httpd_command = + case os.family + when 'fedora', 'amazon', 'suse' + 'httpd -M' + when 'redhat' + os.release.to_i >= 9 ? 'httpd -M' : 'apachectl -M' + else + 'apachectl -M' + end + +control 'PHP module enabled & running' do + impact 1 + desc 'php module should be enabled with config' + + if (os['family'] == 'redhat' && os['release'].to_i >= 9) || os['family'] == 'fedora' + describe command httpd_command do + its('stdout') { should match(/proxy_fcgi/) } + end + else + describe command httpd_command do + its('stdout') { should match(/php/) } + end + end + + case os['family'] + when 'debian', 'suse' + describe file('/etc/apache2/mods-available/php.conf') do + it { should exist } + its('content') { should match %r{SetHandler application/x-httpd-php} } + end + when 'freebsd' + describe file('/usr/local/etc/apache24/mods-available/php.conf') do + it { should exist } + its('content') { should match %r{SetHandler application/x-httpd-php} } + end + when 'redhat', 'fedora' + if os['release'].to_i >= 9 + describe service('php-fpm') do + it { should be_installed } + it { should be_enabled } + it { should be_running } + end + + describe file('/etc/httpd/conf-available/custom_php_pool.conf') do + it { should exist } + its('content') { should match %r{proxy:unix:/var/run/php.*-fpm.sock|fcgi://localhost} } + end + else + describe file('/etc/httpd/mods-available/php.conf') do + it { should exist } + its('content') { should match %r{SetHandler application/x-httpd-php} } + end + end + else + describe file('/etc/httpd/mods-available/php.conf') do + it { should exist } + its('content') { should match %r{SetHandler application/x-httpd-php} } + end + end + + describe http('localhost/info.php') do + its('status') { should eq 200 } + its('body') { should match /PHP Version/ } + end +end diff --git a/test/integration/mod_php/inspec.yml b/test/integration/php/inspec.yml similarity index 91% rename from test/integration/mod_php/inspec.yml rename to test/integration/php/inspec.yml index 4a8ce4d63..6329a0802 100644 --- a/test/integration/mod_php/inspec.yml +++ b/test/integration/php/inspec.yml @@ -1,5 +1,5 @@ --- -name: apache2-mod-php +name: apache2-php title: Integration tests for apache2 cookbook summary: This InSpec profile contains integration tests for apache2 cookbook supports: