diff modules/apache/spec/acceptance/mod_passenger_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
line wrap: on
line diff
--- a/modules/apache/spec/acceptance/mod_passenger_spec.rb	Sun Dec 22 09:41:45 2019 -0500
+++ b/modules/apache/spec/acceptance/mod_passenger_spec.rb	Sun Dec 22 14:43:29 2019 -0500
@@ -1,12 +1,14 @@
 require 'spec_helper_acceptance'
+require_relative './version.rb'
 
-describe 'apache::mod::passenger class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apache::mod::passenger class' do
+  pending 'This cannot run in the same test run as apache::vhost with passenger
+  as the passenger.conf file is not yet managed by puppet and will be wiped out
+  between tests and not replaced'
   case fact('osfamily')
   when 'Debian'
-    service_name = 'apache2'
-    mod_dir = '/etc/apache2/mods-available/'
-    conf_file = "#{mod_dir}passenger.conf"
-    load_file = "#{mod_dir}passenger.load"
+    conf_file = "#{$mod_dir}/passenger.conf"
+    load_file = "#{$mod_dir}/zpassenger.load"
 
     case fact('operatingsystem')
     when 'Ubuntu'
@@ -21,6 +23,10 @@
         passenger_root         = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
         passenger_ruby         = '/usr/bin/ruby'
         passenger_default_ruby = '/usr/bin/ruby'
+      when '16.04'
+        passenger_root         = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
+        passenger_ruby         = '/usr/bin/ruby'
+        passenger_default_ruby = '/usr/bin/ruby'
       else
         # This may or may not work on Ubuntu releases other than the above
         passenger_root = '/usr'
@@ -46,43 +52,37 @@
     rackapp_user = 'www-data'
     rackapp_group = 'www-data'
   when 'RedHat'
-    service_name = 'httpd'
-    mod_dir = '/etc/httpd/conf.d/'
-    conf_file = "#{mod_dir}passenger.conf"
-    load_file = "#{mod_dir}passenger.load"
+    conf_file = "#{$mod_dir}/passenger.conf"
+    load_file = "#{$mod_dir}/zpassenger.load"
     # sometimes installs as 3.0.12, sometimes as 3.0.19 - so just check for the stable part
-    passenger_root = '/usr/lib/ruby/gems/1.8/gems/passenger-3.0.1'
+    passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
     passenger_ruby = '/usr/bin/ruby'
-    passenger_tempdir = '/var/run/rubygem-passenger'
     passenger_module_path = 'modules/mod_passenger.so'
     rackapp_user = 'apache'
     rackapp_group = 'apache'
   end
 
   pp_rackapp = <<-EOS
-          /* a simple ruby rack 'hellow world' app */
-          file { '/var/www/passenger':
-            ensure  => directory,
-            owner   => '#{rackapp_user}',
-            group   => '#{rackapp_group}',
-            require => Class['apache::mod::passenger'],
-          }
-          file { '/var/www/passenger/config.ru':
-            ensure  => file,
-            owner   => '#{rackapp_user}',
-            group   => '#{rackapp_group}',
-            content => "app = proc { |env| [200, { \\"Content-Type\\" => \\"text/html\\" }, [\\"hello <b>world</b>\\"]] }\\nrun app",
-            require => File['/var/www/passenger'] ,
-          }
-          apache::vhost { 'passenger.example.com':
-            port    => '80',
-            docroot => '/var/www/passenger/public',
-            docroot_group => '#{rackapp_group}' ,
-            docroot_owner => '#{rackapp_user}' ,
-            custom_fragment => "PassengerRuby  #{passenger_ruby}\\nRailsEnv  development" ,
-            require => File['/var/www/passenger/config.ru'] ,
-          }
-          host { 'passenger.example.com': ip => '127.0.0.1', }
+    /* a simple ruby rack 'hello world' app */
+    file { '/var/www/passenger':
+      ensure => directory,
+      owner  => '#{rackapp_user}',
+      group  => '#{rackapp_group}',
+    }
+    file { '/var/www/passenger/config.ru':
+      ensure  => file,
+      owner   => '#{rackapp_user}',
+      group   => '#{rackapp_group}',
+      content => "app = proc { |env| [200, { \\"Content-Type\\" => \\"text/html\\" }, [\\"hello <b>world</b>\\"]] }\\nrun app",
+    }
+    apache::vhost { 'passenger.example.com':
+      port          => '80',
+      docroot       => '/var/www/passenger/public',
+      docroot_group => '#{rackapp_group}',
+      docroot_owner => '#{rackapp_user}',
+      require       => File['/var/www/passenger/config.ru'],
+    }
+    host { 'passenger.example.com': ip => '127.0.0.1', }
   EOS
 
   case fact('osfamily')
@@ -98,8 +98,12 @@
         apply_manifest(pp, :catch_failures => true)
       end
 
-      describe service(service_name) do
-        it { is_expected.to be_enabled }
+      describe service($service_name) do
+        if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
+          pending 'Should be enabled - Bug 760616 on Debian 8'
+        else
+          it { should be_enabled }
+        end
         it { is_expected.to be_running }
       end
 
@@ -118,6 +122,9 @@
           when '14.04'
             it { is_expected.to contain "PassengerDefaultRuby \"#{passenger_ruby}\"" }
             it { is_expected.not_to contain "/PassengerRuby/" }
+          when '16.04'
+            it { is_expected.to contain "PassengerDefaultRuby \"#{passenger_ruby}\"" }
+            it { is_expected.not_to contain "/PassengerRuby/" }
           else
             # This may or may not work on Ubuntu releases other than the above
             it { is_expected.to contain "PassengerRuby \"#{passenger_ruby}\"" }
@@ -152,7 +159,8 @@
           # passenger-memory-stats output on newer Debian/Ubuntu verions do not contain
           # these two lines
           unless ((fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04') or
-                 (fact('operatingsystem') == 'Debian' && fact('operatingsystemrelease') == '8.0'))
+                 (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') or
+                 (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8'))
             expect(r.stdout).to match(/### Processes: [0-9]+/)
             expect(r.stdout).to match(/### Total private dirty RSS: [0-9\.]+ MB/)
           end
@@ -169,7 +177,9 @@
           shell("PATH=/usr/bin:$PATH /usr/sbin/passenger-status") do |r|
             # spacing may vary
             expect(r.stdout).to match(/[\-]+ General information [\-]+/)
-            if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04'
+            if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04' or
+               (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '16.04') or
+               fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8'
               expect(r.stdout).to match(/Max pool size[ ]+: [0-9]+/)
               expect(r.stdout).to match(/Processes[ ]+: [0-9]+/)
               expect(r.stdout).to match(/Requests in top-level queue[ ]+: [0-9]+/)
@@ -194,115 +204,5 @@
       end
 
     end
-
-  when 'RedHat'
-    # no fedora 18 passenger package yet, and rhel5 packages only exist for ruby 1.8.5
-    unless (fact('operatingsystem') == 'Fedora' and fact('operatingsystemrelease').to_f >= 18) or (fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '5' and fact('rubyversion') != '1.8.5')
-
-      if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '7'
-        pending('test passenger - RHEL7 packages don\'t exist')
-      else
-        context "default passenger config" do
-          it 'succeeds in puppeting passenger' do
-            pp = <<-EOS
-              /* EPEL and passenger repositories */
-              class { 'epel': }
-              exec { 'passenger.repo GPG key':
-                command => '/usr/bin/curl -o /etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc',
-                creates => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc',
-              }
-              file { 'passenger.repo GPG key':
-                ensure  => file,
-                path    => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc',
-                require => Exec['passenger.repo GPG key'],
-              }
-              epel::rpm_gpg_key { 'passenger.stealthymonkeys.com':
-                path    => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc',
-                require => [
-                  Class['epel'],
-                  File['passenger.repo GPG key'],
-                ]
-              }
-              $releasever_string = $operatingsystem ? {
-                'Scientific' => '6',
-                default      => '$releasever',
-              }
-              yumrepo { 'passenger':
-                baseurl         => "http://passenger.stealthymonkeys.com/rhel/${releasever_string}/\\$basearch" ,
-                descr           => "Red Hat Enterprise ${releasever_string} - Phusion Passenger",
-                enabled         => 1,
-                gpgcheck        => 1,
-                gpgkey          => 'http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc',
-                mirrorlist      => 'http://passenger.stealthymonkeys.com/rhel/mirrors',
-                require => [
-                  Epel::Rpm_gpg_key['passenger.stealthymonkeys.com'],
-                ],
-              }
-              /* apache and mod_passenger */
-              class { 'apache':
-                  require => [
-                    Class['epel'],
-                ],
-              }
-              class { 'apache::mod::passenger':
-                require => [
-                  Yumrepo['passenger']
-                ],
-              }
-              #{pp_rackapp}
-            EOS
-            apply_manifest(pp, :catch_failures => true)
-          end
-
-          describe service(service_name) do
-            it { is_expected.to be_enabled }
-            it { is_expected.to be_running }
-          end
-
-          describe file(conf_file) do
-            it { is_expected.to contain "PassengerRoot #{passenger_root}" }
-            it { is_expected.to contain "PassengerRuby #{passenger_ruby}" }
-            it { is_expected.to contain "PassengerTempDir #{passenger_tempdir}" }
-          end
-
-          describe file(load_file) do
-            it { is_expected.to contain "LoadModule passenger_module #{passenger_module_path}" }
-          end
-
-          it 'should output status via passenger-memory-stats' do
-            shell("/usr/bin/passenger-memory-stats", :pty => true) do |r|
-              expect(r.stdout).to match(/Apache processes/)
-              expect(r.stdout).to match(/Nginx processes/)
-              expect(r.stdout).to match(/Passenger processes/)
-              expect(r.stdout).to match(/### Processes: [0-9]+/)
-              expect(r.stdout).to match(/### Total private dirty RSS: [0-9\.]+ MB/)
-
-              expect(r.exit_code).to eq(0)
-            end
-          end
-
-          it 'should output status via passenger-status' do
-            shell("PASSENGER_TMPDIR=/var/run/rubygem-passenger /usr/bin/passenger-status") do |r|
-              # spacing may vary
-              r.stdout.should =~ /[\-]+ General information [\-]+/
-              r.stdout.should =~ /max[ ]+= [0-9]+/
-              r.stdout.should =~ /count[ ]+= [0-9]+/
-              r.stdout.should =~ /active[ ]+= [0-9]+/
-              r.stdout.should =~ /inactive[ ]+= [0-9]+/
-              r.stdout.should =~ /Waiting on global queue: [0-9]+/
-
-              r.exit_code.should == 0
-            end
-          end
-
-          it 'should answer to passenger.example.com' do
-            shell("/usr/bin/curl passenger.example.com:80") do |r|
-              r.stdout.should =~ /^hello <b>world<\/b>$/
-              r.exit_code.should == 0
-            end
-          end
-        end
-      end
-    end
   end
 end