Sha256: c3ae63c903d75e6b00354bddb2cb21dd712ed5b0237d95d3fd4d2da2915de4ae

Contents?: true

Size: 1.88 KB

Versions: 18

Compression:

Stored size: 1.88 KB

Contents

# Verify that setting a ttls, creates a json file for the cached fact when run
# from puppet facts
test_name "C100038: with ttls configured create cached facts when run from puppet facts" do
  tag 'risk:medium'

  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

  agents.each do |agent|
    step "Agent #{agent}: create config file" do
      facter_conf_default_dir = get_default_fact_dir(agent['platform'], on(agent, facter('kernelmajversion')).stdout.chomp.to_f)
      facter_conf_default_path = File.join(facter_conf_default_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)

      on(agent, "mkdir -p '#{facter_conf_default_dir}'")
      create_remote_file(agent, facter_conf_default_path, config)

      teardown do
        on(agent, "rm -rf '#{cached_facts_dir}' '#{facter_conf_default_dir}'", :acceptable_exit_codes => [0, 1])
      end

      step "should create a JSON file for a fact that is to be cached" do
        on(agent, "rm -rf '#{cached_facts_dir}'", :acceptable_exit_codes => [0, 1])
        on(agent, puppet("facts --debug")) do |pupppet_fact_output|
          assert_match(/caching values for .+ facts/, pupppet_fact_output.stdout, "Expected debug message to state that values will be cached")
        end
        on(agent, "cat #{cached_fact_file}", :acceptable_exit_codes => [0]) do |cat_output|
          assert_match(/#{cached_factname}/, cat_output.stdout, "Expected cached fact file to contain fact information")
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
facter-4.0.29 acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-4.0.28 acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.2.cfacter.20181217 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.1.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.6.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.1.cfacter.20181023 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.5.cfacter.20181022 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.0.cfacter.20181004 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.0.cfacter.20181001 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.12.0.cfacter.20180918 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.4.cfacter.20180821 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.3.cfacter.20180716 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.2.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.9.6.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.2.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.9.6.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
facter-3.11.0.cfacter.20180319 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb
cfacter-3.11.0.rc.20180314 ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb