From b4ffec7c021025ced31343a70ab42d31922aff79 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Thu, 6 Aug 2026 10:41:48 -0500 Subject: [PATCH] Migrate lookup acceptance tests to Hiera 5 data providers PRs #384/#385 removed the deprecated data_binding_terminus and environment_data_provider settings and the metadata.json data_provider key, as accepted in the OpenVox 9 deprecation review. Two acceptance tests still configured environment and module data through those removed mechanisms and began failing on all platforms once 9.0.0 beta packages were built (acceptance-pipelines run 31098859281). Migrate the fixtures the same way #385 migrated the in-repo spec fixtures: - tests/lookup/lookup.rb: bind the environment and module data functions through hiera.yaml (version 5, v4_data_hash) at the environment root and module roots; drop the data_provider key from metadata.json. - tests/parser_functions/puppet_lookup_cmd.rb: env2/env3 (function providers) get env-level hiera.yaml v5 with v4_data_hash: environment::data; env4 (none) gets an explicit empty hierarchy, since environments always have a data layer under Hiera 5; production/env1 keep their still-supported v4 env hiera.yaml. mod2/mod3 (function) get module hiera.yaml v5 with v4_data_hash; mod4 (none) loses its hiera.yaml entirely so the module layer is absent, preserving the not-found behavior the assertions expect. The inert environment_data_provider lines and all 20 metadata.json data_provider keys are removed. One --explain assertion is updated because the environment data provider section now always appears in explain output (previously absent under provider none). Verified on a local beaker rig (single almalinux 9 primary running openvox-agent 9.0.0~beta2 and openvox-server 9.0.0~beta4, the versions from the failing pipeline run): both pipeline failures reproduced exactly with the pristine tests, and both tests pass with this change. All lookup *value* expectations are unchanged -- the loader picks the same function implementations the v4 providers did (ruby when both ruby and puppet-language exist, e.g. env2/mod2; puppet-language when only it exists, e.g. env3/mod3) and the v4_data_hash backend even preserves the Deprecated API function explain wording the test asserts. Note for rerunning on persistent hosts: the puppet_lookup_cmd teardown removes node1/node2 SSL keys but not the CA-signed certs, so back-to-back runs against the same CA need a puppetserver ca clean first. Fresh pipeline VMs are unaffected. Signed-off-by: Steven Pritchard Co-authored-by: Claude Fable 5 --- acceptance/tests/lookup/lookup.rb | 33 +++- .../parser_functions/puppet_lookup_cmd.rb | 169 ++++++++---------- 2 files changed, 98 insertions(+), 104 deletions(-) diff --git a/acceptance/tests/lookup/lookup.rb b/acceptance/tests/lookup/lookup.rb index ca1ec8892c..a10652d311 100644 --- a/acceptance/tests/lookup/lookup.rb +++ b/acceptance/tests/lookup/lookup.rb @@ -98,12 +98,23 @@ def mod_manifest_metadata_json(module_name = nil, testdir) "project_page": null, "issues_url": null, "dependencies": [ - ], - "data_provider": "function" + ] } ', mode => "0644", } + # Hiera 5 module layer: bind the module data function + # (replaces the removed metadata.json "data_provider" key) + file { '#{testdir}/environments/production/modules/#{module_name}/hiera.yaml': + ensure => file, + content => '--- +version: 5 +hierarchy: + - name: "Module data function" + v4_data_hash: #{module_name}::data +', + mode => "0644", + } file { '#{testdir}/environments/production/modules/#{module_name}/lib/puppet/bindings': ensure => absent, force => true, @@ -202,14 +213,24 @@ def mod_manifest_metadata_json(module_name = nil, testdir) ensure => file, content => ' environment_timeout = 0 - # for this environment, provide our own function to supply data to lookup - # implies a ruby function in /lib/puppet/functions/environment/data.rb - # named environment::data() - environment_data_provider = "function" ', mode => "0640", } +# Hiera 5 environment layer: bind the environment data function +# (replaces the removed environment_data_provider setting; the function +# lives in /lib/puppet/functions/environment/data.rb) +file { '#{testdir}/environments/production/hiera.yaml': + ensure => file, + content => '--- +version: 5 +hierarchy: + - name: "Environment data function" + v4_data_hash: environment::data +', + mode => "0640", +} + # the function to provide data for this environment file { '#{testdir}/environments/production/lib/puppet/functions/environment/data.rb': ensure => file, diff --git a/acceptance/tests/parser_functions/puppet_lookup_cmd.rb b/acceptance/tests/parser_functions/puppet_lookup_cmd.rb index 049da39255..5ab7dcba57 100644 --- a/acceptance/tests/parser_functions/puppet_lookup_cmd.rb +++ b/acceptance/tests/parser_functions/puppet_lookup_cmd.rb @@ -354,7 +354,6 @@ ensure => file, mode => "0644", content => 'environment_timeout = 0 -environment_data_provider = "hiera" ', } @@ -362,7 +361,6 @@ ensure => file, mode => "0644", content => 'environment_timeout = 0 -environment_data_provider = "function" ', } @@ -370,7 +368,6 @@ ensure => file, mode => "0644", content => 'environment_timeout = 0 -environment_data_provider = "function" ', } @@ -378,7 +375,6 @@ ensure => file, mode => "0644", content => 'environment_timeout = 0 -environment_data_provider = "none" ', } @@ -422,7 +418,10 @@ ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Environment data function" + v4_data_hash: environment::data ', } @@ -440,7 +439,10 @@ ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Environment data function" + v4_data_hash: environment::data ', } @@ -458,7 +460,8 @@ ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: [] ', } @@ -629,7 +632,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod2::data ', } @@ -648,7 +654,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod3::data ', } @@ -663,14 +672,6 @@ def data() ', } -file { '#{@coderoot}/environments/production/modules/mod4/hiera.yaml': - ensure => file, - mode => "0644", - content => '--- - version: 4 -', -} - file { '#{@coderoot}/environments/production/modules/mod4/data/common.yaml': ensure => file, mode => "0644", @@ -704,7 +705,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod2::data ', } @@ -722,7 +726,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod3::data ', } @@ -736,14 +743,6 @@ def data() ', } -file { '#{@coderoot}/environments/env1/modules/mod4/hiera.yaml': - ensure => file, - mode => "0644", - content => '--- - version: 4 -', -} - file { '#{@coderoot}/environments/env1/modules/mod4/data/common.yaml': ensure => file, mode => "0644", @@ -776,7 +775,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod2::data ', } @@ -794,7 +796,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod3::data ', } @@ -808,14 +813,6 @@ def data() ', } -file { '#{@coderoot}/environments/env2/modules/mod4/hiera.yaml': - ensure => file, - mode => "0644", - content => '--- - version: 4 -', -} - file { '#{@coderoot}/environments/env2/modules/mod4/data/common.yaml': ensure => file, mode => "0644", @@ -848,7 +845,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod2::data ', } @@ -866,7 +866,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod3::data ', } @@ -880,14 +883,6 @@ def data() ', } -file { '#{@coderoot}/environments/env3/modules/mod4/hiera.yaml': - ensure => file, - mode => "0644", - content => '--- - version: 4 -', -} - file { '#{@coderoot}/environments/env3/modules/mod4/data/common.yaml': ensure => file, mode => "0644", @@ -920,7 +915,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod2::data ', } @@ -938,7 +936,10 @@ def data() ensure => file, mode => "0644", content => '--- - version: 4 + version: 5 + hierarchy: + - name: "Module data function" + v4_data_hash: mod3::data ', } @@ -952,14 +953,6 @@ def data() ', } -file { '#{@coderoot}/environments/env4/modules/mod4/hiera.yaml': - ensure => file, - mode => "0644", - content => '--- - version: 4 -', -} - file { '#{@coderoot}/environments/env4/modules/mod4/data/common.yaml': ensure => file, mode => "0644", @@ -1712,8 +1705,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "hiera" + "dependencies": [] } ', } @@ -1730,8 +1722,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1748,8 +1739,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1766,8 +1756,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "none" + "dependencies": [] } ', } @@ -1784,8 +1773,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "hiera" + "dependencies": [] } ', } @@ -1802,8 +1790,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1820,8 +1807,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1838,8 +1824,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "none" + "dependencies": [] } ', } @@ -1856,8 +1841,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "hiera" + "dependencies": [] } ', } @@ -1874,8 +1858,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1892,8 +1875,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1910,8 +1892,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "none" + "dependencies": [] } ', } @@ -1928,8 +1909,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "hiera" + "dependencies": [] } ', } @@ -1946,8 +1926,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1964,8 +1943,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -1982,8 +1960,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "none" + "dependencies": [] } ', } @@ -2000,8 +1977,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "hiera" + "dependencies": [] } ', } @@ -2018,8 +1994,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -2036,8 +2011,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "function" + "dependencies": [] } ', } @@ -2054,8 +2028,7 @@ def data() "source": "", "project_page": null, "issues_url": null, - "dependencies": [], - "data_provider": "none" + "dependencies": [] } ', } @@ -2498,7 +2471,7 @@ def data() rxe4m1 = on(master, puppet('lookup', '--explain', '--environment env4', 'mod1::module_key')) result = rxe4m1.stdout assert_match( - /Global Data Provider.*\s*Using.*\s*Hier.*\s*Path.*\s*Orig.*\s*No such key.*\s*Module.*Data Provider.*\s*Using.*\s*Hier.*common\"\s*Path.*\s*Orig.*\s*Found key.*module-env4-mod1-hiera/, + /Global Data Provider.*\s*Using.*\s*Hier.*\s*Path.*\s*Orig.*\s*No such key.*\s*Environment Data Provider.*\s*Using.*\s*No such key.*\s*Module.*Data Provider.*\s*Using.*\s*Hier.*common\"\s*Path.*\s*Orig.*\s*Found key.*module-env4-mod1-hiera/, result, "environment env4 mod1::module_key lookup failed." )