From 10ce29fe3f9a99fc2dc3c652e0f2ad3675a11c87 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 9 Aug 2022 13:07:36 +0200 Subject: [PATCH 1/8] Modulesync 5.3.0 --- .github/workflows/ci.yml | 86 +++------------------------------------- .msync.yml | 2 +- .rubocop.yml | 3 +- Gemfile | 2 +- spec/spec_helper.rb | 2 + 5 files changed, 11 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e6f180cb..299548f46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,86 +7,12 @@ name: CI on: pull_request concurrency: - group: ${{ github.head_ref }} + group: ${{ github.ref_name }} cancel-in-progress: true jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - timeout-minutes: 40 - outputs: - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} - env: - BUNDLE_WITHOUT: development:system_tests:release - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run static validations - run: bundle exec rake validate lint check - - name: Run rake rubocop - run: bundle exec rake rubocop - - name: Setup Test Matrix - id: get-outputs - run: bundle exec metadata2gha --use-fqdn --pidfile-workaround CentOS,Ubuntu - - unit: - needs: setup_matrix - runs-on: ubuntu-latest - timeout-minutes: 40 - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} - env: - BUNDLE_WITHOUT: development:system_tests:release - PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" - name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run tests - run: bundle exec rake parallel_spec - - acceptance: - needs: setup_matrix - runs-on: ubuntu-latest - env: - LANG: en_US - LC_ALL: en_US.UTF-8 - BUNDLE_WITHOUT: development:test:release - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}} - name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }} - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run tests - run: bundle exec rake beaker - env: - BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} - BEAKER_setfile: ${{ matrix.setfile.value }} - - tests: - needs: - - unit - - acceptance - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'CentOS,Ubuntu' diff --git a/.msync.yml b/.msync.yml index 968a93678..02353859a 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.2.0' +modulesync_config_version: '5.3.0' diff --git a/.rubocop.yml b/.rubocop.yml index ea22bff86..fded90cf2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,7 @@ --- -inherit_from: .rubocop_todo.yml - # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +inherit_from: .rubocop_todo.yml inherit_gem: voxpupuli-test: rubocop.yml diff --git a/Gemfile b/Gemfile index adabc8d62..9c527bdf4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dfa3a9219..a68e7dbe8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ require 'voxpupuli/test/spec_helper' +add_mocked_facts! + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) facts&.each do |name, value| From 95b28f5e3e7ee6bde395d21406cf124ba2683279 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 9 Aug 2022 13:12:14 +0200 Subject: [PATCH 2/8] Remove redundant systemd fact override This is now set by the mocked custom facts --- spec/classes/agent_spec.rb | 10 +--------- spec/classes/server_spec.rb | 10 +--------- spec/defines/userparameters_spec.rb | 10 +--------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index 7a61192d8..11616c75d 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -16,12 +16,6 @@ on_supported_os(baseline_os_hash).each do |os, facts| context "on #{os}" do - systemd_fact = case facts[:osfamily] - when 'Archlinux', 'Fedora', 'Gentoo' - { systemd: true } - else - { systemd: false } - end config_path = case facts[:operatingsystem] when 'Fedora' '/etc/zabbix_agentd.conf' @@ -45,9 +39,7 @@ end zabbix_version = '5.0' - let :facts do - facts.merge(systemd_fact) - end + let(:facts) { facts } case facts[:osfamily] when 'Gentoo' diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 894c5a63a..9350a047f 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -13,15 +13,7 @@ next if facts[:os]['name'] == 'windows' context "on #{os}" do - systemd_fact = case facts[:osfamily] - when 'Archlinux', 'Fedora', 'Gentoo' - { systemd: true } - else - { systemd: false } - end - let :facts do - facts.merge(systemd_fact) - end + let(:facts) { facts } zabbix_version = '5.0' diff --git a/spec/defines/userparameters_spec.rb b/spec/defines/userparameters_spec.rb index 9e6f54a95..9e8f66c52 100644 --- a/spec/defines/userparameters_spec.rb +++ b/spec/defines/userparameters_spec.rb @@ -7,15 +7,7 @@ next if facts[:os]['name'] == 'windows' context "on #{os}" do - let :facts do - systemd_fact = case facts[:os]['family'] - when 'Archlinux', 'Fedora', 'Gentoo' - { systemd: true } - else - { systemd: false } - end - facts.merge(systemd_fact) - end + let(:facts) { facts } let(:title) { 'mysqld' } let(:pre_condition) { 'class { "zabbix::agent": include_dir => "/etc/zabbix/zabbix_agentd.d" }' } From e1d616bb70d359961b4da83dcba60a4eb94532bd Mon Sep 17 00:00:00 2001 From: Alexander Michelsen Date: Fri, 12 Aug 2022 18:50:21 +0200 Subject: [PATCH 3/8] Fix agent and server tests that now use systemd --- spec/classes/agent_spec.rb | 2 +- spec/classes/server_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index 11616c75d..0f9b77c29 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -213,7 +213,7 @@ context 'it creates a startup script' do if facts[:kernel] == 'Linux' case facts[:osfamily] - when 'Archlinux', 'Fedora', 'Gentoo' + when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('absent') } it { is_expected.to contain_file("/etc/systemd/system/#{service_name}.service").with_ensure('file') } when 'windows' diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 9350a047f..5da1b15e7 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -147,7 +147,7 @@ context 'it creates a startup script' do case facts[:osfamily] - when 'Archlinux', 'Fedora', 'Gentoo' + when 'Archlinux', 'Debian', 'Gentoo', 'RedHat' it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('absent') } it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_ensure('file') } else From 269eb38572a579c415d7ec3b35afb61f3d757892 Mon Sep 17 00:00:00 2001 From: Alexander Michelsen Date: Fri, 12 Aug 2022 18:56:36 +0200 Subject: [PATCH 4/8] Disable tests for Gentoo --- spec/spec_helper_methods.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index af6110bc4..3e4bf52e3 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb @@ -18,9 +18,10 @@ def baseline_os_hash { 'operatingsystem' => 'Archlinux', }, - { - 'operatingsystem' => 'Gentoo', - }, + # TODO: Support and tests for Gentoo need to be fixed + # { + # 'operatingsystem' => 'Gentoo', + # }, { 'operatingsystem' => 'windows', 'operatingsystemrelease' => ['2012', '2012 R2', '2016'] From 63dcee83d076fd1774a620881ad77a97202298d2 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 24 Aug 2022 12:54:24 +0200 Subject: [PATCH 5/8] Add workaround for EL 7 locale --- .sync.yml | 2 -- spec/spec_helper_acceptance.rb | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.sync.yml b/.sync.yml index c15a0ccbb..aa41efef7 100644 --- a/.sync.yml +++ b/.sync.yml @@ -9,8 +9,6 @@ spec/spec_helper.rb: spec_overrides: - "require 'support/acceptance/supported_versions'" - "require 'spec_helper_methods'" -spec/spec_helper_acceptance.rb: - unmanaged: false .github/workflows/ci.yml: pidfile_workaround: CentOS,Ubuntu .puppet-lint.rc: diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3a6e23cf..d64c527b1 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,10 +1,14 @@ # frozen_string_literal: true -# Managed by modulesync - DO NOT EDIT -# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ - require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker +configure_beaker do + # In Puppet 7 the locale ends up being C.UTF-8 if it isn't passed. + # This locale doesn't exist in EL7 and won't be supported either. + # At least PostgreSQL runs into this. + if host['hypervisor'] == 'docker' && host['platform'] == 'el-7-x86_64' + ENV['LANG'] = 'en_US.UTF-8' + end +end Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From b548f8446be424a856acb4cc13510a0a6fbd5003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Sep 2022 11:00:12 -1000 Subject: [PATCH 6/8] Make rubocop happy --- spec/spec_helper_acceptance.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d64c527b1..73370392f 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -6,9 +6,7 @@ # In Puppet 7 the locale ends up being C.UTF-8 if it isn't passed. # This locale doesn't exist in EL7 and won't be supported either. # At least PostgreSQL runs into this. - if host['hypervisor'] == 'docker' && host['platform'] == 'el-7-x86_64' - ENV['LANG'] = 'en_US.UTF-8' - end + ENV['LANG'] = 'en_US.UTF-8' if host['hypervisor'] == 'docker' && host['platform'] == 'el-7-x86_64' end Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From e3baa7f5fc665d31ad3c96b8b6fd04adcff26418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 7 Sep 2022 14:40:31 -1000 Subject: [PATCH 7/8] Fix acceptance tests startup --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 73370392f..6d8f82bda 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -2,7 +2,7 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker do +configure_beaker do |host| # In Puppet 7 the locale ends up being C.UTF-8 if it isn't passed. # This locale doesn't exist in EL7 and won't be supported either. # At least PostgreSQL runs into this. From 70a46a3bdf2ec6766a0f4a9d5c817a8b19f50384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 8 Sep 2022 09:36:07 -1000 Subject: [PATCH 8/8] Drop support for Puppet 6 This module install gems using the puppet_gem provider in the gempath of the version of Ruby bundled with Puppet. Puppet 6 bundle Ruby 2.5 which has reached EoL on 2022-04-05, and the gems the module needs depend on gems that do not offer support for this version of Ruby anymore. This break CI and the situation has no reason to improve in the future, so stop advertising support for Puppet 6. --- metadata.json | 2 +- spec/setup_acceptance_node.pp | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 spec/setup_acceptance_node.pp diff --git a/metadata.json b/metadata.json index 678d9666b..d02c699e3 100644 --- a/metadata.json +++ b/metadata.json @@ -52,7 +52,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.1.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 8.0.0" } ], "operatingsystem_support": [ diff --git a/spec/setup_acceptance_node.pp b/spec/setup_acceptance_node.pp deleted file mode 100644 index e00ca77c3..000000000 --- a/spec/setup_acceptance_node.pp +++ /dev/null @@ -1,6 +0,0 @@ -# Needed for os.distro.codebase fact on ubuntu 16/18 on puppet 6 -if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['puppetversion'], '7.0.0') < 0 { - package{'lsb-release': - ensure => present, - } -}