diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbcff657..311f2c4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,5 @@ --- name: ci - "on": pull_request: push: @@ -34,12 +33,10 @@ jobs: - "ubuntu-2004" - "ubuntu-2204" suite: - - "access-11" - "access-12" - "access-13" - "access-14" - "access-15" - - "client-install-11" - "client-install-12" - "client-install-13" - "client-install-14" @@ -53,7 +50,6 @@ jobs: - "ident-14" - "ident-15" - "initdb-locale-15" - - "server-install-11" - "server-install-12" - "server-install-13" - "server-install-14" diff --git a/CHANGELOG.md b/CHANGELOG.md index 18de135b..801ed115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This file is used to list changes made in the last 3 major versions of the postg ## Unreleased +- Modify installed_postgresql_package_source to get highest PG version from packages +- Remove PG11 suites from kitchen & CI due to upstream removal + ## 11.9.0 - *2024-01-05* ## 11.8.5 - *2023-12-18* diff --git a/kitchen.yml b/kitchen.yml index 702d00c2..5959eb87 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -320,73 +320,3 @@ suites: pg_ver: "12" run_list: - recipe[test::server_install] - - - name: access_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/access/ - run_list: - - recipe[test::access] - - name: client_install_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/client_install/ - inputs: - pg_ver: "11" - run_list: - - recipe[test::client_install] - - name: extension_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/extension/ - run_list: - - recipe[test::extension] - - name: ident_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/ident/ - run_list: - - recipe[test::ident] - - name: initdb_locale_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/initdb_locale/ - run_list: - - recipe[test::initdb_locale] - - name: repo_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/repo/ - inputs: - pg_ver: "11" - run_list: - - recipe[test::repository] - - name: server_install_11 - attributes: - test: - pg_ver: "11" - verifier: - inspec_tests: - - path: test/integration/server_install/ - inputs: - pg_ver: "11" - run_list: - - recipe[test::server_install] diff --git a/libraries/helpers.rb b/libraries/helpers.rb index b00337ec..152f08f2 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -23,12 +23,22 @@ module Cookbook module Helpers include Utils - def installed_postgresql_major_version - pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) } + def installed_postgresql_package_logic + pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }.values + + unless pgsql_package.one? + versions = pgsql_package.map { |values| values['version'] }.join(', ') + Chef::Log.warn("Detected #{pgsql_package.count} installed PostgreSQL versions: #{versions}. Using latest version.") + pgsql_package = [pgsql_package.max_by { |values| values['version'].to_f }] + end raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package) - pgsql_package = pgsql_package.values.first + pgsql_package.first + end + + def installed_postgresql_major_version + pgsql_package = installed_postgresql_package_logic pgsql_package_version = pgsql_package.fetch('version').to_i pgsql_package_source = if pgsql_package.key?('release') pgsql_package.fetch('release').match?('PGDG') ? :repo : :os @@ -42,11 +52,7 @@ def installed_postgresql_major_version end def installed_postgresql_package_source - pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) } - - raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package) - - pgsql_package = pgsql_package.values.first + pgsql_package = installed_postgresql_package_logic pgsql_package_version = pgsql_package.fetch('version').to_i pgsql_package_source = if pgsql_package.key?('release') pgsql_package.fetch('release').match?('PGDG') ? :repo : :os