-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SIMP-9883) Generalize simpkv acceptance tests (#63)
Rewrote simpkv acceptance tests used by the file plugin so that the test infrastructure can be used by any plugin or any combination of plugins. Also, addressed test deficiencies such as the absence of global key testing and test infrastructure design flaws such as the confusing, unnecessary coupling of test data and the simpkv_test module. This test infrastructure is required for the ldap plugin.
- Loading branch information
1 parent
b8b584e
commit 4708811
Showing
76 changed files
with
3,890 additions
and
746 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rb_files = File.expand_path( 'helpers/**/*.rb', __dir__) | ||
Dir.glob( rb_files ).sort_by(&:to_s).each { |file| require file } |
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,119 @@ | ||
--- | ||
# NOTES FOR TEST MAINTAINERS: | ||
# This file specifies test key information in a data structure corresponding to | ||
# the Simpkv_test::KeyInfo type alias. This data or data derived from it will be | ||
# used to stimulate simpkv_test manifests to test simpkv functions. | ||
# | ||
# ** Please take time to understand how the simpkv_test module works! ** | ||
# | ||
# Important details about this key information are as follows: | ||
# * The keys are designed to cover a wide variety of keys types a user could | ||
# specify. This includes: | ||
# - Keys with simple values (Boolean, Integer, Float, String) | ||
# - Keys with complex values (Hash, Array) | ||
# - Keys that have to be handled with special Puppet code (Binary values) | ||
# - Puppet-environment-specific keys | ||
# - Global keys | ||
# - Keys with/without metadata | ||
# - Keys with/without path elements in their key names | ||
# * The keys are explicitly designed to test that key uniqueness is | ||
# appropriately handled. | ||
# - Keys are supposed to be uniquely specified by their | ||
# {key path, global status, and backend} triples. | ||
# - This data and the tests **ASSUME** a one-to-one mapping of app_id | ||
# to backend, and so a key is uniquely specified by its | ||
# {key path, global status, and app_id} triple. | ||
# - This file contains multiple keys with the same key path, but different | ||
# content and different combinations of app_id and global status. | ||
# * The key info is also designed to test different folder configurations | ||
# - Folders with keys and sub-folders | ||
# - Folders with only keys | ||
# - Folders with only sub-folders | ||
# | ||
# Also of note: | ||
# - This file currently only supports 3 different app_ids. | ||
# - Binary data is loaded with the Puppet binary_file() method, so the | ||
# 'file' specification must match what that function requires. | ||
# - Validation logic elsewhere assumes the Binary value of a key will be found | ||
# in a file in the simpkv_test module. | ||
# | ||
"<%= appid1 %>": | ||
env: | ||
boolean: | ||
value: true | ||
integer: | ||
value: 1234567890 | ||
metadata: | ||
verified: true | ||
float: | ||
value: 0.123 | ||
string: | ||
value: "test string1" | ||
metadata: | ||
author: "Sally Smith" | ||
complex/array_integers: | ||
value: | ||
- 8 | ||
- 9 | ||
- 10 | ||
metadata: | ||
normalized: true | ||
complex/array_strings: | ||
value: | ||
- 'test string2' | ||
complex/hash: | ||
value: | ||
attr1: "test string2" | ||
attr2: 11.0 | ||
attr3: false | ||
attr4: | ||
part1: "test string3" | ||
part2: true | ||
part3: | ||
- 12 | ||
- 13 | ||
empty/string: | ||
value: "" | ||
empty/complex/array: | ||
value: [] | ||
empty/complex/hash: | ||
value: {} | ||
global: | ||
boolean: | ||
value: false | ||
string: | ||
value: "global test string1" | ||
metadata: | ||
auditor: "Jill Jones" | ||
binary/keytabs/test_krb5.keytab: | ||
file: "simpkv_test/test_krb5.keytab" | ||
metadata: | ||
comment: "from simp/krb5 test" | ||
"<%= appid2 %>": | ||
# list will have no sub-folders | ||
env: | ||
integer: | ||
value: 123 | ||
float: | ||
value: 45.678 | ||
metadata: | ||
origin: sensor | ||
version: 3 | ||
global: | ||
integer: | ||
value: 901 | ||
metadata: | ||
truncated: true | ||
string: | ||
value: "global test string2" | ||
|
||
"<%= appid3 %>": | ||
env: | ||
# list will have only sub-folders | ||
complex/hash: | ||
value: | ||
location: rack1 | ||
slot: 10 | ||
metadata: | ||
last_reviewed: "2021-08-30" | ||
# global list will be empty |
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,25 @@ | ||
module Acceptance | ||
module Helpers | ||
module ManifestUtils | ||
|
||
def print_test_config(hieradata, manifest) | ||
puts '>'*80 | ||
if hieradata.is_a?(Hash) | ||
puts "Hieradata:\n#{hieradata.to_yaml}" | ||
else | ||
puts "Hieradata:\n#{hieradata}" | ||
end | ||
puts '-'*80 | ||
puts "Manifest:\n#{manifest}" | ||
puts '<'*80 | ||
end | ||
|
||
def set_hiera_and_apply_on(host, hieradata, manifest, apply_opts = {}, verbose = true ) | ||
print_test_config(hieradata, manifest) if verbose | ||
set_hieradata_on(host, hieradata) | ||
apply_manifest_on(host, manifest, apply_opts) | ||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.