-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SIMP-9623) Disable caching across calls to compliance_markup::enforc…
…ement (#125) * (SIMP-9623) Disable caching across calls to compliance_markup::enforcement SIMP-9623 #close * Additional cleanup * Removed the actual defunct caching methods * Changed the `lock` value to something compliance markup-specific since we're using the global cache now * Removed the calls to 'cached_lookup` since we can't access the appropriate context at that point and the only things that used them don't seem to be used anywhere else in the codebase * Fix global hieradata lookup Hooked the global hieradata into the lookup stack. (Honestly, I have no idea how this was working properly before) * remove extraneous method * Add a test for overrides using `compliance_markup::compliance_map`. Co-authored-by: Trevor Vaughan <[email protected]>
- Loading branch information
1 parent
bbdb7d4
commit cb66cf4
Showing
5 changed files
with
130 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
* Wed Feb 24 2021 Steven Pritchard <[email protected]> - 3.1.4-0 | ||
- Refactor `list_puppet_params` to avoid excessive looping | ||
- Disable caching (SIMP-9623) | ||
|
||
* Mon Nov 02 2020 Andy Adrian <[email protected]> - 3.1.4-0 | ||
- Remove unused and broken telemetry functionality | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
spec/functions/compliance_markup/05_enforcement_override_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/usr/bin/env ruby -S rspec | ||
|
||
require 'spec_helper' | ||
require 'semantic_puppet' | ||
require 'puppet/pops/lookup/context' | ||
require 'yaml' | ||
require 'fileutils' | ||
|
||
puppetver = SemanticPuppet::Version.parse(Puppet.version) | ||
requiredver = SemanticPuppet::Version.parse("4.10.0") | ||
|
||
describe 'lookup' do | ||
# Generate a fake module with dummy data for lookup(). | ||
profile_yaml = { | ||
'version' => '2.0.0', | ||
'profiles' => { | ||
'profile_test1' => { | ||
'ces' => { | ||
'05_profile_test1' => true, | ||
'05_profile_test2' => true, | ||
}, | ||
}, | ||
}, | ||
}.to_yaml | ||
|
||
ces_yaml = { | ||
'version' => '2.0.0', | ||
'ce' => { | ||
'05_profile_test1' => {}, | ||
'05_profile_test2' => {}, | ||
}, | ||
}.to_yaml | ||
|
||
checks_yaml = { | ||
'version' => '2.0.0', | ||
'checks' => { | ||
'05_hash check1' => { | ||
'type' => 'puppet-class-parameter', | ||
'settings' => { | ||
'parameter' => 'test_module_05::hash_param', | ||
'value' => { | ||
'hash key 1' => 'hash value 1', | ||
}, | ||
}, | ||
'ces' => [ | ||
'05_profile_test1', | ||
], | ||
}, | ||
'05_hash check2' => { | ||
'type' => 'puppet-class-parameter', | ||
'settings' => { | ||
'parameter' => 'test_module_05::hash_param', | ||
'value' => { | ||
'hash key 2' => 'hash value 2', | ||
}, | ||
}, | ||
'ces' => [ | ||
'05_profile_test2', | ||
], | ||
}, | ||
}, | ||
}.to_yaml | ||
|
||
fixtures = File.expand_path('../../fixtures', __dir__) | ||
|
||
compliance_dir = File.join(fixtures, 'modules', 'test_module_05', 'SIMP', 'compliance_profiles') | ||
FileUtils.mkdir_p(compliance_dir) | ||
|
||
File.open(File.join(compliance_dir, 'profile.yaml'), 'w') do |fh| | ||
fh.puts profile_yaml | ||
end | ||
|
||
File.open(File.join(compliance_dir, 'ces.yaml'), 'w') do |fh| | ||
fh.puts ces_yaml | ||
end | ||
|
||
File.open(File.join(compliance_dir, 'checks.yaml'), 'w') do |fh| | ||
fh.puts checks_yaml | ||
end | ||
|
||
on_supported_os.each do |os, os_facts| | ||
context "on #{os} with compliance data in modules" do | ||
before(:all) do | ||
File.open(File.join(fixtures, 'hieradata', 'profile-merging.yaml'), 'w') do |fh| | ||
test_hiera = {'compliance_markup::enforcement' => ['profile_test1']}.to_yaml | ||
fh.puts test_hiera | ||
end | ||
end | ||
|
||
let(:hieradata) { 'profile-merging' } | ||
|
||
# Test a simple hash. | ||
it { is_expected.to run.with_params('test_module_05::hash_param').and_return({'hash key 1' => 'hash value 1', 'hash key 2' => 'hash value 2'}) } | ||
end | ||
|
||
context "on #{os} with compliance_markup::compliance_map override" do | ||
before(:all) do | ||
File.open(File.join(fixtures, 'hieradata', 'profile-merging.yaml'), 'w') do |fh| | ||
test_hiera = { | ||
'compliance_markup::enforcement' => ['profile_test1'], | ||
'compliance_markup::compliance_map' => { | ||
'version' => '2.0.0', | ||
'profiles' => { | ||
'profile_test1' => { | ||
'ces' => { | ||
'05_profile_test2' => false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}.to_yaml | ||
fh.puts test_hiera | ||
end | ||
end | ||
|
||
let(:hieradata) { 'profile-merging' } | ||
|
||
# Test a simple hash. | ||
it { is_expected.to run.with_params('test_module_05::hash_param').and_return({'hash key 1' => 'hash value 1'}) } | ||
end | ||
end | ||
end |