Skip to content

Commit

Permalink
(FACT-2817) Add acceptance test for session cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanIrimie committed Oct 8, 2020
1 parent a8b1a27 commit bb6357e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 27 additions & 0 deletions acceptance/tests/session_cached_is_not_refershed_in_session.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
test_name 'facter should not update it`s session cache in same session' do
tag 'risk:high'

fact_content = <<-EOM
require 'facter'
seconds_before = Facter.value('system_uptime.seconds')
sleep(3)
seconds_after = Facter.value('system_uptime.seconds')
puts seconds_before == seconds_after
EOM

agents.each do |agent|
fact_dir = agent.tmpdir('test_scripts')
script_path = File.join(fact_dir, 'session_test.rb')
create_remote_file(agent, script_path, fact_content)

teardown do
agent.rm_rf(script_path)
end

on(agent, "#{ruby_command(agent)} #{script_path}") do |ruby_result|
assert_equal('true', ruby_result.stdout.chomp, 'Expect the session cache is not reset in same session')
end
end
end
1 change: 0 additions & 1 deletion custom_facts/my_custom_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Facter.add(:my_custom_fact) do
has_weight(10_000)
setcode do
# 'my_custom_fact'
Facter.value('os')
end
end

0 comments on commit bb6357e

Please sign in to comment.