From ea75f634b4d47aca2d041a283bd1f9896dbcd56f Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Thu, 2 May 2024 12:08:04 -0400 Subject: [PATCH] Fix various tests --- .github/workflows/ci.yml | 5 ++++- cookbooks/fb_apache/attributes/default.rb | 2 +- cookbooks/fb_apache/recipes/default.rb | 6 +++--- cookbooks/fb_apache/resources/verify_configs.rb | 15 +++++++-------- cookbooks/fb_apt/recipes/default.rb | 3 ++- spec/fbspec.rb | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a05fd0c3d..d2c9aca24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.4, 2.5, 2.6] + ruby: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3] runs-on: ubuntu-latest steps: - name: Checkout repository @@ -34,8 +34,11 @@ jobs: - centos-stream-8 - ubuntu-1804 - ubuntu-2004 + - ubuntu-2204 - debian-9 - debian-10 + - debian-11 + - debian-12 runs-on: ubuntu-latest steps: - name: Checkout repository diff --git a/cookbooks/fb_apache/attributes/default.rb b/cookbooks/fb_apache/attributes/default.rb index ecafba772..be960423d 100644 --- a/cookbooks/fb_apache/attributes/default.rb +++ b/cookbooks/fb_apache/attributes/default.rb @@ -92,7 +92,7 @@ 'sites' => {}, 'status_config' => { 'Location /server-status' => { - 'SetHandler' => 'server-status' + 'SetHandler' => 'server-status', }, }, 'extra_configs' => {}, diff --git a/cookbooks/fb_apache/recipes/default.rb b/cookbooks/fb_apache/recipes/default.rb index 3a93ae099..083cd8cb9 100644 --- a/cookbooks/fb_apache/recipes/default.rb +++ b/cookbooks/fb_apache/recipes/default.rb @@ -73,8 +73,8 @@ end baseconfig = value_for_platform_family( - 'rhel' => "#{httpdir}/conf/httpd.conf", - 'debian' => "#{httpdir}/apache2.conf", + 'rhel' => "#{httpdir}/conf/httpd.conf", + 'debian' => "#{httpdir}/apache2.conf", ) sitesdir = value_for_platform_family( @@ -168,7 +168,7 @@ mod_dir moddir end -template "#{baseconfig}" do +template baseconfig do owner 'root' group 'root' mode '0644' diff --git a/cookbooks/fb_apache/resources/verify_configs.rb b/cookbooks/fb_apache/resources/verify_configs.rb index 8e78aba13..18d69a56b 100644 --- a/cookbooks/fb_apache/resources/verify_configs.rb +++ b/cookbooks/fb_apache/resources/verify_configs.rb @@ -44,10 +44,10 @@ # This is file = Chef::Util::FileEdit.new("#{tdir}/conf/httpd.conf") file.search_file_replace_line(%r{^ServerRoot "/etc/httpd"$}, - "ServerRoot \"#{tdir}\"") || - fail('Apache validation failed. Cannot find `ServerRoot /etc/httpd`') - file.write_file - else node.debian_family? + "ServerRoot \"#{tdir}\"") || + fail('Apache validation failed. Cannot find `ServerRoot /etc/httpd`') + file.write_file + elsif node.debian_family? # Generate the base apache config before doing the path substitution trickery below. build_resource(:template, "#{tdir}/apache2.conf") do @@ -58,12 +58,11 @@ end.run_action(:create) file = Chef::Util::FileEdit.new("#{tdir}/apache2.conf") file.search_file_replace_line(%r{^.?ServerRoot "/etc/apache2"$}, - "ServerRoot \"#{tdir}\"") || - fail('Apache validation failed. Cannot find `ServerRoot /etc/apache2`') - file.write_file + "ServerRoot \"#{tdir}\"") || + fail('Apache validation failed. Cannot find `ServerRoot /etc/apache2`') + file.write_file end - # we manually build the resource so that Chef does not add these to its # resource collection and hence not track it for "updates". build_resource(:template, diff --git a/cookbooks/fb_apt/recipes/default.rb b/cookbooks/fb_apt/recipes/default.rb index 71a7ef87d..8c0cc0e87 100644 --- a/cookbooks/fb_apt/recipes/default.rb +++ b/cookbooks/fb_apt/recipes/default.rb @@ -101,7 +101,8 @@ strace_path = node['fb_apt']['apt_update_strace_path'] strace_flags = node['fb_apt']['apt_update_strace_flags'] cmd_suffix = " >>#{log_path.shellescape} 2>&1" if log_path - cmd_prefix = "strace #{strace_flags} -o #{strace_path.shellescape} " if strace_path && ::File.exist?('/usr/bin/strace') + cmd_prefix = "strace #{strace_flags} -o #{strace_path.shellescape} " \ + if strace_path && ::File.exist?('/usr/bin/strace') "#{cmd_prefix}apt-get update#{cmd_suffix}" end) action :nothing diff --git a/spec/fbspec.rb b/spec/fbspec.rb index 735eb8997..7ea7a5142 100644 --- a/spec/fbspec.rb +++ b/spec/fbspec.rb @@ -39,7 +39,7 @@ def self.fbspec_init(cookbook_path, platforms) config.after(:example) do result = RubyProf.stop printer = RubyProf::GraphPrinter.new(result) - printer.print(STDOUT) + printer.print($stdout) end end end