Skip to content

Commit

Permalink
Update stdout and stderr methods
Browse files Browse the repository at this point in the history
Previously in Beaker, you could use standalone stdout and stderr methods
to access output from remote machines.

These methods were deprecated in 2013 with voxpupuli/beaker@28b2510 and
dropped entirely in voxpupuli/beaker@73a31c7.

This commit removes these methods from puppet-agent tests in favor of
calling stdout and stderr methods on Result objects.
  • Loading branch information
mhashizume committed Feb 1, 2024
1 parent 305b073 commit 17a052c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
10 changes: 4 additions & 6 deletions acceptance/tests/ensure_puppet-agent_paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,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 17a052c

Please sign in to comment.