Skip to content

Commit c4d6e53

Browse files
committed
Update Beaker result proxies on host object
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 updates any methods that were initially missed in the first pass of this work in commit 9f5f8e5.
1 parent a3e77e7 commit c4d6e53

9 files changed

+27
-27
lines changed

acceptance/lib/puppet/acceptance/environment_utils.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,20 @@ def use_an_environment(environment, description, master_opts, envdir, confdir, o
241241
# Test agents configured to use directory environments (affects environment
242242
# loading on the agent, especially with regards to requests/node environment)
243243
args << "--environmentpath='$confdir/environments'" if directory_environments && agent != master
244-
on(agent, puppet("agent", *args), :acceptable_exit_codes => (0..255)) do
244+
on(agent, puppet("agent", *args), :acceptable_exit_codes => (0..255)) do |result|
245245
agent_results[:puppet_agent] = result
246246
end
247247

248248
args = ["--trace"]
249249
args << ["--environment", environment] if environment
250250

251251
step "print puppet config for #{description} environment"
252-
on(master, puppet(*(["config", "print", "basemodulepath", "modulepath", "manifest", "config_version", config_print] + args)), :acceptable_exit_codes => (0..255)) do
252+
on(master, puppet(*(["config", "print", "basemodulepath", "modulepath", "manifest", "config_version", config_print] + args)), :acceptable_exit_codes => (0..255)) do |result|
253253
agent_results[:puppet_config] = result
254254
end
255255

256256
step "puppet apply using #{description} environment"
257-
on(master, puppet(*(["apply", '-e', '"include testing_mod"'] + args)), :acceptable_exit_codes => (0..255)) do
257+
on(master, puppet(*(["apply", '-e', '"include testing_mod"'] + args)), :acceptable_exit_codes => (0..255)) do |result|
258258
agent_results[:puppet_apply] = result
259259
end
260260
end

acceptance/lib/puppet/acceptance/module_utils.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def get_default_modulepath_for_host(host)
4444
# @param host [String] hostname
4545
# @return [Array] paths for found modules
4646
def get_installed_modules_for_host(host)
47-
on host, puppet("module list --render-as json")
48-
str = stdout.lines.to_a.last
49-
pat = /\(([^()]+)\)/
50-
mods = str.scan(pat).flatten
51-
return mods
47+
on(host, puppet('module list --render-as json')) do |result|
48+
str = result.stdout.lines.to_a.last
49+
pat = /\(([^()]+)\)/
50+
mods = str.scan(pat).flatten
51+
return mods
52+
end
5253
end
5354

5455
# Return a hash of array of paths to installed modules for a hosts.

acceptance/lib/puppet/acceptance/service_utils.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def ensure_service_change_on_host(host, service, status)
4242
# that the exit code is either
4343
# 2 => something changed, or
4444
# 0 => no change needed
45-
apply_manifest_on host, service_manifest(service, status), :acceptable_exit_codes => [0, 2] do
46-
assert_match(/Service\[#{service}\]\/ensure: ensure changed '\w+' to '#{status[:ensure]}'/, stdout, 'Service status change failed') if status[:ensure]
47-
assert_match(/Service\[#{service}\]\/enable: enable changed '\w+' to '#{status[:enable]}'/, stdout, 'Service enable change failed') if status[:enable]
45+
apply_manifest_on(host, service_manifest(service, status), :acceptable_exit_codes => [0, 2]) do |result|
46+
assert_match(/Service\[#{service}\]\/ensure: ensure changed '\w+' to '#{status[:ensure]}'/, result.stdout, 'Service status change failed') if status[:ensure]
47+
assert_match(/Service\[#{service}\]\/enable: enable changed '\w+' to '#{status[:enable]}'/, result.stdout, 'Service enable change failed') if status[:enable]
4848
end
4949
end
5050

@@ -56,9 +56,9 @@ def ensure_service_change_on_host(host, service, status)
5656
# @return None
5757
def ensure_service_idempotent_on_host(host, service, status)
5858
# ensure idempotency
59-
apply_manifest_on host, service_manifest(service, status) do
60-
assert_no_match(/Service\[#{service}\]\/ensure/, stdout, 'Service status not idempotent') if status[:ensure]
61-
assert_no_match(/Service\[#{service}\]\/enable/, stdout, 'Service enable not idempotent') if status[:enable]
59+
apply_manifest_on(host, service_manifest(service, status)) do |result|
60+
assert_no_match(/Service\[#{service}\]\/ensure/, result.stdout, 'Service status not idempotent') if status[:ensure]
61+
assert_no_match(/Service\[#{service}\]\/enable/, result.stdout, 'Service enable not idempotent') if status[:enable]
6262
end
6363
end
6464

@@ -86,8 +86,8 @@ def assert_service_status_on_host(host, service, status, &block)
8686
ensure_status = "ensure.+=> '#{status[:ensure]}'" if status[:ensure]
8787
enable_status = "enable.+=> '#{status[:enable]}'" if status[:enable]
8888

89-
on host, puppet_resource('service', service) do
90-
assert_match(/'#{service}'.+#{ensure_status}.+#{enable_status}/m, stdout, "Service status does not match expectation #{status}")
89+
on(host, puppet_resource('service', service)) do |result|
90+
assert_match(/'#{service}'.+#{ensure_status}.+#{enable_status}/m, result.stdout, "Service status does not match expectation #{status}")
9191
end
9292

9393
# Verify service state on the system using a custom block

acceptance/tests/agent/agent_disable_lockfile.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666

6767
step "attempt to run the agent (message: '#{expected_message}')" do
6868
agents.each do |agent|
69-
on(agent, puppet('agent', "--test"),
70-
:acceptable_exit_codes => [1]) do
69+
on(agent, puppet('agent', "--test"), :acceptable_exit_codes => [1]) do |result|
7170
disabled_regex = /administratively disabled.*'#{expected_message}'/
7271
unless result.stdout =~ disabled_regex
7372
fail_test("Unexpected output from attempt to run agent disabled; expecting to match '#{disabled_regex}', got '#{result.stdout}' on agent '#{agent}'") unless agent['locale'] == 'ja'

acceptance/tests/environment/can_enumerate_environments.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def curl_master_from(agent, path, headers = '', &block)
6565
end
6666

6767
step "Ensure that an authenticated client can retrieve the list of environments" do
68-
curl_master_from(master, '/puppet/v3/environments') do
69-
data = JSON.parse(stdout)
68+
curl_master_from(master, '/puppet/v3/environments') do |result|
69+
data = JSON.parse(result.stdout)
7070
assert_equal(["env1", "env2", "production"], data["environments"].keys.sort)
7171
end
7272
end

acceptance/tests/environment/directory_environment_production_created_master.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
step 'ensure catalog returned from production env with no changes'
3636
agents.each do |agent|
37-
on(agent, puppet("agent -t --environment production --detailed-exitcodes")) do
37+
on(agent, puppet("agent -t --environment production --detailed-exitcodes")) do |result|
3838
# detailed-exitcodes produces a 0 when no changes are made.
39-
assert_equal(0, exit_code)
39+
assert_equal(0, result.exit_code)
4040
end
4141
end
4242
end

acceptance/tests/pluginsync/7316_faces_with_app_stubs_should_be_available_via_pluginsync.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ class Puppet::Application::#{app_name.capitalize} < Puppet::Application::FaceBas
133133

134134
step "verify that the application shows up in help" do
135135
agents.each do |agent|
136-
on(agent, PuppetCommand.new(:help, "--libdir=\"#{get_test_file_path(agent, agent_lib_dir)}\"")) do
136+
on(agent, PuppetCommand.new(:help, "--libdir=\"#{get_test_file_path(agent, agent_lib_dir)}\"")) do |result|
137137
assert_match(/^\s+#{app_name}\s+#{app_desc % "face"}/, result.stdout)
138138
end
139139
end
140140
end
141141

142142
step "verify that we can run the application" do
143143
agents.each do |agent|
144-
on(agent, PuppetCommand.new(:"#{app_name}", "--libdir=\"#{get_test_file_path(agent, agent_lib_dir)}\"")) do
144+
on(agent, PuppetCommand.new(:"#{app_name}", "--libdir=\"#{get_test_file_path(agent, agent_lib_dir)}\"")) do |result|
145145
assert_match(/^#{app_output % "face"}/, result.stdout)
146146
end
147147
end

acceptance/tests/resource/service/should_query_all.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
agents.each do |agent|
99
step "query with puppet"
1010
on(agent, puppet_resource('service'), :accept_all_exit_codes => true) do |result|
11-
assert_equal(exit_code, 0, "'puppet resource service' should have an exit code of 0")
11+
assert_equal(result.exit_code, 0, "'puppet resource service' should have an exit code of 0")
1212
assert(/^service/ =~ result.stdout, "'puppet resource service' should present service details")
1313
end
1414
end

acceptance/tests/ticket_13948_lib_dir_hook_should_be_called_on_initialization.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ class Puppet::Application::#{app_name.capitalize} < Puppet::Application::FaceBas
137137

138138
step "verify that the application shows up in help" do
139139
agents.each do |agent|
140-
on(agent, PuppetCommand.new(:help, "--vardir=\"#{get_test_file_path(agent, agent_var_dir)}\"")) do
140+
on(agent, PuppetCommand.new(:help, "--vardir=\"#{get_test_file_path(agent, agent_var_dir)}\"")) do |result|
141141
assert_match(/^\s+#{app_name}\s+#{app_desc % "face"}/, result.stdout)
142142
end
143143
end
144144
end
145145

146146
step "verify that we can run the application" do
147147
agents.each do |agent|
148-
on(agent, PuppetCommand.new(:"#{app_name}", "--vardir=\"#{get_test_file_path(agent, agent_var_dir)}\"")) do
148+
on(agent, PuppetCommand.new(:"#{app_name}", "--vardir=\"#{get_test_file_path(agent, agent_var_dir)}\"")) do |result|
149149
assert_match(/^#{app_output % "face"}/, result.stdout)
150150
end
151151
end

0 commit comments

Comments
 (0)