-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(FACT-2793) Time limit for Facter::Core::Execute
- Loading branch information
Oana Tanasoiu
committed
Sep 21, 2020
1 parent
28677be
commit 7e8b689
Showing
5 changed files
with
118 additions
and
40 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
acceptance/tests/custom_facts/time_limit_for_execute_command.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
test_name 'Facter::Core::Execution accepts and correctly sets a time limit option' do | ||
tag 'risk:high' | ||
|
||
first_file_content = <<-EOM | ||
Facter.add(:foo) do | ||
setcode do | ||
Facter::Core::Execution.execute("ping 127.0.0.1", {:limit => 2}) | ||
end | ||
end | ||
EOM | ||
|
||
second_file_content = <<-EOM | ||
Facter.add(:custom_fact) do | ||
setcode do | ||
Facter::Core::Execution.execute("ping 127.0.0.1") | ||
end | ||
end | ||
EOM | ||
|
||
|
||
agents.each do |agent| | ||
|
||
custom_dir = agent.tmpdir('arbitrary_dir') | ||
fact_file1 = File.join(custom_dir, 'file1.rb') | ||
fact_file2 = File.join(custom_dir, 'file2.rb') | ||
create_remote_file(agent, fact_file1, first_file_content) | ||
create_remote_file(agent, fact_file2, second_file_content) | ||
|
||
teardown do | ||
agent.rm_rf(custom_dir) | ||
end | ||
|
||
step "Facter: Logs that command of the first custom fact had timeout after setted time limit" do | ||
on agent, facter('--custom-dir', custom_dir, 'foo --debug') do |facter_output| | ||
assert_match(/DEBUG Facter::Core::Execution.* - Timeout encounter after 2s, killing process with pid:/, | ||
facter_output.stderr.chomp) | ||
end | ||
end | ||
|
||
step "Facter: Logs that command of the second custom fact had timeout after befault time limit" do | ||
on agent, facter('--custom-dir', custom_dir, 'custom_fact --debug') do |facter_output| | ||
assert_match(/DEBUG Facter::Core::Execution.* - Timeout encounter after 1.5s, killing process with pid:/, | ||
facter_output.stderr.chomp) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters