-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
facts > 2.5 not working as expected #61
Comments
Please try specifying the facter version you want to test through setting Related, there is talk on getting cfacter (that is, facter 3) into gems for testing: https://tickets.puppetlabs.com/browse/FACT-1542 . please vote there to help prioritise this issue. |
@DavidS any good way to get this in the spec_helper.rb so I don't have to specify in the array of the spec test? |
@DavidS tried the following but didn't work (you can see the commented out stubbed fact I had to use before):
Even tried:
|
I even tried to move this to spec_helper.rb with no luck: RSpec.configure do |c|
c.tty = true
c.mock_framework = :rspec
c.mock_with(:rspec)
c.after(:suite) do
RSpec::Puppet::Coverage.report!(95)
end
c.hiera_config = File.expand_path(
File.join(__FILE__, '../fixtures/hiera.yaml')
)
default_facts = {
puppetversion: Puppet.version,
facterversion: '3.6.4'
}
c.default_facts = default_facts
end But oddly if I do this in my own script it will return just fine ( facterversion > 2.5.1 ): require 'facterdb'
require 'rspec-puppet-facts'
facterversion = ARGV[0]
facter_version_filter = RspecPuppetFacts.facter_version_to_filter(facterversion)
db = FacterDB.get_facts({ :facterversion => facter_version_filter })
version = facterversion
filter = []
filter << {
:facterversion => facter_version_filter,
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => '7',
:hardwaremodel => 'x86_64',
}
received_facts = FacterDB::get_facts(filter)
puts received_facts[0].to_h[:memory]['system']['total_bytes']
|
I found a way to do it within the individual spec ... the on_supported_os({
facterversion: '3.7',
supported_os: [
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => [
'7'
]
}
]
}).each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({
puppetversion: Puppet.version,
sudoversion: '1.7.10p9',
ap_env: 'dev',
role: 'mapi',
awsregion: 'us-east-1'
# memory: {
# system: {
# total_bytes: '1111'
# }
# }
})
end Does anyone know how to get that to work from the spec_helper.rb example above... doesn't appear to be reading |
Any update on this, fighting with the same issue. |
Ugly as it is the way I worked around this in my spec_helper file was to do something like this require 'facter'
module Facter
def self.version
ENV['FACTER_VERSION'] || '3.8.0'
end
end |
Facter 2.5.1 appears to be working. If someone would like to send a patch to allow for cfacter, I would be happy to add it to the test matrix. |
In doing some testing if you lookup
%{::memory.system.total_bytes}
it returns null and I believe that is because puppet requires facter and the latest version if 2.5.1 and in that facts set there is no fact for that even though for example4.10.1
ships with3.6.4
and it is available in facterdb under3.6
folder.I think there either needs to be a facter gem published to support later than
2.5
or some way for rspec-puppet-facts to use the 3.x facts from facterdbThe text was updated successfully, but these errors were encountered: