Skip to content

Commit f13f035

Browse files
mhashizumetvpartytonight
authored andcommitted
Update stdout and stderr methods
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.
1 parent ec32e61 commit f13f035

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

acceptance/tests/ensure_puppet-agent_paths.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,18 @@ def config_options(agent)
9090

9191
step 'test configprint outputs'
9292
agents.each do |agent|
93-
on(agent, puppet_agent('--configprint all')) do
94-
output = stdout
93+
on(agent, puppet_agent('--configprint all')) do |result|
9594
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
96-
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
95+
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
9796
end
9897
end
9998
end
10099

101100
step 'test puppet genconfig entries'
102101
agents.each do |agent|
103-
on(agent, puppet_agent('--genconfig')) do
104-
output = stdout
102+
on(agent, puppet_agent('--genconfig')) do |result|
105103
config_options(agent).select {|v| !v[:not_puppet_config] }.each do |config_option|
106-
assert_match("#{config_option[:name]} = #{config_option[:expected]}", output)
104+
assert_match("#{config_option[:name]} = #{config_option[:expected]}", result.stdout)
107105
end
108106
end
109107
end

acceptance/tests/ensure_puppet_facts_can_use_facter.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

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

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

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

2626
step "test that stderr is empty on puppet facts'" do
27-
on agent, puppet('facts'), :acceptable_exit_codes => [0] do
28-
assert_empty(stderr, "Expected `puppet facts` stderr to be empty")
27+
on(agent, puppet('facts'), :acceptable_exit_codes => [0]) do |result|
28+
assert_empty(result.stderr, "Expected `puppet facts` stderr to be empty")
2929
end
3030
end
3131
end

acceptance/tests/test_manpage_clobber.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
agents.each do |agent|
1111
man_command = nil
1212

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

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

21-
step "test if we have puppet manpages" do
22-
on agent, "#{man_command} puppet"
21+
step 'test if we have puppet manpages' do
22+
on(agent, "#{man_command} puppet")
2323
end
2424

25-
step "test if we have unix manpages" do
26-
on agent, "#{man_command} ls"
25+
step 'test if we have unix manpages' do
26+
on(agent, "#{man_command} ls")
2727
end
2828
end
2929
end

acceptance/tests/windows_eventlog.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
# generate an error, no master on windows boxes
2525
# we use `agent` because it creates an eventlog log destination by default,
2626
# whereas `apply` does not.
27-
on agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1]
27+
on(agent, puppet('agent', '--server', '127.0.0.1', '--test'), :acceptable_exit_codes => [1])
2828

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

0 commit comments

Comments
 (0)