Sha256: 60a570a145396710ee6c7faac701ca23f3e483ae36c777f056e1fa7db4984b46
Contents?: true
Size: 1.98 KB
Versions: 18
Compression:
Stored size: 1.98 KB
Contents
# This test verifies that cached facts are used while still valid test_name "C100041: ttls configured cached facts are used while still valid" do tag 'risk:high' require 'facter/acceptance/user_fact_utils' extend Facter::Acceptance::UserFactUtils # This fact must be resolvable on ALL platforms # Do NOT use the 'kernel' fact as it is used to configure the tests cached_factname = 'uptime' config = <<EOM facts : { ttls : [ { "#{cached_factname}" : 30 days } ] } EOM cached_fact_value = "CACHED_FACT_VALUE" cached_fact_content = <<EOM { "#{cached_factname}": "#{cached_fact_value}" } EOM agents.each do |agent| step "Agent #{agent}: create config file" do config_dir = get_default_fact_dir(agent['platform'], on(agent, facter('kernelmajversion')).stdout.chomp.to_f) config_file = File.join(config_dir, "facter.conf") cached_facts_dir = get_cached_facts_dir(agent['platform'], on(agent, facter('kernelmajversion')).stdout.chomp.to_f) cached_fact_file = File.join(cached_facts_dir, cached_factname) # Setup facter conf on(agent, "mkdir -p '#{config_dir}'") create_remote_file(agent, config_file, config) teardown do on(agent, "rm -rf '#{config_dir}'", :acceptable_exit_codes => [0, 1]) on(agent, "rm -rf '#{cached_facts_dir}'", :acceptable_exit_codes => [0, 1]) end step "should read from a cached JSON file for a fact that has been cached" do # Setup a known cached fact on(agent, "rm -rf '#{cached_facts_dir}'", :acceptable_exit_codes => [0, 1]) on(agent, facter("")) create_remote_file(agent, cached_fact_file, cached_fact_content) on(agent, facter("#{cached_factname} --debug")) do assert_match(/loading cached values for .+ facts/, stderr, "Expected debug message to state that values are read from cache") assert_match(/#{cached_fact_value}/, stdout, "Expected fact to match the cached fact file") end end end end end
Version data entries
18 entries across 18 versions & 2 rubygems