Skip to content

Commit

Permalink
Merge pull request #2675 from mhashizume/PA-5022/main/beaker-deprecated
Browse files Browse the repository at this point in the history
Update deprecated Beaker methods
  • Loading branch information
mhashizume authored Feb 10, 2024
2 parents 3974869 + e4e4f32 commit f0a6704
Show file tree
Hide file tree
Showing 44 changed files with 121 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
on(agent, "#{ruby_command(agent)} #{facter_rb}") do |result|
output = result.stdout.strip
assert_match(/has resolved to: #{fact_name}/, output, 'Incorrect fact value for custom fact')
assert_no_match(/Searching fact: #{fact_name} in all custom facts/, output, 'Loaded all custom facts')
refute_match(/Searching fact: #{fact_name} in all custom facts/, output, 'Loaded all custom facts')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/api/value/external_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
on(agent, "#{ruby_command(agent)} #{facter_rb}") do |result|
output = result.stdout.strip
assert_match(/has resolved to: 123/, output, 'Incorrect fact value for external fact')
assert_no_match(/in all custom facts/, output, 'Loaded all custom facts')
refute_match(/in all custom facts/, output, 'Loaded all custom facts')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/api/value/non_existent_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

on(agent, "#{ruby_command(agent)} #{facter_rb}") do |result|
output = result.stdout.strip
assert_no_match(/has resolved to: /, output, 'Fact was found')
refute_match(/has resolved to: /, output, 'Fact was found')
assert_match(
/Searching fact: #{fact_name} in file: #{fact_name}.rb/,
output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def create_api_call_file(test_vars, facter_querry)
step "Agent #{agent}: Verify that custom fact 2 is missing" do
create_api_call_file(test_vars, "puts Facter.value('custom_fact_2')")
on(agent, "#{ruby_command(agent)} #{test_vars[:test_script_path]}") do |ruby_result|
assert_no_match(/custom_fact_2_value/, ruby_result.stdout.chomp)
refute_match(/custom_fact_2_value/, ruby_result.stdout.chomp)
end
end

step "Agent #{agent}: Verify that custom fact 3 is missing" do
create_api_call_file(test_vars, "puts Facter.value('custom_fact_3')")
on(agent, "#{ruby_command(agent)} #{test_vars[:test_script_path]}") do |ruby_result|
assert_no_match(/custom_fact_3_value/, ruby_result.stdout.chomp)
refute_match(/custom_fact_3_value/, ruby_result.stdout.chomp)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
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 |output|
on(agent, facter('--custom-dir', custom_dir, 'foo --debug')) do |output|
assert_match(/DEBUG Facter::Core::Execution.*Timeout encounter after 2s, killing process with pid:/,
output.stderr.chomp)
end
end

step "Facter: Logs an error stating that the command of the second custom fact had timeout" do
on(agent, facter('--custom-dir', custom_dir, 'custom_fact --debug'), acceptable_exit_codes: 1) do |output|
on(agent, facter('--custom-dir', custom_dir, 'custom_fact --debug'), acceptable_exit_codes: [1]) do |output|
assert_match(/ERROR\s+.*Failed while executing '.*sleep.*2': Timeout encounter after 1s, killing process/,
output.stderr.chomp)
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/external_facts/block_external_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
step "agent #{agent}: resolve the external fact" do
on(agent, facter("--debug --external-dir \"#{facts_dir}\" --config \"#{config_file}\"")) do |facter_output|
assert_match(/External fact file external_fact_1#{ext} blocked./, facter_output.stderr.chomp, 'Expected to block the external_fact')
assert_no_match(/external_fact => external_value/, stdout, 'Expected fact not to match fact')
refute_match(/external_fact => external_value/, facter_output.stdout, 'Expected fact not to match fact')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

step 'works if ttl is not enabled' do
on(agent, facter("--external-dir \"#{external_dir1}\" --external-dir \"#{external_dir2}\" --debug #{fact1} #{fact2}")) do |facter_output|
assert_match(/#{fact1} => #{fact1_value}/, stdout, 'Expected fact to match first fact')
assert_match(/#{fact2} => #{fact2_value}/, stdout, 'Expected fact to match second fact')
assert_match(/#{fact1} => #{fact1_value}/, facter_output.stdout, 'Expected fact to match first fact')
assert_match(/#{fact2} => #{fact2_value}/, facter_output.stdout, 'Expected fact to match second fact')
end
end

Expand All @@ -50,9 +50,9 @@
agent.mkdir_p(config_dir)
create_remote_file(agent, config_file, config)
on(agent, facter("--external-dir \"#{external_dir1}\" --external-dir \"#{external_dir2}\" --debug #{fact1} #{fact2}"), :acceptable_exit_codes => 1) do |facter_output|
assert_match(/ERROR.*Caching is enabled for group "#{external_filename}" while there are at least two external facts files with the same filename/, stderr, 'Expected error message')
assert_match(/#{fact1} => #{fact1_value}/, stdout, 'Expected fact to match first fact')
refute_match(/#{fact2} => #{fact2_value}/, stdout, 'Expected fact not to match second fact')
assert_match(/ERROR.*Caching is enabled for group "#{external_filename}" while there are at least two external facts files with the same filename/, facter_output.stderr, 'Expected error message')
assert_match(/#{fact1} => #{fact1_value}/, facter_output.stdout, 'Expected fact to match first fact')
refute_match(/#{fact2} => #{fact2_value}/, facter_output.stdout, 'Expected fact not to match second fact')
end
end

Expand Down
16 changes: 8 additions & 8 deletions acceptance/tests/external_facts/structured_executable_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
agent.chmod('+x', yaml_fact)

step "YAML output should produce a structured fact" do
on(agent, facter("yaml_fact")) do
assert_match(/#{yaml_structured_output}/, stdout, "Expected properly structured fact")
on(agent, facter("yaml_fact")) do |facter_output|
assert_match(/#{yaml_structured_output}/, facter_output.stdout, "Expected properly structured fact")
end
end
end
Expand All @@ -106,8 +106,8 @@
agent.chmod('+x', json_fact)

step "JSON output should produce a structured fact" do
on(agent, facter("json_fact")) do
assert_match(/#{json_structured_output}/, stdout, "Expected properly structured fact")
on(agent, facter("json_fact")) do |facter_output|
assert_match(/#{json_structured_output}/, facter_output.stdout, "Expected properly structured fact")
end
end
end
Expand All @@ -118,8 +118,8 @@
agent.chmod('+x', kv_fact)

step "output that is neither yaml nor json should not produce a structured fact" do
on(agent, facter("kv_fact")) do
assert_match(/#{kv_output}/, stdout, "Expected a simple key-value fact")
on(agent, facter("kv_fact")) do |facter_output|
assert_match(/#{kv_output}/, facter_output.stdout, "Expected a simple key-value fact")
end
end
end
Expand All @@ -130,8 +130,8 @@
agent.chmod('+x', bad_fact)

step "should error when output is not in a supported format" do
on(agent, facter("bad_fact --debug")) do
assert_match(/Could not parse executable fact/, stderr, "Expected parsing the malformed fact to fail")
on(agent, facter("bad_fact --debug")) do |facter_output|
assert_match(/Could not parse executable fact/, facter_output.stderr, "Expected parsing the malformed fact to fail")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/facts/mountpoints_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
agents.each do |agent|
step 'Ensure that mountpoints does not contain rootfs as type for root directory' do
on(agent, facter("mountpoints")) do |facter_result|
assert_no_match(/rootfs/, facter_result.stdout.chomp, "Expected mountpoint with rootfs type to not be present")
refute_match(/rootfs/, facter_result.stdout.chomp, "Expected mountpoint with rootfs type to not be present")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions acceptance/tests/facts/verify_tmpfs_file_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

step "Apply the manifest to mount directory '#{mount_point}'" do
on(agent, puppet("apply #{manifest}"), :acceptable_exit_codes => [0,2]) do |puppet_apply|
assert_no_match(/Error/, puppet_apply.stdout, 'Unexpected error on stdout was detected!')
assert_no_match(/ERROR/, puppet_apply.stderr, 'Unexpected error on stderr was detected!')
refute_match(/Error/, puppet_apply.stdout, 'Unexpected error on stdout was detected!')
refute_match(/ERROR/, puppet_apply.stderr, 'Unexpected error on stderr was detected!')
end
end

Expand Down
6 changes: 3 additions & 3 deletions acceptance/tests/options/config_file/blocklist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
assert_match(/blocking collection of .+ facts/, facter_output.stderr, "Expected stderr to contain statement about blocking fact collection")

# on some platforms, file system facts are never resolved, so this will also be true in those cases
assert_no_match(/filesystems/, facter_output.stdout, "filesystems fact should have been blocked")
assert_no_match(/mountpoints/, facter_output.stdout, "mountpoints fact should have been blocked")
assert_no_match(/partitions/, facter_output.stdout, "partitions fact should have been blocked")
refute_match(/filesystems/, facter_output.stdout, "filesystems fact should have been blocked")
refute_match(/mountpoints/, facter_output.stdout, "mountpoints fact should have been blocked")
refute_match(/partitions/, facter_output.stdout, "partitions fact should have been blocked")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
assert_match(/blocking collection of .+ facts/, puppet_facts_output.stdout, "Expected stderr to contain statement about blocking fact collection")

# on some platforms, file system facts are never resolved, so this will also be true in those cases
assert_no_match(/filesystems/, puppet_facts_output.stdout, "filesystems fact should have been blocked")
assert_no_match(/mountpoints/, puppet_facts_output.stdout, "mountpoints fact should have been blocked")
assert_no_match(/partitions/, puppet_facts_output.stdout, "partitions fact should have been blocked")
refute_match(/filesystems/, puppet_facts_output.stdout, "filesystems fact should have been blocked")
refute_match(/mountpoints/, puppet_facts_output.stdout, "mountpoints fact should have been blocked")
refute_match(/partitions/, puppet_facts_output.stdout, "partitions fact should have been blocked")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{first_fact_name}")) do |facter_output|
assert_match(/loading cached values for #{external_cachegroup}#{ext} 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")
assert_match(/loading cached values for #{external_cachegroup}#{ext} facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

on(agent, facter("--config \"#{no_cache_config_file}\" --external-dir \"#{external_dir}\"", environment: env)) do |facter_output|
assert_match(/#{cached_fact_name}/, facter_output.stdout, "Expected to see the fact in output")
assert_no_match(/#{cached_fact_value}/, facter_output.stdout, "Expected to not see the cached fact value")
refute_match(/#{cached_fact_value}/, facter_output.stdout, "Expected to not see the cached fact value")
end

assert_equal(true, agent.file_exist?("#{cached_facts_dir}/cached-custom-facts"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("--external-dir \"#{external_dir}\" --debug #{cached_fact_name}")) do |facter_output|
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")
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# Read cached fact file content
cat_output = agent.cat(cached_fact_file)
assert_no_match(/#{cached_fact_value}/, cat_output.strip, "Expected cached fact file to be refreshed")
refute_match(/#{cached_fact_value}/, cat_output.strip, "Expected cached fact file to be refreshed")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
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")
on(agent, facter("#{cached_factname} --debug")) do |facter_output|
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

on(agent, facter("--config \"#{no_cache_config_file}\"")) do |facter_output|
assert_match(/#{cached_fact_name}/, facter_output.stdout, "Expected to see the fact in output")
assert_no_match(/#{cached_fact_value}/, facter_output.stdout, "Expected to not see the cached fact value")
refute_match(/#{cached_fact_value}/, facter_output.stdout, "Expected to not see the cached fact value")
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
# Corrupt the cached fact file
create_remote_file(agent, cached_fact_file, 'ThisIsNotvalidJSON')

on(agent, facter("#{cached_factname}")) do
assert_match(/.+/, stdout, "Expected fact to be resolved")
on(agent, facter("#{cached_factname}")) do |facter_output|
assert_match(/.+/, facter_output.stdout, "Expected fact to be resolved")
end
cat_output = agent.cat(cached_fact_file)
assert_match(/#{cached_factname}/, cat_output.strip, "Expected cachced fact to contain the fact name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
agent.mkdir_p(cached_facts_dir)
create_remote_file(agent, cached_fact_file, cached_fact_content)

on(agent, facter("#{cached_fact_name} --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")
on(agent, facter("#{cached_fact_name} --debug")) do |facter_output|
assert_match(/loading cached values for .+ facts/, facter_output.stderr, "Expected debug message to state that values are read from cache")
assert_match(/#{cached_fact_value}/, facter_output.stdout, "Expected fact to match the cached fact file")
end
end
end
Expand Down
Loading

0 comments on commit f0a6704

Please sign in to comment.