simp-rspec-puppet-facts 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +10 -3
- data/lib/simp/rspec-puppet-facts.rb +26 -7
- data/lib/simp/version.rb +1 -1
- data/spec/acceptance/suites/default/00_default_spec.rb +10 -11
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/shim_dispatch_spec.rb +50 -0
- metadata +18 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 140c028f5870337de6f143ba7c8f73508f312fe10fe0017333b85454d1f8db3e
|
|
4
|
+
data.tar.gz: a0e791c59faff98c6612697b13b755b6d2327d4e58628c4cb15d0fd81faaec01
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e80e1cf1e316a51ae0bfc00410395fec10b9c95e3473c35ad0574752eea866b0638b7fdade85aa9917a17addaf295497c7f76477c8c669ec6f5dac102409342
|
|
7
|
+
data.tar.gz: a09bfe14fbd0b8bf067d9d8fdc97a036fa82ddcf66842fed692742e7fcd81d1910cda0bfa4cf0cede5d2f1f9139c408805b2d8068e6da87f705a326e25acbeb6
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
require 'simp/rake/beaker'
|
|
2
1
|
require 'bundler/gem_tasks'
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'simp/rake/beaker'
|
|
6
|
+
Simp::Rake::Beaker.new(__dir__)
|
|
7
|
+
rescue LoadError => e
|
|
8
|
+
# simp-beaker-helpers' rake tasks need puppetlabs_spec_helper, which isn't
|
|
9
|
+
# installable on Ruby 4 (it requires the legacy `puppet` gem)
|
|
10
|
+
warn "WARNING: skipping Simp::Rake::Beaker tasks (#{e.message})"
|
|
11
|
+
end
|
|
5
12
|
|
|
6
13
|
def syntax_check(task, glob)
|
|
7
14
|
warn "---> #{task.name}"
|
|
@@ -11,7 +11,9 @@ module Simp::RspecPuppetFacts
|
|
|
11
11
|
SELINUX_MODES = [:enforcing, :disabled, :permissive].freeze
|
|
12
12
|
|
|
13
13
|
def supported_os_strings(opts, known_os_list = [])
|
|
14
|
-
|
|
14
|
+
# The default has to be a block so that metadata.json is only consulted
|
|
15
|
+
# when :supported_os wasn't given
|
|
16
|
+
supported_os = opts.fetch(:supported_os) { RspecPuppetFacts.meta_supported_os }
|
|
15
17
|
hardwaremodels = opts.fetch(:hardwaremodels, ['x86_64'])
|
|
16
18
|
os_strings = []
|
|
17
19
|
supported_os.each do |os|
|
|
@@ -41,7 +43,7 @@ module Simp::RspecPuppetFacts
|
|
|
41
43
|
# because if it doesn't have them it will crash
|
|
42
44
|
def filter_opts(opts, simp_h)
|
|
43
45
|
rfh_hw = opts.fetch(:hardwaremodels, ['x86_64'])
|
|
44
|
-
rfh_os = opts.fetch(:supported_os
|
|
46
|
+
rfh_os = opts.fetch(:supported_os) { RspecPuppetFacts.meta_supported_os }.dup
|
|
45
47
|
|
|
46
48
|
filtered_opts = []
|
|
47
49
|
rfh_os.each do |os|
|
|
@@ -57,11 +59,13 @@ module Simp::RspecPuppetFacts
|
|
|
57
59
|
|
|
58
60
|
next if os['operatingsystemrelease'].empty?
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
# Only pass along the releases we don't have facts for, and only list
|
|
63
|
+
# each OS once, no matter how many of its releases are missing
|
|
64
|
+
missing_releases = os['operatingsystemrelease'].select do |rel|
|
|
65
|
+
rfh_hw.any? { |hw| !simp_h.key?([os['operatingsystem'].downcase, rel, hw].join('-')) }
|
|
64
66
|
end
|
|
67
|
+
|
|
68
|
+
filtered_opts.push(os.merge('operatingsystemrelease' => missing_releases)) unless missing_releases.empty?
|
|
65
69
|
end
|
|
66
70
|
|
|
67
71
|
ret_opts = opts.dup
|
|
@@ -203,7 +207,8 @@ module Simp::RspecPuppetFacts
|
|
|
203
207
|
|
|
204
208
|
if fallback_version
|
|
205
209
|
fact_dir = File.join(fact_dir_path, fallback_version)
|
|
206
|
-
warn "WARNING:
|
|
210
|
+
warn "WARNING: No SIMP factsets for Facter #{facter_xy_version}; " \
|
|
211
|
+
"falling back to the newest available factsets (Facter #{fallback_version})"
|
|
207
212
|
else
|
|
208
213
|
msg = <<~END_MSG
|
|
209
214
|
Can't find SIMP facts for Facter #{facter_xy_version}, skipping...
|
|
@@ -232,5 +237,19 @@ module Simp::RspecPuppetFacts
|
|
|
232
237
|
class Shim
|
|
233
238
|
require 'rspec-puppet-facts'
|
|
234
239
|
extend ::RspecPuppetFacts
|
|
240
|
+
|
|
241
|
+
# `extend ::RspecPuppetFacts` above is not enough to guarantee that
|
|
242
|
+
# `Shim.on_supported_os` reaches the upstream implementation: if a
|
|
243
|
+
# spec_helper has already done a top-level `include RspecPuppetFacts`
|
|
244
|
+
# (voxpupuli-test does this), the module is already in Object's ancestry
|
|
245
|
+
# and the `extend` is silently skipped. A later top-level
|
|
246
|
+
# `include Simp::RspecPuppetFacts` then shadows the upstream method, so
|
|
247
|
+
# `Shim.on_supported_os` would dispatch back to
|
|
248
|
+
# Simp::RspecPuppetFacts#on_supported_os and recurse without bound,
|
|
249
|
+
# exhausting all memory during fact loading (issue #86). Bind the
|
|
250
|
+
# upstream method explicitly so dispatch can never be shadowed.
|
|
251
|
+
def self.on_supported_os(opts = {})
|
|
252
|
+
::RspecPuppetFacts.instance_method(:on_supported_os).bind_call(self, opts)
|
|
253
|
+
end
|
|
235
254
|
end
|
|
236
255
|
end
|
data/lib/simp/version.rb
CHANGED
|
@@ -4,12 +4,11 @@ test_name 'we just want the facts'
|
|
|
4
4
|
|
|
5
5
|
describe 'look out muppets' do
|
|
6
6
|
hosts.each do |host|
|
|
7
|
-
let(:host_fqdn) { fact_on(host, 'fqdn') }
|
|
7
|
+
let(:host_fqdn) { fact_on(host, 'networking.fqdn') }
|
|
8
8
|
let(:collection_dir) { 'collected_facts' }
|
|
9
9
|
let(:os_info) { fact_on(host, 'os') }
|
|
10
|
-
let(:os_arch) { fact_on(host, 'architecture') }
|
|
11
10
|
|
|
12
|
-
let(:fact_collection) { File.join(collection_dir, [os_info['name'], os_info['release']['major'].gsub(%r{\s}, '_'),
|
|
11
|
+
let(:fact_collection) { File.join(collection_dir, [os_info['name'], os_info['release']['major'].gsub(%r{\s}, '_'), os_info['architecture']].join('-').downcase + '.facts') }
|
|
13
12
|
|
|
14
13
|
let(:host_data) { JSON.parse(File.read(fact_collection)) }
|
|
15
14
|
|
|
@@ -24,12 +23,12 @@ describe 'look out muppets' do
|
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
it 'disables the secondary network interface' do
|
|
27
|
-
interfaces = fact_on(host, 'interfaces').
|
|
26
|
+
interfaces = fact_on(host, 'networking.interfaces').keys
|
|
28
27
|
|
|
29
28
|
ifaces = {
|
|
30
29
|
'eth1' => 'ip link set eth1 down',
|
|
31
30
|
'enp0s8' => 'ip link set enp0s8 down',
|
|
32
|
-
'Ethernet 2' => 'netsh interface set interface "Ethernet 2" disable'
|
|
31
|
+
'Ethernet 2' => 'netsh interface set interface "Ethernet 2" disable',
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
ifaces.each_key do |iface|
|
|
@@ -56,12 +55,12 @@ describe 'look out muppets' do
|
|
|
56
55
|
it 'cleans up the data' do
|
|
57
56
|
str_data = JSON.generate(@output.first)
|
|
58
57
|
|
|
59
|
-
str_data = str_data.gsub(fact_on(host, 'fqdn'), 'foo.example.com')
|
|
60
|
-
.gsub(fact_on(host, 'domain'), 'example.com')
|
|
61
|
-
.gsub(%(:"#{fact_on(host, 'hostname')}"), ':"foo"')
|
|
62
|
-
.gsub(%(:"#{fact_on(host, 'networking')
|
|
63
|
-
.gsub(%(:"#{fact_on(host, 'networking')
|
|
64
|
-
.gsub(%(:"#{fact_on(host, 'networking')
|
|
58
|
+
str_data = str_data.gsub(fact_on(host, 'networking.fqdn'), 'foo.example.com')
|
|
59
|
+
.gsub(fact_on(host, 'networking.domain'), 'example.com')
|
|
60
|
+
.gsub(%(:"#{fact_on(host, 'networking.hostname')}"), ':"foo"')
|
|
61
|
+
.gsub(%(:"#{fact_on(host, 'networking.ip')}"), ':"10.0.2.15"')
|
|
62
|
+
.gsub(%(:"#{fact_on(host, 'networking.netmask')}"), ':"255.255.0.0"')
|
|
63
|
+
.gsub(%(:"#{fact_on(host, 'networking.network')}"), ':"10.0.2.0"')
|
|
65
64
|
.gsub(%r{"dhcp":"(.+?)"}, '"dhcp":"10.0.2.2"')
|
|
66
65
|
|
|
67
66
|
expect { JSON.parse(str_data) }.not_to raise_error
|
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'English'
|
|
3
|
+
require 'timeout'
|
|
4
|
+
|
|
5
|
+
# Regression tests for https://github.com/simp/rubygem-simp-rspec-puppet-facts/issues/86
|
|
6
|
+
#
|
|
7
|
+
# If a spec_helper does a top-level `include RspecPuppetFacts` before this gem
|
|
8
|
+
# is loaded (voxpupuli-test does this), a plain `extend ::RspecPuppetFacts` on
|
|
9
|
+
# the Shim is silently skipped because the module is already in Object's
|
|
10
|
+
# ancestry. A later top-level `include Simp::RspecPuppetFacts` then shadows
|
|
11
|
+
# the upstream method, and `Shim.on_supported_os` recurses without bound,
|
|
12
|
+
# consuming all available memory during fact loading.
|
|
13
|
+
describe 'Simp::RspecPuppetFacts::Shim' do
|
|
14
|
+
describe '.on_supported_os' do
|
|
15
|
+
it 'dispatches to the upstream rspec-puppet-facts implementation' do
|
|
16
|
+
expect(Simp::RspecPuppetFacts::Shim.method(:on_supported_os).owner)
|
|
17
|
+
.not_to eq Simp::RspecPuppetFacts
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'when RspecPuppetFacts was included at the top level before this gem was loaded' do
|
|
21
|
+
it 'terminates instead of recursing' do
|
|
22
|
+
# An OS release with no SIMP factset (Debian here) forces
|
|
23
|
+
# on_supported_os down the Shim path that used to recurse
|
|
24
|
+
script = <<~SCRIPT
|
|
25
|
+
require 'rspec'
|
|
26
|
+
require 'rspec-puppet-facts'
|
|
27
|
+
include RspecPuppetFacts
|
|
28
|
+
require 'simp/rspec-puppet-facts'
|
|
29
|
+
include Simp::RspecPuppetFacts
|
|
30
|
+
facts = on_supported_os(
|
|
31
|
+
supported_os: [
|
|
32
|
+
{ 'operatingsystem' => 'RedHat', 'operatingsystemrelease' => ['9'] },
|
|
33
|
+
{ 'operatingsystem' => 'Debian', 'operatingsystemrelease' => ['12'] },
|
|
34
|
+
],
|
|
35
|
+
)
|
|
36
|
+
exit!(1) unless facts.key?('redhat-9-x86_64')
|
|
37
|
+
puts 'SHIM_DISPATCH_OK'
|
|
38
|
+
SCRIPT
|
|
39
|
+
|
|
40
|
+
lib_dir = File.expand_path('../../lib', __dir__)
|
|
41
|
+
output = nil
|
|
42
|
+
Timeout.timeout(120) do
|
|
43
|
+
output = IO.popen([RbConfig.ruby, '-I', lib_dir, '-e', script], err: [:child, :out], &:read)
|
|
44
|
+
end
|
|
45
|
+
expect($CHILD_STATUS).to be_success, "subprocess failed (#{$CHILD_STATUS}):\n#{output}"
|
|
46
|
+
expect(output).to include('SHIM_DISPATCH_OK')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simp-rspec-puppet-facts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Tessmer
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-08-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: json
|
|
@@ -81,20 +81,6 @@ dependencies:
|
|
|
81
81
|
- - ">="
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '0'
|
|
84
|
-
- !ruby/object:Gem::Dependency
|
|
85
|
-
name: puppetlabs_spec_helper
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - ">="
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: '0'
|
|
91
|
-
type: :development
|
|
92
|
-
prerelease: false
|
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
-
requirements:
|
|
95
|
-
- - ">="
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
version: '0'
|
|
98
84
|
- !ruby/object:Gem::Dependency
|
|
99
85
|
name: rake
|
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -129,6 +115,20 @@ dependencies:
|
|
|
129
115
|
- - "~>"
|
|
130
116
|
- !ruby/object:Gem::Version
|
|
131
117
|
version: '3.13'
|
|
118
|
+
- !ruby/object:Gem::Dependency
|
|
119
|
+
name: rspec-puppet
|
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '5'
|
|
125
|
+
type: :development
|
|
126
|
+
prerelease: false
|
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '5'
|
|
132
132
|
- !ruby/object:Gem::Dependency
|
|
133
133
|
name: tins
|
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -398,6 +398,7 @@ files:
|
|
|
398
398
|
- spec/spec_helper.rb
|
|
399
399
|
- spec/spec_helper_acceptance.rb
|
|
400
400
|
- spec/unit/data_normalization_spec.rb
|
|
401
|
+
- spec/unit/shim_dispatch_spec.rb
|
|
401
402
|
- spec/unit/simp_rspec_puppet_facts_spec.rb
|
|
402
403
|
homepage: https://github.com/simp/rubygem-simp-rspec-puppet-facts
|
|
403
404
|
licenses:
|
|
@@ -450,6 +451,7 @@ test_files:
|
|
|
450
451
|
- spec/spec_helper.rb
|
|
451
452
|
- spec/spec_helper_acceptance.rb
|
|
452
453
|
- spec/unit/data_normalization_spec.rb
|
|
454
|
+
- spec/unit/shim_dispatch_spec.rb
|
|
453
455
|
- spec/unit/simp_rspec_puppet_facts_spec.rb
|
|
454
456
|
- facts/2.5/almalinux-8-x86_64.facts
|
|
455
457
|
- facts/2.5/almalinux-9-x86_64.facts
|