Skip to content

Commit

Permalink
Merge pull request #2482 from mhashizume/PA-5022/main/beaker-deprecated
Browse files Browse the repository at this point in the history
Update stdout and stderr methods
  • Loading branch information
tvpartytonight authored Feb 5, 2024
2 parents f1cce80 + f13f035 commit 78463e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
16 changes: 5 additions & 11 deletions acceptance/tests/ensure_puppet-agent_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ def config_options(agent)
platform = agent[:platform]
case platform
when /windows/
if platform =~ /2003/
common_app_data = 'C:/Documents and Settings/All Users/Application Data'
else
common_app_data = 'C:/ProgramData'
end
common_app_data = 'C:/ProgramData'
puppetlabs_data = "#{common_app_data}/PuppetLabs"

codedir = "#{puppetlabs_data}/code"
Expand Down Expand Up @@ -94,20 +90,18 @@ def config_options(agent)

step 'test configprint outputs'
agents.each do |agent|
on(agent, puppet_agent('--configprint all')) do
output = stdout
on(agent, puppet_agent('--configprint all')) do |result|
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
end
end
end

step 'test puppet genconfig entries'
agents.each do |agent|
on(agent, puppet_agent('--genconfig')) do
output = stdout
on(agent, puppet_agent('--genconfig')) do |result|
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions acceptance/tests/ensure_puppet_facts_can_use_facter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

agents.each do |agent|
step 'test puppet facts with correct facter version' do
on agent, puppet('facts'), :acceptable_exit_codes => [0] do
facter_major_version = Integer(JSON.parse(stdout)["facterversion"].split('.').first)
on(agent, puppet('facts'), :acceptable_exit_codes => [0]) do |result|
facter_major_version = Integer(JSON.parse(result.stdout)["facterversion"].split('.').first)
assert(4 >= facter_major_version, "wrong facter version")
end
end

step "test puppet facts with facter has all the dependencies installed" do
on agent, puppet('facts --debug'), :acceptable_exit_codes => [0] do
on(agent, puppet('facts --debug'), :acceptable_exit_codes => [0]) do |result|
if agent['platform'] =~ /win/
# exclude augeas as it is not provided on Windows
unresolved_fact = stdout.match(/(resolving fact (?!augeas).+\, but)/)
unresolved_fact = result.stdout.match(/(resolving fact (?!augeas).+\, but)/)
else
unresolved_fact = stdout.match(/(resolving fact .+\, but)/)
unresolved_fact = result.stdout.match(/(resolving fact .+\, but)/)
end

assert_nil(unresolved_fact, "missing dependency for facter from: #{unresolved_fact.inspect}")
end
end

step "test that stderr is empty on puppet facts'" do
on agent, puppet('facts'), :acceptable_exit_codes => [0] do
assert_empty(stderr, "Expected `puppet facts` stderr to be empty")
on(agent, puppet('facts'), :acceptable_exit_codes => [0]) do |result|
assert_empty(result.stderr, "Expected `puppet facts` stderr to be empty")
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions acceptance/tests/test_manpage_clobber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
agents.each do |agent|
man_command = nil

step "test for man command" do
on agent, "command -v man", :acceptable_exit_codes => [0, 1] do
man_command = stdout.chomp
step 'test for man command' do
on(agent, 'command -v man', :acceptable_exit_codes => [0, 1]) do |result|
man_command = result.stdout.chomp
end
end

skip_test "man command not found on #{agent.hostname} (#{agent.platform})" unless man_command

step "test if we have puppet manpages" do
on agent, "#{man_command} puppet"
step 'test if we have puppet manpages' do
on(agent, "#{man_command} puppet")
end

step "test if we have unix manpages" do
on agent, "#{man_command} ls"
step 'test if we have unix manpages' do
on(agent, "#{man_command} ls")
end
end
end
6 changes: 3 additions & 3 deletions acceptance/tests/windows_eventlog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
# generate an error, no master on windows boxes
# we use `agent` because it creates an eventlog log destination by default,
# whereas `apply` does not.
on agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1]
on(agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1])

# make sure there's a Puppet error message in the log
# cygwin + ssh + wmic hangs trying to read stdin, so echo '' |
on agent, "cmd /c echo '' | wmic ntevent where \"LogFile='Application' and SourceName='Puppet' and TimeWritten >= '#{now}'\" get Message,Type /format:csv" do
on(agent, "cmd /c echo '' | wmic ntevent where \"LogFile='Application' and SourceName='Puppet' and TimeWritten >= '#{now}'\" get Message,Type /format:csv") do |result|
fail_test "Event not found in Application event log" unless
stdout.include?('target machine actively refused it. - connect(2) for "127.0.0.1"')
result.stdout.include?('target machine actively refused it. - connect(2) for "127.0.0.1"')
end
end

0 comments on commit 78463e0

Please sign in to comment.