Skip to content

Commit bb6357e

Browse files
author
BogdanIrimie
committed
(FACT-2817) Add acceptance test for session cache.
1 parent a8b1a27 commit bb6357e

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
test_name 'facter should not update it`s session cache in same session' do
2+
tag 'risk:high'
3+
4+
fact_content = <<-EOM
5+
require 'facter'
6+
7+
seconds_before = Facter.value('system_uptime.seconds')
8+
sleep(3)
9+
seconds_after = Facter.value('system_uptime.seconds')
10+
11+
puts seconds_before == seconds_after
12+
EOM
13+
14+
agents.each do |agent|
15+
fact_dir = agent.tmpdir('test_scripts')
16+
script_path = File.join(fact_dir, 'session_test.rb')
17+
create_remote_file(agent, script_path, fact_content)
18+
19+
teardown do
20+
agent.rm_rf(script_path)
21+
end
22+
23+
on(agent, "#{ruby_command(agent)} #{script_path}") do |ruby_result|
24+
assert_equal('true', ruby_result.stdout.chomp, 'Expect the session cache is not reset in same session')
25+
end
26+
end
27+
end

custom_facts/my_custom_fact.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Facter.add(:my_custom_fact) do
44
has_weight(10_000)
55
setcode do
6-
# 'my_custom_fact'
76
Facter.value('os')
87
end
98
end

0 commit comments

Comments
 (0)