From 6620de50df7f3204672d5dea016cd9cd8c2d4cf5 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jun 2025 11:28:14 +0200 Subject: [PATCH 1/5] Add test for puppet implementation In https://github.com/OpenVoxProject/openvox-agent/issues/66 someone reported issues during `puppet lookup` with the changes from https://github.com/OpenVoxProject/puppet/pull/63 or https://github.com/OpenVoxProject/puppet/pull/78. It's also easy to reproduce it locally: ``` root@:~# puppet lookup puppet::puppetmaster Warning: The node parameter 'implementation' for node 'mirror.voxpupu.li' was already set to 'openvox'. It could not be set to 'openvox' --- voxpupu.li root@:~# echo $? 0 root@:~# ``` --- .../tests/lookup/issue_66_implementation.rb | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 acceptance/tests/lookup/issue_66_implementation.rb diff --git a/acceptance/tests/lookup/issue_66_implementation.rb b/acceptance/tests/lookup/issue_66_implementation.rb new file mode 100644 index 0000000000..cf2313f673 --- /dev/null +++ b/acceptance/tests/lookup/issue_66_implementation.rb @@ -0,0 +1,57 @@ +# test for https://github.com/OpenVoxProject/openvox-agent/issues/66 +test_name 'Warning about implementatin during puppet lookup' do + require 'puppet/acceptance/puppet_type_test_tools.rb' + extend Puppet::Acceptance::PuppetTypeTestTools + +# bastelfreak: I've no idea what those tags do, I copied them from lookup/v4_hieradata_with_v5_configs.rb +tag 'audit:high', + 'audit:acceptance', + 'audit:refactor', # Master is not needed for this test. Refactor + # to use puppet apply with a local module tree. + + app_type = File.basename(__FILE__, '.*') + tmp_environment = mk_tmp_environment_with_teardown(master, app_type) + fq_tmp_environmentpath = "#{environmentpath}/#{tmp_environment}" + + confdir = puppet_config(master, 'confdir', section: 'master') + hiera_conf_backup = master.tmpfile('66-hiera-yaml') + + step "backup global hiera.yaml" do + on(master, "cp -a #{confdir}/hiera.yaml #{hiera_conf_backup}", :acceptable_exit_codes => [0,1]) + end + + teardown do + step "restore global hiera.yaml" do + on(master, "mv #{hiera_conf_backup} #{confdir}/hiera.yaml", :acceptable_exit_codes => [0,1]) + end + + agents.each do |agent| + on(agent, puppet('config print lastrunfile')) do |command_result| + agent.rm_rf(command_result.stdout) + end + end + end + + step "create global hiera.yaml and data" do + create_remote_file(master, "#{confdir}/hiera.yaml", <<-HIERA) +--- +version: 5 +hierarchy: + - name: common + data_hash: yaml_data + path: "common.yaml" + HIERA + on(master, "chmod 755 #{confdir}/hiera.yaml") + create_remote_file(master, "#{confdir}/common.yaml", <<-YAML) +--- +environment_key: environment_key-global_common_file +global_key: global_key-global_common_file + YAML + end + + step 'assert lookups using lookup subcommand' do + on(master, puppet('lookup', 'environment_key'), :accept_all_exit_codes => true) do |result| + assert_match(/Warning: The node parameter 'implementation' for node '.*' was already set to 'openvox'. It could not be set to 'openvox'/, result.stderr) + end + end +end From f999016ab7ef24a5080b27ee9db5bf8cc14c0b71 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jun 2025 15:48:03 +0200 Subject: [PATCH 2/5] Add basic acceptance testing --- .github/workflows/acceptance.yaml | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/acceptance.yaml diff --git a/.github/workflows/acceptance.yaml b/.github/workflows/acceptance.yaml new file mode 100644 index 0000000000..7e29963945 --- /dev/null +++ b/.github/workflows/acceptance.yaml @@ -0,0 +1,39 @@ +--- +name: Beaker Acceptance Tests + +on: + workflow_dispatch: + +permissions: + contents: read + +env: + RUBY_VERSION: '3.3' + +jobs: + acceptance: + defaults: + run: + working-directory: acceptance + name: Acceptance Tests + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Ruby and Run Bundler + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true + - name: Run Beaker + run: |- + bundle exec beaker init --hosts hosts.yaml \ + --preserve-hosts always --keyfile "${SSH_KEY}" \ + --pre-suite pre-suite/configure_type_defaults.rb \ + --tests tests + # The provision step is still needed here, see notes in the + # kvm_automation_tooling/templates/beaker-hosts.yaml.epp + # template... + bundle exec beaker provision + bundle exec beaker exec From fa25bec7c5ec67896401edc26162697639556696 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jun 2025 15:51:35 +0200 Subject: [PATCH 3/5] Update .gitignore for acceptance --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6f746ed235..cc893f986c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ puppet-acceptance/ /acceptance/junit /acceptance/log /acceptance/.beaker +/acceptance/.vendor # emacs backup files *~ /*.samples From fb931b1053bd10193e3691491b14a771f0373188 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jun 2025 15:51:51 +0200 Subject: [PATCH 4/5] Cleanup Gemfile for acceptance testing --- acceptance/Gemfile | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/acceptance/Gemfile b/acceptance/Gemfile index 2e7d52c8a0..8abe5d3f6d 100644 --- a/acceptance/Gemfile +++ b/acceptance/Gemfile @@ -13,14 +13,10 @@ def location_for(place, fake_version = nil) end gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 6.0') -gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION' || "~> 4.0"]) +gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || "~> 4") gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 2") -gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 1.0") -gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || "~> 0") -gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1.3") -gem "beaker-vcloud", *location_for(ENV['BEAKER_VCLOUD_VERSION'] || "~> 1.0") -gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || "~> 0.5") -gem "beaker-gke", *location_for(ENV['BEAKER_GKE_VERSION'] || "~> 0.0.3") +gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || "~> 1.4") +gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || "~> 2.6") gem "rake", ">= 12.3.3" gem "httparty", :require => false gem 'uuidtools', :require => false @@ -29,7 +25,3 @@ group(:test) do gem "rspec", "~> 2.14.0", :require => false gem "mocha", "~> 0.10.5", :require => false end - -if File.exist? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) -end From d4b3a2c22604cec6afdcdbee0a3e324807e8b06f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 4 Jun 2025 15:51:55 +0200 Subject: [PATCH 5/5] fooo --- .github/workflows/acceptance.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/acceptance.yaml b/.github/workflows/acceptance.yaml index 7e29963945..994f75da1b 100644 --- a/.github/workflows/acceptance.yaml +++ b/.github/workflows/acceptance.yaml @@ -26,6 +26,8 @@ jobs: with: ruby-version: ${{ env.RUBY_VERSION }} bundler-cache: true + - name: Output Ruby environment information + run: bundle env - name: Run Beaker run: |- bundle exec beaker init --hosts hosts.yaml \