diff --git a/acceptance/tests/aix/aix_package_provider.rb b/acceptance/tests/aix/aix_package_provider.rb index 9a2d2d76d3e..bd03be55d4b 100644 --- a/acceptance/tests/aix/aix_package_provider.rb +++ b/acceptance/tests/aix/aix_package_provider.rb @@ -11,8 +11,8 @@ def assert_package_version(package, expected_version) # The output of lslpp is a colon-delimited list like: # sudo:sudo.rte:1.8.6.4: : :C: :Configurable super-user privileges runtime: : : : : : :0:0:/: # We want the version, so grab the third field - on hosts, "lslpp -qLc #{package} | cut -f3 -d:" do - actual_version = stdout.chomp + on(hosts, "lslpp -qLc #{package} | cut -f3 -d:") do |result| + actual_version = result.stdout.chomp assert_equal(expected_version, actual_version, "Installed package version #{actual_version} does not match expected version #{expected_version}") end end diff --git a/acceptance/tests/aix/nim_package_provider.rb b/acceptance/tests/aix/nim_package_provider.rb index 6c310683d45..0694ffc6e05 100644 --- a/acceptance/tests/aix/nim_package_provider.rb +++ b/acceptance/tests/aix/nim_package_provider.rb @@ -20,8 +20,8 @@ def assert_package_version(package, expected_version) # The output of lslpp is a colon-delimited list like: # sudo:sudo.rte:1.8.6.4: : :C: :Configurable super-user privileges runtime: : : : : : :0:0:/: # We want the version, so grab the third field - on hosts, "lslpp -qLc #{package} | cut -f3 -d:" do - actual_version = stdout.chomp + on(hosts, "lslpp -qLc #{package} | cut -f3 -d:") do |result| + actual_version = result.stdout.chomp assert_equal(expected_version, actual_version, "Installed package version #{actual_version} does not match expected version #{expected_version}") end end @@ -109,11 +109,11 @@ def test_apply(package_name, ensure_value, expected_version) version = details[:old_version] manifest = get_manifest(package_name, version) - on hosts, puppet_apply("--verbose", "--detailed-exitcodes"), + on(hosts, puppet_apply("--verbose", "--detailed-exitcodes"), { :stdin => manifest, - :acceptable_exit_codes => [4,6] } do + :acceptable_exit_codes => [4,6] }) do |result| - assert_match(/NIM package provider is unable to downgrade packages/, stderr, "Didn't get an error about downgrading packages") + assert_match(/NIM package provider is unable to downgrade packages/, result.stderr, "Didn't get an error about downgrading packages") end end diff --git a/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb b/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb index ef67e97472c..b5e9b0c81cf 100644 --- a/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb +++ b/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb @@ -10,9 +10,7 @@ testdir = master.tmpdir("nodenamefact") node_names = [] -on agents, facter('kernel') do - node_names << stdout.chomp -end +node_names << on(agents, facter('kernel')).stdout.chomp node_names.uniq! @@ -147,8 +145,8 @@ } with_puppet_running_on(master, master_opts, testdir) do - on(agents, puppet('agent', "--no-daemonize --verbose --onetime --node_name_fact kernel")) do - assert_match(/defined 'message'.*#{success_message}/, stdout) + on(agents, puppet('agent', "--no-daemonize --verbose --onetime --node_name_fact kernel")) do |result| + assert_match(/defined 'message'.*#{success_message}/, result.stdout) end end end diff --git a/acceptance/tests/allow_arbitrary_node_name_for_agent.rb b/acceptance/tests/allow_arbitrary_node_name_for_agent.rb index 5ae07fa7586..146c442b18c 100644 --- a/acceptance/tests/allow_arbitrary_node_name_for_agent.rb +++ b/acceptance/tests/allow_arbitrary_node_name_for_agent.rb @@ -127,8 +127,8 @@ }, } with_puppet_running_on(master, master_opts, testdir) do - on(agents, puppet('agent', "-t --node_name_value specified_node_name"), :acceptable_exit_codes => [0,2]) do - assert_match(/defined 'message'.*#{success_message}/, stdout) + on(agents, puppet('agent', "-t --node_name_value specified_node_name"), :acceptable_exit_codes => [0,2]) do |result| + assert_match(/defined 'message'.*#{success_message}/, result.stdout) end end end diff --git a/acceptance/tests/apply/classes/parameterized_classes.rb b/acceptance/tests/apply/classes/parameterized_classes.rb index feed3bc0446..3f089a968ce 100755 --- a/acceptance/tests/apply/classes/parameterized_classes.rb +++ b/acceptance/tests/apply/classes/parameterized_classes.rb @@ -12,8 +12,8 @@ class x($y, $z) { class {x: y => '1', z => '2'} } -apply_manifest_on(agents, manifest) do - fail_test "inclusion after parameterization failed" unless stdout.include? "1-2" +apply_manifest_on(agents, manifest) do |result| + fail_test "inclusion after parameterization failed" unless result.stdout.include? "1-2" end ######################################################################## @@ -28,8 +28,8 @@ class {x: y => '1', z => '2'} include x } -apply_manifest_on(agents, manifest) do - fail_test "inclusion after parameterization failed" unless stdout.include? "1-2" +apply_manifest_on(agents, manifest) do |result| + fail_test "inclusion after parameterization failed" unless result.stdout.include? "1-2" end ######################################################################## @@ -41,8 +41,8 @@ class x($y, $z='2') { class {x: y => '1'} } -apply_manifest_on(agents, manifest) do - fail_test "the default didn't apply as expected" unless stdout.include? "1-2" +apply_manifest_on(agents, manifest) do |result| + fail_test "the default didn't apply as expected" unless result.stdout.include? "1-2" end ######################################################################## @@ -54,6 +54,6 @@ class x($y, $z='2') { class {x: y => '1', z => '3'} } -apply_manifest_on(agents, manifest) do - fail_test "the override didn't happen as we expected" unless stdout.include? "1-3" +apply_manifest_on(agents, manifest) do |result| + fail_test "the override didn't happen as we expected" unless result.stdout.include? "1-3" end diff --git a/acceptance/tests/apply/classes/should_allow_param_override.rb b/acceptance/tests/apply/classes/should_allow_param_override.rb index 008dc438286..c077e272010 100755 --- a/acceptance/tests/apply/classes/should_allow_param_override.rb +++ b/acceptance/tests/apply/classes/should_allow_param_override.rb @@ -16,8 +16,8 @@ class child inherits parent { include child } -apply_manifest_on(agents, manifest) do +apply_manifest_on(agents, manifest) do |result| fail_test "parameter override didn't work" unless - stdout.include? "defined 'message' as 'child'" + result.stdout.include? "defined 'message' as 'child'" end diff --git a/acceptance/tests/apply/classes/should_allow_param_undef_override.rb b/acceptance/tests/apply/classes/should_allow_param_undef_override.rb index fffa0e3238e..052bdf270e9 100755 --- a/acceptance/tests/apply/classes/should_allow_param_undef_override.rb +++ b/acceptance/tests/apply/classes/should_allow_param_undef_override.rb @@ -30,9 +30,9 @@ class child inherits parent { step "apply the manifest" apply_manifest_on(agent, manifest) step "verify the file content" - on(agent, "cat #{out}") do - fail_test "the file was not touched" if stdout.include? "hello world!" - fail_test "the file was not updated" unless stdout.include? "hello new world" + on(agent, "cat #{out}") do |result| + fail_test "the file was not touched" if result.stdout.include? "hello world!" + fail_test "the file was not updated" unless result.stdout.include? "hello new world" end on(agent, "rm -rf #{dir}") diff --git a/acceptance/tests/apply/classes/should_include_resources_from_class.rb b/acceptance/tests/apply/classes/should_include_resources_from_class.rb index be1e6764128..52f78f513f7 100755 --- a/acceptance/tests/apply/classes/should_include_resources_from_class.rb +++ b/acceptance/tests/apply/classes/should_include_resources_from_class.rb @@ -9,7 +9,6 @@ class x { } include x } -apply_manifest_on(agents, manifest) do - fail_test "the resource did not apply" unless - stdout.include? "defined 'message' as 'a'" +apply_manifest_on(agents, manifest) do |result| + fail_test "the resource did not apply" unless result.stdout.include?("defined 'message' as 'a'") end diff --git a/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb b/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb index 32eb3650c8c..80aeea50fd2 100755 --- a/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb +++ b/acceptance/tests/apply/classes/should_not_auto_include_resources_from_class.rb @@ -4,7 +4,7 @@ 'audit:unit' # This should be covered at the unit layer. manifest = %q{ class x { notify { 'test': message => 'never invoked' } } } -apply_manifest_on(agents, manifest) do +apply_manifest_on(agents, manifest) do |result| fail_test "found the notify despite not including it" if - stdout.include? "never invoked" + result.stdout.include? "never invoked" end diff --git a/acceptance/tests/direct_puppet/cached_catalog_remediate_local_drift.rb b/acceptance/tests/direct_puppet/cached_catalog_remediate_local_drift.rb index f76e28be8be..60c9fb33e9c 100644 --- a/acceptance/tests/direct_puppet/cached_catalog_remediate_local_drift.rb +++ b/acceptance/tests/direct_puppet/cached_catalog_remediate_local_drift.rb @@ -129,8 +129,8 @@ step "Run agent again using --use_cached_catalog and ensure content from the first code_id is used" on(agent, puppet("agent", "-t", "--use_cached_catalog"), :acceptable_exit_codes => [0,2]) - on(agent, "cat #{agent_test_file_path}") do - assert_equal('code_version_1', stdout) + on(agent, "cat #{agent_test_file_path}") do |result| + assert_equal('code_version_1', result.stdout) end end end diff --git a/acceptance/tests/direct_puppet/catalog_uuid_correlates_catalogs_with_reports.rb b/acceptance/tests/direct_puppet/catalog_uuid_correlates_catalogs_with_reports.rb index 4a74cf71c94..45c862f7f5a 100644 --- a/acceptance/tests/direct_puppet/catalog_uuid_correlates_catalogs_with_reports.rb +++ b/acceptance/tests/direct_puppet/catalog_uuid_correlates_catalogs_with_reports.rb @@ -13,16 +13,16 @@ def remove_reports_on_master(master_reportdir, agent_node_name) def get_catalog_uuid_from_cached_catalog(host, agent_vardir, agent_node_name) cache_catalog_uuid = nil - on(host, "cat #{agent_vardir}/client_data/catalog/#{agent_node_name}.json") do - cache_catalog_uuid = stdout.match(/"catalog_uuid":"([a-z0-9\-]*)",/)[1] + on(host, "cat #{agent_vardir}/client_data/catalog/#{agent_node_name}.json") do |result| + cache_catalog_uuid = result.stdout.match(/"catalog_uuid":"([a-z0-9\-]*)",/)[1] end cache_catalog_uuid end def get_catalog_uuid_from_report(master_reportdir, agent_node_name) report_catalog_uuid = nil - on(master, "cat #{master_reportdir}/#{agent_node_name}/*") do - report_catalog_uuid = stdout.match(/catalog_uuid: '?([a-z0-9\-]*)'?/)[1] + on(master, "cat #{master_reportdir}/#{agent_node_name}/*") do |result| + report_catalog_uuid = result.stdout.match(/catalog_uuid: '?([a-z0-9\-]*)'?/)[1] end report_catalog_uuid end diff --git a/acceptance/tests/environment/broken_unassigned_environment_handled_gracefully.rb b/acceptance/tests/environment/broken_unassigned_environment_handled_gracefully.rb index 010b8d1e248..23d32a62466 100644 --- a/acceptance/tests/environment/broken_unassigned_environment_handled_gracefully.rb +++ b/acceptance/tests/environment/broken_unassigned_environment_handled_gracefully.rb @@ -59,9 +59,8 @@ agents.each do |agent| on(agent, puppet('agent', "--test --environment #{environment}"), - :acceptable_exit_codes => (0..255)) do - assert_match(/you win/, stdout, - 'agent did not pickup newly classified environment.') + :acceptable_exit_codes => (0..255)) do |result| + assert_match(/you win/, result.stdout, 'agent did not pickup newly classified environment.') end end end diff --git a/acceptance/tests/environment/can_enumerate_environments.rb b/acceptance/tests/environment/can_enumerate_environments.rb index d74ca5793ea..eeb08c61dcb 100644 --- a/acceptance/tests/environment/can_enumerate_environments.rb +++ b/acceptance/tests/environment/can_enumerate_environments.rb @@ -59,8 +59,8 @@ def curl_master_from(agent, path, headers = '', &block) with_puppet_running_on(master, master_opts) do step "Ensure that an unauthenticated client cannot access the environments list" do - on master, "curl --tlsv1 -ksv https://#{master}:#{server_port(master)}/puppet/v3/environments", :acceptable_exit_codes => [0,7] do - assert_match(/< HTTP\/1\.\d 403/, stderr) + on(master, "curl --tlsv1 -ksv https://#{master}:#{server_port(master)}/puppet/v3/environments", :acceptable_exit_codes => [0,7]) do |result| + assert_match(/< HTTP\/1\.\d 403/, result.stderr) end end diff --git a/acceptance/tests/face/4654_facts_face.rb b/acceptance/tests/face/4654_facts_face.rb index 82a6d5b6af3..d8dc8954836 100644 --- a/acceptance/tests/face/4654_facts_face.rb +++ b/acceptance/tests/face/4654_facts_face.rb @@ -60,8 +60,8 @@ MANIFEST step "Agent #{agent}: custom_fact and external_fact should be present in the output of `puppet facts`" - on agent, puppet('facts') do - assert_match(/"custom_fact": "foo"/, stdout, "custom_fact did not match expected output") - assert_match(/"external_fact": "bar"/, stdout, "external_fact did not match expected output") + on agent, puppet('facts') do |result| + assert_match(/"custom_fact": "foo"/, result.stdout, "custom_fact did not match expected output") + assert_match(/"external_fact": "bar"/, result.stdout, "external_fact did not match expected output") end end diff --git a/acceptance/tests/face/loadable_from_modules.rb b/acceptance/tests/face/loadable_from_modules.rb index 7b6542b36a3..15d80450cc6 100644 --- a/acceptance/tests/face/loadable_from_modules.rb +++ b/acceptance/tests/face/loadable_from_modules.rb @@ -93,21 +93,21 @@ def print end EOM - on(agent, puppet('help', '--config', puppetconf)) do - assert_match(/helloworld\s*Hello world face/, stdout, "Face missing from list of available subcommands") + on(agent, puppet('help', '--config', puppetconf)) do |result| + assert_match(/helloworld\s*Hello world face/, result.stdout, "Face missing from list of available subcommands") end - on(agent, puppet('help', 'helloworld', '--config', puppetconf)) do - assert_match(/This is the hello world face/, stdout, "Descripion help missing") - assert_match(/moduleprint\s*Prints hello world from a required module/, stdout, "help for moduleprint action missing") - assert_match(/actionprint\s*Prints hello world from an action/, stdout, "help for actionprint action missing") + on(agent, puppet('help', 'helloworld', '--config', puppetconf)) do |result| + assert_match(/This is the hello world face/, result.stdout, "Descripion help missing") + assert_match(/moduleprint\s*Prints hello world from a required module/, result.stdout, "help for moduleprint action missing") + assert_match(/actionprint\s*Prints hello world from an action/, result.stdout, "help for actionprint action missing") end - on(agent, puppet('helloworld', 'actionprint', '--config', puppetconf)) do - assert_match(/^Hello world from an action$/, stdout, "face did not print hello world") + on(agent, puppet('helloworld', 'actionprint', '--config', puppetconf)) do |result| + assert_match(/^Hello world from an action$/, result.stdout, "face did not print hello world") end - on(agent, puppet('helloworld', 'moduleprint', '--config', puppetconf)) do - assert_match(/^Hello world from a required module$/, stdout, "face did not load module to print hello world") + on(agent, puppet('helloworld', 'moduleprint', '--config', puppetconf)) do |result| + assert_match(/^Hello world from a required module$/, result.stdout, "face did not load module to print hello world") end end diff --git a/acceptance/tests/language/resource_refs_with_nested_arrays.rb b/acceptance/tests/language/resource_refs_with_nested_arrays.rb index 111544de256..b8c345ff3bb 100644 --- a/acceptance/tests/language/resource_refs_with_nested_arrays.rb +++ b/acceptance/tests/language/resource_refs_with_nested_arrays.rb @@ -24,7 +24,7 @@ } MANIFEST - apply_manifest_on agent, test_manifest do - assert_match(/Exec\[third\].*the final command/, stdout) + apply_manifest_on(agent, test_manifest) do |result| + assert_match(/Exec\[third\].*the final command/, result.stdout) end end diff --git a/acceptance/tests/loader/func4x_loadable_from_modules.rb b/acceptance/tests/loader/func4x_loadable_from_modules.rb index dfac9ccaad3..8e8a4d8c9b0 100644 --- a/acceptance/tests/loader/func4x_loadable_from_modules.rb +++ b/acceptance/tests/loader/func4x_loadable_from_modules.rb @@ -70,11 +70,11 @@ class helloworld { SOURCE # Run apply to generate the file with the output - on agent, puppet('apply', '-e', "'include helloworld'", '--config', puppetconf) + on(agent, puppet('apply', '-e', "'include helloworld'", '--config', puppetconf)) # Assert that the file was written with the generated content - on(agent, "cat #{File.join(target_path, 'result.txt')}") do - assert_match(/^Generated, 1 => 10, 2 => 20, 3 => 30$/, stdout, "Generated the wrong content") + on(agent, "cat #{File.join(target_path, 'result.txt')}") do |result| + assert_match(/^Generated, 1 => 10, 2 => 20, 3 => 30$/, result.stdout, "Generated the wrong content") end end diff --git a/acceptance/tests/lookup/lookup.rb b/acceptance/tests/lookup/lookup.rb index 795c804d2b0..a65d5a347ae 100644 --- a/acceptance/tests/lookup/lookup.rb +++ b/acceptance/tests/lookup/lookup.rb @@ -306,26 +306,27 @@ class #{module_name}($#{env_data_implied_key}, with_puppet_running_on master, master_opts, testdir do step "Lookup string data, binding specified in metadata.json" do agents.each do |agent| - on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [0, 2]) - assert_match("#{env_data_implied_key} #{env_data_implied_value}", stdout) - assert_match("#{env_data_key} #{env_data_value}", stdout) + on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [0, 2]) do |result| + assert_match("#{env_data_implied_key} #{env_data_implied_value}", result.stdout) + assert_match("#{env_data_key} #{env_data_value}", result.stdout) - assert_match("#{module_data_implied_key} #{module_data_implied_value}", stdout) - assert_match("#{module_data_key} #{module_data_value}", stdout) + assert_match("#{module_data_implied_key} #{module_data_implied_value}", result.stdout) + assert_match("#{module_data_key} #{module_data_value}", result.stdout) - assert_match("#{module_data_key} #{module_data_value_other}", stdout) + assert_match("#{module_data_key} #{module_data_value_other}", result.stdout) - assert_match("#{env_data_override_implied_key} #{env_data_override_implied_value}", stdout) - assert_match("#{env_data_override_key} #{env_data_override_value}", stdout) + assert_match("#{env_data_override_implied_key} #{env_data_override_implied_value}", result.stdout) + assert_match("#{env_data_override_key} #{env_data_override_value}", result.stdout) - assert_match("#{hiera_data_implied_key} #{hiera_data_implied_value}", stdout) - assert_match("#{hiera_data_key} #{hiera_data_value}", stdout) + assert_match("#{hiera_data_implied_key} #{hiera_data_implied_value}", result.stdout) + assert_match("#{hiera_data_key} #{hiera_data_value}", result.stdout) - assert_match("#{hash_name} {#{module_hash_key} => #{module_hash_value}, #{env_hash_key} => #{env_hash_value}, #{hiera_hash_key} => #{hiera_hash_value}}", stdout) + assert_match("#{hash_name} {#{module_hash_key} => #{module_hash_value}, #{env_hash_key} => #{env_hash_value}, #{hiera_hash_key} => #{hiera_hash_value}}", result.stdout) - assert_match("#{array_key} [#{hiera_array_value0}, #{hiera_array_value1}, #{env_array_value0}, #{env_array_value1}, #{module_array_value0}, #{module_array_value1}]", stdout) + assert_match("#{array_key} [#{hiera_array_value0}, #{hiera_array_value1}, #{env_array_value0}, #{env_array_value1}, #{module_array_value0}, #{module_array_value1}]", result.stdout) - assert_match("#{automatic_data_key} #{automatic_data_value}", stdout) + assert_match("#{automatic_data_key} #{automatic_data_value}", result.stdout) + end end end end diff --git a/acceptance/tests/ordering/master_agent_application.rb b/acceptance/tests/ordering/master_agent_application.rb index 6b3edb60e95..5ebc2ea0d88 100644 --- a/acceptance/tests/ordering/master_agent_application.rb +++ b/acceptance/tests/ordering/master_agent_application.rb @@ -42,9 +42,10 @@ with_puppet_running_on(master, master_opts) do agents.each do |agent| - on(agent, puppet('agent', "--no-daemonize --onetime --verbose")) - if stdout !~ /Notice: first.*Notice: second.*Notice: third.*Notice: fourth.*Notice: fifth.*Notice: sixth.*Notice: seventh.*Notice: eighth/m - fail_test "Output did not include the notify resources in the correct order" + on(agent, puppet('agent', "--no-daemonize --onetime --verbose")) do |result| + if result.stdout !~ /Notice: first.*Notice: second.*Notice: third.*Notice: fourth.*Notice: fifth.*Notice: sixth.*Notice: seventh.*Notice: eighth/m + fail_test "Output did not include the notify resources in the correct order" + end end end end diff --git a/acceptance/tests/parser_functions/hiera/lookup_data.rb b/acceptance/tests/parser_functions/hiera/lookup_data.rb index e6e5ac444e9..3e0b67f1d90 100644 --- a/acceptance/tests/parser_functions/hiera/lookup_data.rb +++ b/acceptance/tests/parser_functions/hiera/lookup_data.rb @@ -88,8 +88,8 @@ class apache { with_puppet_running_on master, master_opts, testdir do agents.each do |agent| - on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) - - assert_match("apache server port: 8080", stdout) + on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) do |result| + assert_match('apache server port: 8080', result.stdout) + end end end diff --git a/acceptance/tests/parser_functions/hiera_array/lookup_data.rb b/acceptance/tests/parser_functions/hiera_array/lookup_data.rb index fcda42f47c7..3bfbcfa635b 100644 --- a/acceptance/tests/parser_functions/hiera_array/lookup_data.rb +++ b/acceptance/tests/parser_functions/hiera_array/lookup_data.rb @@ -100,9 +100,9 @@ class ntp { with_puppet_running_on master, master_opts, testdir do agents.each do |agent| - on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) - - assert_match("ntpserver global.ntp.puppetlabs.com", stdout) - assert_match("ntpserver production.ntp.puppetlabs.com", stdout) + on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) do |result| + assert_match('ntpserver global.ntp.puppetlabs.com', result.stdout) + assert_match('ntpserver production.ntp.puppetlabs.com', result.stdout) + end end end diff --git a/acceptance/tests/parser_functions/hiera_hash/lookup_data.rb b/acceptance/tests/parser_functions/hiera_hash/lookup_data.rb index 2a6e2bc6012..3532fdb454d 100644 --- a/acceptance/tests/parser_functions/hiera_hash/lookup_data.rb +++ b/acceptance/tests/parser_functions/hiera_hash/lookup_data.rb @@ -98,8 +98,8 @@ with_puppet_running_on master, master_opts, testdir do agents.each do |agent| - on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) - - assert_match("name: postgres shell: /bin/bash", stdout) + on(agent, puppet('agent', "-t"), :acceptable_exit_codes => [2]) do |result| + assert_match("name: postgres shell: /bin/bash", result.stdout) + end end end diff --git a/acceptance/tests/pluginsync/3935_pluginsync_should_follow_symlinks.rb b/acceptance/tests/pluginsync/3935_pluginsync_should_follow_symlinks.rb index bd95803916a..40b6e2e83c6 100644 --- a/acceptance/tests/pluginsync/3935_pluginsync_should_follow_symlinks.rb +++ b/acceptance/tests/pluginsync/3935_pluginsync_should_follow_symlinks.rb @@ -41,8 +41,9 @@ with_puppet_running_on master, master_opts, basedir do agents.each do |agent| - on(agent, puppet('agent', "-t")) - refute_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/pluginfacts/, stderr) - refute_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/plugins/, stderr) + on(agent, puppet('agent', "-t")) do |result| + refute_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/pluginfacts/, result.stderr) + refute_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/plugins/, result.stderr) + end end end diff --git a/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb b/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb index b8a87c351af..2dacd0ffb32 100644 --- a/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb +++ b/acceptance/tests/pluginsync/files_earlier_in_modulepath_take_precendence.rb @@ -62,8 +62,8 @@ with_puppet_running_on master, master_opts, basedir do agents.each do |agent| on(agent, puppet('agent', "-t")) - on agent, "cat \"#{agent.puppet['vardir']}/lib/foo.rb\"" do - assert_match(/from the first module/, stdout, "The synced plugin was not found or the wrong version was synced") + on(agent, "cat \"#{agent.puppet['vardir']}/lib/foo.rb\"") do |result| + assert_match(/from the first module/, result.stdout, "The synced plugin was not found or the wrong version was synced") end end end diff --git a/acceptance/tests/reports/cached_catalog_status_in_report.rb b/acceptance/tests/reports/cached_catalog_status_in_report.rb index 5d85b86ea2c..6561d353e86 100644 --- a/acceptance/tests/reports/cached_catalog_status_in_report.rb +++ b/acceptance/tests/reports/cached_catalog_status_in_report.rb @@ -22,8 +22,8 @@ def remove_reports_on_master(master_reportdir, agent_node_name) step "Run again and ensure report indicates that the cached catalog was not used" do on(agent, puppet("agent", "--onetime", "--no-daemonize"), :acceptable_exit_codes => [0, 2]) - on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do - assert_match(/cached_catalog_status: not_used/, stdout, "expected to find 'cached_catalog_status: not_used' in the report") + on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do |result| + assert_match(/cached_catalog_status: not_used/, result.stdout, "expected to find 'cached_catalog_status: not_used' in the report") end remove_reports_on_master(master_reportdir, agent.node_name) end @@ -31,16 +31,16 @@ def remove_reports_on_master(master_reportdir, agent_node_name) step "Run with --use_cached_catalog and ensure report indicates cached catalog was explicitly requested" do on(agent, puppet("agent", "--onetime", "--no-daemonize", "--use_cached_catalog"), :acceptable_exit_codes => [0, 2]) - on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do - assert_match(/cached_catalog_status: explicitly_requested/, stdout, "expected to find 'cached_catalog_status: explicitly_requested' in the report") + on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do |result| + assert_match(/cached_catalog_status: explicitly_requested/, result.stdout, "expected to find 'cached_catalog_status: explicitly_requested' in the report") end remove_reports_on_master(master_reportdir, agent.node_name) end step "On a run which fails to retrieve a new catalog, ensure report indicates cached catalog was used on failure" do on(agent, puppet("agent", "--onetime", "--no-daemonize", "--report_server #{master}", "--server nonexist"), :acceptable_exit_codes => [0, 2]) - on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do - assert_match(/cached_catalog_status: on_failure/, stdout, "expected to find 'cached_catalog_status: on_failure' in the report") + on(master, "cat #{master_reportdir}/#{agent.node_name}/*") do |result| + assert_match(/cached_catalog_status: on_failure/, result.stdout, "expected to find 'cached_catalog_status: on_failure' in the report") end end end diff --git a/acceptance/tests/resource/exec/accept_multi-line_commands.rb b/acceptance/tests/resource/exec/accept_multi-line_commands.rb index 7d64c659ae4..d1a77b33edd 100644 --- a/acceptance/tests/resource/exec/accept_multi-line_commands.rb +++ b/acceptance/tests/resource/exec/accept_multi-line_commands.rb @@ -23,8 +23,8 @@ apply_manifest_on agent, test_manifest - on(agent, "cat #{temp_file_name}") do - assert_equal(expected_results, stdout, "Unexpected result for host '#{agent}'") + on(agent, "cat #{temp_file_name}") do |result| + assert_equal(expected_results, result.stdout, "Unexpected result for host '#{agent}'") end on(agent, "rm -f #{temp_file_name}") diff --git a/acceptance/tests/resource/exec/should_accept_large_output.rb b/acceptance/tests/resource/exec/should_accept_large_output.rb index 55ef46b5c4c..91f8005dfd2 100644 --- a/acceptance/tests/resource/exec/should_accept_large_output.rb +++ b/acceptance/tests/resource/exec/should_accept_large_output.rb @@ -15,15 +15,15 @@ EOF create_remote_file(agent, testfile, lorem_ipsum*1024) - apply_manifest_on(agent, "exec {'cat #{testfile}': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin', 'C:/cygwin/bin'], logoutput => true}") do + apply_manifest_on(agent, "exec {'cat #{testfile}': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin', 'C:/cygwin/bin'], logoutput => true}") do |result| fail_test "didn't seem to run the command" unless - stdout.include? 'executed successfully' unless agent['locale'] == 'ja' + result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja' fail_test "didn't print output correctly" unless - stdout.lines.select {|line| line =~ /\/returns:/}.count == 4097 + result.stdout.lines.select {|line| line =~ /\/returns:/}.count == 4097 end - apply_manifest_on(agent, "exec {'echo': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin', 'C:/cygwin/bin'], logoutput => true}") do + apply_manifest_on(agent, "exec {'echo': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin', 'C:/cygwin/bin'], logoutput => true}") do |result| fail_test "didn't seem to run the command" unless - stdout.include? 'executed successfully' unless agent['locale'] == 'ja' + result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja' end end diff --git a/acceptance/tests/resource/exec/should_not_run_command_creates.rb b/acceptance/tests/resource/exec/should_not_run_command_creates.rb index cce46b11daa..de827a097ea 100644 --- a/acceptance/tests/resource/exec/should_not_run_command_creates.rb +++ b/acceptance/tests/resource/exec/should_not_run_command_creates.rb @@ -15,9 +15,9 @@ on agent, "touch #{touch} && rm -f #{donottouch}" step "test using puppet apply" - apply_manifest_on(agent, manifest) do + apply_manifest_on(agent, manifest) do |result| fail_test "looks like the thing executed, which it shouldn't" if - stdout.include? 'executed successfully' + result.stdout.include? 'executed successfully' end step "verify the file didn't get created" @@ -29,9 +29,9 @@ step "test using puppet resource" on(agent, puppet_resource('exec', "test#{Time.new.to_i}", "command='#{agent.touch(donottouch)}'", - "creates='#{touch}'")) do + "creates='#{touch}'")) do |result| fail_test "looks like the thing executed, which it shouldn't" if - stdout.include? 'executed successfully' + result.stdout.include? 'executed successfully' end step "verify the file didn't get created the second time" diff --git a/acceptance/tests/resource/exec/should_run_bad_command.rb b/acceptance/tests/resource/exec/should_run_bad_command.rb index d27c5ff049c..bd591117a99 100644 --- a/acceptance/tests/resource/exec/should_run_bad_command.rb +++ b/acceptance/tests/resource/exec/should_run_bad_command.rb @@ -62,9 +62,9 @@ def stop_sleep_process(targets, accept_no_pid_found = false) create_remote_file(agent, daemon, sleepy_daemon_script(agent)) on(agent, "chmod +x #{daemon}") - apply_manifest_on(agent, "exec {'#{daemon}': logoutput => true}") do + apply_manifest_on(agent, "exec {'#{daemon}': logoutput => true}") do |result| fail_test "didn't seem to run the command" unless - stdout.include? 'executed successfully' unless agent['locale'] == 'ja' + result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja' end end diff --git a/acceptance/tests/resource/exec/should_run_command.rb b/acceptance/tests/resource/exec/should_run_command.rb index 9c2b0e86f43..cdce50ac045 100644 --- a/acceptance/tests/resource/exec/should_run_command.rb +++ b/acceptance/tests/resource/exec/should_run_command.rb @@ -20,18 +20,16 @@ def after(agent, touched) agents.each do |agent| touched = before(agent) - apply_manifest_on(agent, "exec {'test': command=>'#{agent.touch(touched)}'}") do + apply_manifest_on(agent, "exec {'test': command=>'#{agent.touch(touched)}'}") do |result| fail_test "didn't seem to run the command" unless - stdout.include? 'executed successfully' unless agent['locale'] == 'ja' + result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja' end after(agent, touched) touched = before(agent) - on(agent, puppet_resource('-d', 'exec', 'test', "command='#{agent.touch(touched)}'}")) do + on(agent, puppet_resource('-d', 'exec', 'test', "command='#{agent.touch(touched)}'}")) do |result| fail_test "didn't seem to run the command" unless - stdout.include? 'executed successfully' unless agent['locale'] == 'ja' + result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja' end after(agent, touched) end - - diff --git a/acceptance/tests/resource/file/ascii_diff_output_content_attribute.rb b/acceptance/tests/resource/file/ascii_diff_output_content_attribute.rb index 8acdd443dbc..f955ac55882 100644 --- a/acceptance/tests/resource/file/ascii_diff_output_content_attribute.rb +++ b/acceptance/tests/resource/file/ascii_diff_output_content_attribute.rb @@ -23,18 +23,18 @@ step 'Create ASCII file using content' do manifest = "file { '#{target}': content => '#{initial_text}', ensure => present , checksum => 'sha256'}" - on(agent, puppet('apply'), :stdin => manifest) do - assert_match(/ensure: defined content as '{sha256}#{initial_text_sha_checksum}'/, stdout, "#{agent}: checksum of ASCII file not matched") + on(agent, puppet('apply'), :stdin => manifest) do |result| + assert_match(/ensure: defined content as '{sha256}#{initial_text_sha_checksum}'/, result.stdout, "#{agent}: checksum of ASCII file not matched") end end step 'Update existing ASCII file content' do manifest = "file { '#{target}': content => '#{updated_text}', ensure => present , checksum => 'sha256'}" - on(agent, puppet('apply','--show_diff'), :stdin => manifest) do - assert_match(/content: content changed '{sha256}#{initial_text_sha_checksum}' to '{sha256}#{updated_text_sha_checksum}'/, stdout, "#{agent}: checksum of ASCII file not matched after update") - assert_match(/^- ?#{initial_text}$/, stdout, "#{agent}: initial text not found in diff") - assert_match(/^\+ ?#{updated_text}$/, stdout, "#{agent}: updated text not found in diff") + on(agent, puppet('apply','--show_diff'), :stdin => manifest) do |result| + assert_match(/content: content changed '{sha256}#{initial_text_sha_checksum}' to '{sha256}#{updated_text_sha_checksum}'/, result.stdout, "#{agent}: checksum of ASCII file not matched after update") + assert_match(/^- ?#{initial_text}$/, result.stdout, "#{agent}: initial text not found in diff") + assert_match(/^\+ ?#{updated_text}$/, result.stdout, "#{agent}: updated text not found in diff") end end end diff --git a/acceptance/tests/resource/file/bin_diff_output_content_attribute.rb b/acceptance/tests/resource/file/bin_diff_output_content_attribute.rb index fea60a65775..b0706731a1b 100644 --- a/acceptance/tests/resource/file/bin_diff_output_content_attribute.rb +++ b/acceptance/tests/resource/file/bin_diff_output_content_attribute.rb @@ -44,22 +44,22 @@ step 'Create binary file using content' do manifest = "file { '#{target}': content => Binary('#{initial_base64_data}'), ensure => present , checksum => 'sha256'}" - on(agent, puppet('apply'), :stdin => manifest) do - assert_match(/ensure: defined content as '{sha256}#{initial_sha_checksum}'/, stdout, "#{agent}: checksum of binary file not matched") + on(agent, puppet('apply'), :stdin => manifest) do |result| + assert_match(/ensure: defined content as '{sha256}#{initial_sha_checksum}'/, result.stdout, "#{agent}: checksum of binary file not matched") end end step 'Update existing binary file content' do manifest = "file { '#{target}': content => Binary('#{updated_base64_data}'), ensure => present , checksum => 'sha256'}" - on(agent, puppet('apply','--show_diff'), :stdin => manifest) do - assert_match(/content: content changed '{sha256}#{initial_sha_checksum}' to '{sha256}#{updated_sha_checksum}'/, stdout, "#{agent}: checksum of binary file not matched after update") - refute_match(/content: Received a Log attribute with invalid encoding:/, stdout, "#{agent}: Received a Log attribute with invalid encoding") + on(agent, puppet('apply','--show_diff'), :stdin => manifest) do |result| + assert_match(/content: content changed '{sha256}#{initial_sha_checksum}' to '{sha256}#{updated_sha_checksum}'/, result.stdout, "#{agent}: checksum of binary file not matched after update") + refute_match(/content: Received a Log attribute with invalid encoding:/, result.stdout, "#{agent}: Received a Log attribute with invalid encoding") if initial_bin_data.valid_encoding? && updated_bin_data.valid_encoding? - assert_match(/^- ?#{initial_bin_data}$/, stdout, "#{agent}: initial utf-8 data not found in binary diff") - assert_match(/^\+ ?#{updated_bin_data}$/, stdout, "#{agent}: updated utf-8 data not found in binary diff") + assert_match(/^- ?#{initial_bin_data}$/, result.stdout, "#{agent}: initial utf-8 data not found in binary diff") + assert_match(/^\+ ?#{updated_bin_data}$/, result.stdout, "#{agent}: updated utf-8 data not found in binary diff") else - assert_match(/Binary files #{target} and .* differ/, stdout, "#{agent}: Binary file diff notice not matched") + assert_match(/Binary files #{target} and .* differ/, result.stdout, "#{agent}: Binary file diff notice not matched") end end end diff --git a/acceptance/tests/resource/file/content_attribute.rb b/acceptance/tests/resource/file/content_attribute.rb index be67eab9132..6b3c820a40e 100644 --- a/acceptance/tests/resource/file/content_attribute.rb +++ b/acceptance/tests/resource/file/content_attribute.rb @@ -24,35 +24,35 @@ manifest += checksums.collect {|checksum_type| "file { '#{target+checksum_type}': content => 'This is the test file content', ensure => present, checksum => #{checksum_type} }" }.join("\n") - apply_manifest_on agent, manifest do + apply_manifest_on(agent, manifest) do |result| checksums.each do |checksum_type| - refute_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote #{target+checksum_type}") + refute_match(/content changed/, result.stdout, "#{agent}: shouldn't have overwrote #{target+checksum_type}") end end - on agent, "cat #{target}" do - assert_match(/This is the test file content/, stdout, "File content not matched on #{agent}") unless agent['locale'] == 'ja' + on(agent, "cat #{target}") do |result| + assert_match(/This is the test file content/, result.stdout, "File content not matched on #{agent}") unless agent['locale'] == 'ja' end step "Content Attribute: illegal timesteps" ['mtime', 'ctime'].each do |checksum_type| manifest = "file { '#{target+checksum_type}': content => 'This is the test file content', ensure => present, checksum => #{checksum_type} }" - apply_manifest_on agent, manifest, :acceptable_exit_codes => [1] do - assert_match(/Error: Validation of File\[#{target+checksum_type}\] failed: You cannot specify content when using checksum '#{checksum_type}'/, stderr, "#{agent}: expected failure") unless agent['locale'] == 'ja' + apply_manifest_on(agent, manifest, :acceptable_exit_codes => [1]) do |result| + assert_match(/Error: Validation of File\[#{target+checksum_type}\] failed: You cannot specify content when using checksum '#{checksum_type}'/, result.stderr, "#{agent}: expected failure") unless agent['locale'] == 'ja' end end step "Ensure the test environment is clean" - on agent, "rm -f #{target}" + on(agent, "rm -f #{target}") step "Content Attribute: using a checksum from filebucket" - on agent, "echo 'This is the checksum file contents' > #{target}" + on(agent, "echo 'This is the checksum file contents' > #{target}") step "Backup file into the filebucket" - on agent, puppet_filebucket("backup --local #{target}") + on(agent, puppet_filebucket("backup --local #{target}")) step "Modify file to force apply to retrieve file from local clientbucket" - on agent, "echo 'This is the modified file contents' > #{target}" + on(agent, "echo 'This is the modified file contents' > #{target}") dir = on(agent, puppet_filebucket("--configprint clientbucketdir")).stdout.chomp @@ -72,7 +72,7 @@ apply_manifest_on agent, sha256_manifest step "Validate filebucket checksum file contents" - on agent, "cat #{target}" do - assert_match(/This is the checksum file content/, stdout, "File content not matched on #{agent}") unless agent['locale'] == 'ja' + on(agent, "cat #{target}") do |result| + assert_match(/This is the checksum file content/, result.stdout, "File content not matched on #{agent}") unless agent['locale'] == 'ja' end end diff --git a/acceptance/tests/resource/file/handle_fifo_files.rb b/acceptance/tests/resource/file/handle_fifo_files.rb index 3f0f7b680bd..4a19f913a0e 100644 --- a/acceptance/tests/resource/file/handle_fifo_files.rb +++ b/acceptance/tests/resource/file/handle_fifo_files.rb @@ -31,8 +31,8 @@ def ensure_content_to_file_manifest(file_path, ensure_value) end step "puppet ensures given fifo is present" do - apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'present'), :acceptable_exit_codes => [2]) do - assert_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr) + apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'present'), :acceptable_exit_codes => [2]) do |result| + assert_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, result.stderr) end end @@ -43,9 +43,9 @@ def ensure_content_to_file_manifest(file_path, ensure_value) end step "puppet ensures given fifo is a regular file" do - apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'file'), :acceptable_exit_codes => [0]) do - assert_match(/Notice: .+\/myfifo\]\/ensure: defined content as '{/, stdout) - refute_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr) + apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'file'), :acceptable_exit_codes => [0]) do |result| + assert_match(/Notice: .+\/myfifo\]\/ensure: defined content as '{/, result.stdout) + refute_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, result.stderr) end end diff --git a/acceptance/tests/resource/file/handle_fifo_files_when_recursing.rb b/acceptance/tests/resource/file/handle_fifo_files_when_recursing.rb index cec2191f39e..ee071886eec 100644 --- a/acceptance/tests/resource/file/handle_fifo_files_when_recursing.rb +++ b/acceptance/tests/resource/file/handle_fifo_files_when_recursing.rb @@ -41,9 +41,9 @@ def ensure_owner_recursively_manifest(path, owner_value) end step "puppet ensures '#{random_user}' as owner of path" do - apply_manifest_on(agent, ensure_owner_recursively_manifest(tmp_path, random_user), :acceptable_exit_codes => [0]) do - assert_match(/#{tmp_path}\]\/owner: owner changed '#{initial_owner}' to '#{random_user}'/, stdout) - refute_match(/Error: .+ Failed to generate additional resources using ‘eval_generate’: Cannot manage files of type fifo/, stderr) + apply_manifest_on(agent, ensure_owner_recursively_manifest(tmp_path, random_user), :acceptable_exit_codes => [0]) do |result| + assert_match(/#{tmp_path}\]\/owner: owner changed '#{initial_owner}' to '#{random_user}'/, result.stdout) + refute_match(/Error: .+ Failed to generate additional resources using ‘eval_generate’: Cannot manage files of type fifo/, result.stderr) end end diff --git a/acceptance/tests/resource/file/should_create_symlink.rb b/acceptance/tests/resource/file/should_create_symlink.rb index 68bc6c6b593..364a322c274 100644 --- a/acceptance/tests/resource/file/should_create_symlink.rb +++ b/acceptance/tests/resource/file/should_create_symlink.rb @@ -15,24 +15,24 @@ def reset_link_and_target(agent, link, target) def verify_symlink(agent, link, target) step "verify the symlink was created" - on agent, "test -L #{link} && test -f #{link}" + on(agent, "test -L #{link} && test -f #{link}") step "verify the symlink points to a file" - on agent, "test -f #{target}" + on(agent, "test -f #{target}") step "verify the content is identical on both sides" - on(agent, "cat #{link}") do - fail_test "link missing content" unless stdout.include? message + on(agent, "cat #{link}") do |result| + fail_test "link missing content" unless result.stdout.include?(message) end - on(agent, "cat #{target}") do - fail_test "target missing content" unless stdout.include? message + on(agent, "cat #{target}") do |result| + fail_test "target missing content" unless result.stdout.include?(message) end end agents.each do |agent| if agent.platform.variant == 'windows' # symlinks are supported only on Vista+ (version 6.0 and higher) - on agent, facter('kernelmajversion') do - skip_test "Test not supported on this platform" if stdout.chomp.to_f < 6.0 + on(agent, facter('kernelmajversion')) do |result| + skip_test "Test not supported on this platform" if result.stdout.chomp.to_f < 6.0 end end diff --git a/acceptance/tests/resource/file/should_default_mode.rb b/acceptance/tests/resource/file/should_default_mode.rb index 728286f8bee..56cccd52dcf 100644 --- a/acceptance/tests/resource/file/should_default_mode.rb +++ b/acceptance/tests/resource/file/should_default_mode.rb @@ -13,8 +13,8 @@ def regexp_mode(mode) on(agent, "rm -rf #{parent}") step "puppet should set execute bit on readable directories" - on(agent, puppet_resource("file", parent, "ensure=directory", "mode=0644")) do - assert_match(regexp_mode(755), stdout) + on(agent, puppet_resource("file", parent, "ensure=directory", "mode=0644")) do |result| + assert_match(regexp_mode(755), result.stdout) end step "include execute bit on newly created directories" @@ -24,20 +24,20 @@ def regexp_mode(mode) step "exclude execute bit from newly created files" file = "#{parent}/file.txt" on(agent, "echo foobar > #{file}") - on(agent, "#{file}", :acceptable_exit_codes => (1..255)) do - refute_match(/foobar/, stdout) + on(agent, "#{file}", :acceptable_exit_codes => (1..255)) do |result| + refute_match(/foobar/, result.stdout) end step "set execute bit on file if explicitly specified" file_750 = "#{parent}/file_750.txt" - on(agent, puppet_resource("file", file_750, "ensure=file", "mode=0750")) do - assert_match(regexp_mode(750), stdout) + on(agent, puppet_resource("file", file_750, "ensure=file", "mode=0750")) do |result| + assert_match(regexp_mode(750), result.stdout) end step "don't set execute bit if directory not readable" dir_600 = "#{parent}/dir_600" - on(agent, puppet_resource("file", dir_600, "ensure=directory", "mode=0600")) do - assert_match(regexp_mode(700), stdout) # readable by owner, but not group + on(agent, puppet_resource("file", dir_600, "ensure=directory", "mode=0600")) do |result| + assert_match(regexp_mode(700), result.stdout) # readable by owner, but not group end on(agent, "rm -rf #{parent}") diff --git a/acceptance/tests/resource/file/should_remove_dir.rb b/acceptance/tests/resource/file/should_remove_dir.rb index d3e8356081d..ae04d6cce43 100644 --- a/acceptance/tests/resource/file/should_remove_dir.rb +++ b/acceptance/tests/resource/file/should_remove_dir.rb @@ -7,20 +7,20 @@ target = agent.tmpdir("delete-dir") step "clean up the system before we begin" - on agent, "rm -rf #{target} ; mkdir -p #{target}" + on(agent, "rm -rf #{target} ; mkdir -p #{target}") step "verify we can't remove a directory without 'force'" - on(agent, puppet_resource("file", target, 'ensure=absent')) do + on(agent, puppet_resource("file", target, 'ensure=absent')) do |result| fail_test "didn't tell us that force was required" unless - stdout.include? "Not removing directory; use 'force' to override" unless agent['locale'] == 'ja' + result.stdout.include? "Not removing directory; use 'force' to override" unless agent['locale'] == 'ja' end step "verify the directory still exists" - on agent, "test -d #{target}" + on(agent, "test -d #{target}") step "verify we can remove a directory with 'force'" on(agent, puppet_resource("file", target, 'ensure=absent', 'force=true')) step "verify that the directory is gone" - on agent, "test -d #{target}", :acceptable_exit_codes => [1] + on(agent, "test -d #{target}", :acceptable_exit_codes => [1]) end diff --git a/acceptance/tests/resource/file/source_attribute.rb b/acceptance/tests/resource/file/source_attribute.rb index c8ed79c96b3..45a51bf3bdd 100644 --- a/acceptance/tests/resource/file/source_attribute.rb +++ b/acceptance/tests/resource/file/source_attribute.rb @@ -167,19 +167,19 @@ class source_test_module { dir_to_check = agent['platform'] =~ /windows/ ? @target_dir_on_windows : @target_dir_on_nix checksums.each do |checksum_type| - on agent, "cat #{file_to_check}#{checksum_type}" do - assert_match(/the content is present/, stdout, "Result file not created #{checksum_type}") + on agent, "cat #{file_to_check}#{checksum_type}" do |result| + assert_match(/the content is present/, result.stdout, "Result file not created #{checksum_type}") end - on agent, "cat #{dir_to_check}#{checksum_type}/source_dir_file" do - assert_match(/the content is present/, stdout, "Result file not created #{checksum_type}") + on agent, "cat #{dir_to_check}#{checksum_type}/source_dir_file" do |result| + assert_match(/the content is present/, result.stdout, "Result file not created #{checksum_type}") end end end step "second run should not update file" - on(agent, puppet('agent', "--test"), :acceptable_exit_codes => [0,2]) do - refute_match(/content changed.*(md5|sha256)/, stdout, "Shouldn't have overwritten any files") + on(agent, puppet('agent', "--test"), :acceptable_exit_codes => [0,2]) do |result| + refute_match(/content changed.*(md5|sha256)/, result.stdout, "Shouldn't have overwritten any files") # When using ctime/mtime, the agent compares the values from its # local file with the values on the master to determine if the @@ -190,11 +190,11 @@ class source_test_module { # again. This process will repeat until the agent updates the # file, and the resulting ctime/mtime are after the values on # the master, at which point it will have converged. - if stdout =~ /content changed.*ctime/ + if result.stdout =~ /content changed.*ctime/ Log.warn "Agent did not converge using ctime" end - if stdout =~ /content changed.*mtime/ + if result.stdout =~ /content changed.*mtime/ Log.warn "Agent did not converge using mtime" end end @@ -248,14 +248,14 @@ class source_test_module { checksums.each do |checksum_type| step "Using a local file path. #{checksum_type}" - on agent, "cat #{target[checksum_type]}" do - assert_match(/Yay, this is the local file./, stdout, "FIRST: File contents not matched on #{agent}") + on(agent, "cat #{target[checksum_type]}") do |result| + assert_match(/Yay, this is the local file./, result.stdout, "FIRST: File contents not matched on #{agent}") end end step "second run should not update any files" - apply_manifest_on agent, local_apply_manifest do - refute_match(/content changed/, stdout, "Shouldn't have overwrote any files") + apply_manifest_on(agent, local_apply_manifest) do |result| + refute_match(/content changed/, result.stdout, "Shouldn't have overwrote any files") end # changes in source file producing updates is tested elsewhere @@ -265,12 +265,12 @@ class source_test_module { create_remote_file agent, source, source_content if fips_host_present - apply_manifest_on agent, "file { '#{localsource_testdir}/targetsha256lite': source => '#{source}', ensure => present, checksum => sha256lite }" do - refute_match(/(content changed|defined content)/, stdout, "Shouldn't have overwrote any files") + apply_manifest_on(agent, "file { '#{localsource_testdir}/targetsha256lite': source => '#{source}', ensure => present, checksum => sha256lite }") do |result| + refute_match(/(content changed|defined content)/, result.stdout, "Shouldn't have overwrote any files") end else - apply_manifest_on agent, "file { '#{localsource_testdir}/targetmd5lite': source => '#{source}', ensure => present, checksum => md5lite } file { '#{localsource_testdir}/targetsha256lite': source => '#{source}', ensure => present, checksum => sha256lite }" do - refute_match(/(content changed|defined content)/, stdout, "Shouldn't have overwrote any files") + apply_manifest_on(agent, "file { '#{localsource_testdir}/targetmd5lite': source => '#{source}', ensure => present, checksum => md5lite } file { '#{localsource_testdir}/targetsha256lite': source => '#{source}', ensure => present, checksum => sha256lite }") do |result| + refute_match(/(content changed|defined content)/, result.stdout, "Shouldn't have overwrote any files") end end @@ -287,14 +287,14 @@ class source_test_module { checksums.each do |checksum_type| step "Using a puppet:/// URI with checksum type: #{checksum_type}" - on agent, "cat #{target[checksum_type]}" do - assert_match(/Yay, this is the local file./, stdout, "FIRST: File contents not matched on #{agent}") + on(agent, "cat #{target[checksum_type]}") do |result| + assert_match(/Yay, this is the local file./, result.stdout, "FIRST: File contents not matched on #{agent}") end end step "second run should not update any files using apply with puppet:/// URI source" - on agent, puppet( %{apply --modulepath=#{localsource_testdir} #{localsource_test_manifest}} ) do - refute_match(/content changed/, stdout, "Shouldn't have overwrote any files") + on(agent, puppet( %{apply --modulepath=#{localsource_testdir} #{localsource_test_manifest}} )) do |result| + refute_match(/content changed/, result.stdout, "Shouldn't have overwrote any files") end end diff --git a/acceptance/tests/resource/file/ticket_7680-follow-symlinks.rb b/acceptance/tests/resource/file/ticket_7680-follow-symlinks.rb index 59d79a2fa52..86d4fb94ee3 100644 --- a/acceptance/tests/resource/file/ticket_7680-follow-symlinks.rb +++ b/acceptance/tests/resource/file/ticket_7680-follow-symlinks.rb @@ -31,8 +31,8 @@ MANIFEST apply_manifest_on(agent, manifest, :trace => true) - on agent, "cat #{dest}" do - assert_match(/This is the real content/, stdout) + on(agent, "cat #{dest}") do |result| + assert_match(/This is the real content/, result.stdout) end step "Cleanup" diff --git a/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb b/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb index 6ae9fa3a58e..36f61c07eb7 100644 --- a/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb +++ b/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb @@ -20,14 +20,14 @@ on(agent, "#{ruby_command(agent)} -e \"require 'socket'; UNIXServer::new('#{target}').close\"") step "query for all files, which should return nothing" - on(agent, puppet_resource('file'), :acceptable_exit_codes => [1]) do - assert_match(%r{Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc}, stderr) + on(agent, puppet_resource('file'), :acceptable_exit_codes => [1]) do |result| + assert_match(%r{Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc}, result.stderr) end ["/", "/etc"].each do |file| step "query '#{file}' directory, which should return single entry" - on(agent, puppet_resource('file', file)) do - files = stdout.scan(/^file \{ '([^']+)'/).flatten + on(agent, puppet_resource('file', file)) do |result| + files = result.stdout.scan(/^file \{ '([^']+)'/).flatten assert_equal(1, files.size, "puppet returned multiple files: #{files.join(', ')}") assert_match(file, files[0], "puppet did not return file") @@ -35,8 +35,8 @@ end step "query file that does not exist, which should report the file is absent" - on(agent, puppet_resource('file', '/this/does/notexist')) do - assert_match(/ensure\s+=>\s+'absent'/, stdout) + on(agent, puppet_resource('file', '/this/does/notexist')) do |result| + assert_match(/ensure\s+=>\s+'absent'/, result.stdout) end step "remove UNIX domain socket" diff --git a/acceptance/tests/resource/group/should_modify_gid.rb b/acceptance/tests/resource/group/should_modify_gid.rb index 191bb0cc819..a394449ec56 100644 --- a/acceptance/tests/resource/group/should_modify_gid.rb +++ b/acceptance/tests/resource/group/should_modify_gid.rb @@ -14,13 +14,13 @@ agents.each do |agent| # AIX group provider returns quoted gids step "ensure that the group exists with gid #{gid1}" - on(agent, puppet_resource('group', name, 'ensure=present', "gid=#{gid1}")) do - fail_test "missing gid notice" unless stdout =~ /gid +=> +'?#{gid1}'?/ + on(agent, puppet_resource('group', name, 'ensure=present', "gid=#{gid1}")) do |result| + fail_test "missing gid notice" unless result.stdout =~ /gid +=> +'?#{gid1}'?/ end step "ensure that we can modify the GID of the group to #{gid2}" - on(agent, puppet_resource('group', name, 'ensure=present', "gid=#{gid2}")) do - fail_test "missing gid notice" unless stdout =~ /gid +=> +'?#{gid2}'?/ + on(agent, puppet_resource('group', name, 'ensure=present', "gid=#{gid2}")) do |result| + fail_test "missing gid notice" unless result.stdout =~ /gid +=> +'?#{gid2}'?/ end step "verify that the GID changed" diff --git a/acceptance/tests/resource/group/should_not_create_existing.rb b/acceptance/tests/resource/group/should_not_create_existing.rb index eb046d857d3..8105f21861a 100644 --- a/acceptance/tests/resource/group/should_not_create_existing.rb +++ b/acceptance/tests/resource/group/should_not_create_existing.rb @@ -13,9 +13,9 @@ agent.group_present(name) step "verify that we don't try and create the existing group" - on(agent, puppet_resource('group', name, 'ensure=present')) do + on(agent, puppet_resource('group', name, 'ensure=present')) do |result| fail_test "looks like we created the group" if - stdout.include? "/Group[#{name}]/ensure: created" + result.stdout.include? "/Group[#{name}]/ensure: created" end step "clean up the system after the test run" diff --git a/acceptance/tests/resource/group/should_not_destroy_unexisting.rb b/acceptance/tests/resource/group/should_not_destroy_unexisting.rb index 38397e80f5c..c734bdbfb2d 100644 --- a/acceptance/tests/resource/group/should_not_destroy_unexisting.rb +++ b/acceptance/tests/resource/group/should_not_destroy_unexisting.rb @@ -14,8 +14,8 @@ end step "verify that we don't remove the group when it doesn't exist" -on(agents, puppet_resource('group', name, 'ensure=absent')) do +on(agents, puppet_resource('group', name, 'ensure=absent')) do |result| fail_test "it looks like we tried to remove the group" if - stdout.include? "/Group[#{name}]/ensure: removed" + result.stdout.include? "/Group[#{name}]/ensure: removed" end diff --git a/acceptance/tests/resource/group/should_query.rb b/acceptance/tests/resource/group/should_query.rb index 07e3f6423e1..484122f825a 100644 --- a/acceptance/tests/resource/group/should_query.rb +++ b/acceptance/tests/resource/group/should_query.rb @@ -15,8 +15,8 @@ agent.group_present(name) step "query for the resource and verify it was found" - on(agent, puppet_resource('group', name)) do - fail_test "didn't find the group #{name}" unless stdout.include? 'present' + on(agent, puppet_resource('group', name)) do |result| + fail_test "didn't find the group #{name}" unless result.stdout.include? 'present' end step "clean up the group we added" diff --git a/acceptance/tests/resource/group/should_query_all.rb b/acceptance/tests/resource/group/should_query_all.rb index 3fb16c36560..ae1b36f9aed 100644 --- a/acceptance/tests/resource/group/should_query_all.rb +++ b/acceptance/tests/resource/group/should_query_all.rb @@ -13,8 +13,8 @@ fail_test("No groups found") unless groups step "query with puppet" - on(agent, puppet_resource('group')) do - stdout.each_line do |line| + on(agent, puppet_resource('group')) do |result| + result.stdout.each_line do |line| name = ( line.match(/^group \{ '([^']+)'/) or next )[1] unless groups.delete(name) diff --git a/acceptance/tests/resource/package/common_package_name_in_different_providers.rb b/acceptance/tests/resource/package/common_package_name_in_different_providers.rb index a95f78ef94f..c50dcf47137 100644 --- a/acceptance/tests/resource/package/common_package_name_in_different_providers.rb +++ b/acceptance/tests/resource/package/common_package_name_in_different_providers.rb @@ -50,12 +50,12 @@ def verify_state(hosts, pkg, state, match) hosts.each do |agent| cmd = rpm_provider(agent) # Note yum lists packages as . - on agent, "#{cmd} list installed" do - method(match).call(/^#{pkg}\./, stdout) + on(agent, "#{cmd} list installed") do |result| + method(match).call(/^#{pkg}\./, result.stdout) end - on agent, "#{gem_command(agent, @options[:type])} list --local" do - method(match).call(/^#{pkg} /, stdout) + on(agent, "#{gem_command(agent, @options[:type])} list --local") do |result| + method(match).call(/^#{pkg} /, result.stdout) end end end diff --git a/acceptance/tests/resource/package/does_not_exist.rb b/acceptance/tests/resource/package/does_not_exist.rb index a2cb46bf240..96fd9eee441 100644 --- a/acceptance/tests/resource/package/does_not_exist.rb +++ b/acceptance/tests/resource/package/does_not_exist.rb @@ -9,8 +9,8 @@ agents.each do |agent| step "test puppet resource package" do - on(agent, puppet('resource', 'package', 'not-installed-on-this-host')) do - assert_match(/package.*not-installed-on-this-host.*\n.*ensure.*(?:absent|purged).*\n.*provider/, stdout) + on(agent, puppet('resource', 'package', 'not-installed-on-this-host')) do |result| + assert_match(/package.*not-installed-on-this-host.*\n.*ensure.*(?:absent|purged).*\n.*provider/, result.stdout) end end @@ -21,8 +21,8 @@ confine_block(:to, :platform => /debian|ubuntu/) do agents.each do |agent| step "test puppet apply" do - on(agent, puppet('apply', '-e', %Q|"package {'not-installed-on-this-host': ensure => purged }"|)) do - refute_match(/warning/i, stdout) + on(agent, puppet('apply', '-e', %Q|"package {'not-installed-on-this-host': ensure => purged }"|)) do |result| + refute_match(/warning/i, result.stdout) end end end diff --git a/acceptance/tests/resource/package/yum.rb b/acceptance/tests/resource/package/yum.rb index d5c60a2d568..63ca497974f 100644 --- a/acceptance/tests/resource/package/yum.rb +++ b/acceptance/tests/resource/package/yum.rb @@ -29,8 +29,8 @@ def verify_state(hosts, pkg, state, match) hosts.each do |agent| cmd = rpm_provider(agent) # Note yum and dnf list packages as . - on agent, "#{cmd} list installed" do - method(match).call(/^#{pkg}\./, stdout) + on(agent, "#{cmd} list installed") do |result| + method(match).call(/^#{pkg}\./, result.stdout) end end end diff --git a/acceptance/tests/resource/service/AIX_service_provider.rb b/acceptance/tests/resource/service/AIX_service_provider.rb index 410f2269399..42ead3e4fe6 100644 --- a/acceptance/tests/resource/service/AIX_service_provider.rb +++ b/acceptance/tests/resource/service/AIX_service_provider.rb @@ -26,8 +26,8 @@ def lsitab_assert_enable(host, service, expected_status) raise "This test doesn't know what to do with an expected enable status of #{expected_status}" end - on host, "lsitab #{service} | cut -f 1 -d :" do - actual_output = stdout.chomp + on(host, "lsitab #{service} | cut -f 1 -d :") do |result| + actual_output = result.stdout.chomp assert_equal(expected_output, actual_output, "Service doesn't actually have enabled = #{expected_status}") end @@ -45,8 +45,8 @@ def lssrc_assert_status(host, service, expected_status) # sometimes there's no group or PID which messes up the condense to a single # delimiter - on host, "lssrc -s #{service} | tr -s ' ' ':' | tail -1 | cut -f 3- -d :" do - actual_output = stdout.chomp + on(host, "lssrc -s #{service} | tr -s ' ' ':' | tail -1 | cut -f 3- -d :") do |result| + actual_output = result.stdout.chomp assert_match(/#{expected_output}\Z/, actual_output, "Service is not actually #{expected_status}") end @@ -65,16 +65,16 @@ def lssrc_assert_status(host, service, expected_status) step "Setup on #{agent}" sloth_daemon_path = agent.tmpfile("sloth_daemon.sh") create_remote_file(agent, sloth_daemon_path, sloth_daemon_script) - on agent, "chmod +x #{sloth_daemon_path}" - on agent, "mkssys -s sloth_daemon -p #{sloth_daemon_path} -u 0 -S -n 15 -f 9" + on(agent, "chmod +x #{sloth_daemon_path}") + on(agent, "mkssys -s sloth_daemon -p #{sloth_daemon_path} -u 0 -S -n 15 -f 9") # Creating the service may also start it. Stop service before beginning the test. on(agent, puppet_resource('service', 'sloth_daemon', 'ensure=stopped', 'enable=false')) ## Query step "Verify the service exists on #{agent}" - on(agent, puppet_resource('service', 'sloth_daemon')) do - assert_match(/sloth_daemon/, stdout, "Couldn't find service sloth_daemon") + on(agent, puppet_resource('service', 'sloth_daemon')) do |result| + assert_match(/sloth_daemon/, result.stdout, "Couldn't find service sloth_daemon") end ## Start the service diff --git a/acceptance/tests/resource/service/init_on_systemd.rb b/acceptance/tests/resource/service/init_on_systemd.rb index 7175b67ca23..94a15a5fb12 100644 --- a/acceptance/tests/resource/service/init_on_systemd.rb +++ b/acceptance/tests/resource/service/init_on_systemd.rb @@ -1,8 +1,9 @@ test_name 'SysV on default Systemd Service Provider Validation' do confine :to, :platform => /el-[6-8]|centos|fedora-(2[0-9])/ do |h| - on h, 'which systemctl', :acceptable_exit_codes => [0, 1] - stdout =~ /systemctl/ + on(h, 'which systemctl', :acceptable_exit_codes => [0, 1]) do |result| + result.stdout =~ /systemctl/ + end end tag 'audit:high', @@ -80,12 +81,11 @@ def initd_file(svc, pidfile, initd_location, status) end def assert_service_status(agent, pidfile, expected_running) - on agent, "ps -p `cat #{pidfile}`", :acceptable_exit_codes => (expected_running ? [0] : [1]) + on(agent, "ps -p `cat #{pidfile}`", :acceptable_exit_codes => (expected_running ? [0] : [1])) end agents.each do |agent| - on agent, 'which sleep' - sleep_bin = stdout.chomp + sleep_bin = on(agent, 'which sleep').stdout.chomp step "Create initd script with status command" do create_remote_file agent, initd_location, initd_file(svc, pidfile, initd_location, true) @@ -93,9 +93,9 @@ def assert_service_status(agent, pidfile, expected_running) file {'/usr/bin/#{svc}': ensure => link, target => '#{sleep_bin}', } file {'#{initd_location}': ensure => file, mode => '0755', } MANIFEST - on agent, "chkconfig --add #{svc}" - on agent, "chkconfig #{svc}", :acceptable_exit_codes => [0] - on agent, "service #{svc} status", :acceptable_exit_codes => [3] + on(agent, "chkconfig --add #{svc}") + on(agent, "chkconfig #{svc}", :acceptable_exit_codes => [0]) + on(agent, "service #{svc} status", :acceptable_exit_codes => [3]) end step "Verify the service exists on #{agent}" do @@ -134,9 +134,9 @@ def assert_service_status(agent, pidfile, expected_running) file {'/usr/bin/#{svc}': ensure => link, target => '#{sleep_bin}', } file {'#{initd_location}': ensure => file, mode => '0755', } MANIFEST - on agent, "chkconfig --add #{svc}" - on agent, "chkconfig #{svc}", :acceptable_exit_codes => [0] - on agent, "service #{svc} status", :acceptable_exit_codes => [1] + on(agent, "chkconfig --add #{svc}") + on(agent, "chkconfig #{svc}", :acceptable_exit_codes => [0]) + on(agent, "service #{svc} status", :acceptable_exit_codes => [1]) end step "Verify the service exists on #{agent}" do @@ -176,9 +176,9 @@ def assert_service_status(agent, pidfile, expected_running) end teardown do - on agent, "service #{svc} stop", :accept_any_exit_code => true - on agent, "chkconfig --del #{svc}" - on agent, "rm /usr/bin/#{svc} #{initd_location}" + on(agent, "service #{svc} stop", :accept_any_exit_code => true) + on(agent, "chkconfig --del #{svc}") + on(agent, "rm /usr/bin/#{svc} #{initd_location}") end end end diff --git a/acceptance/tests/resource/service/launchd_provider.rb b/acceptance/tests/resource/service/launchd_provider.rb index d84cd5e285d..b13e1879bd0 100644 --- a/acceptance/tests/resource/service/launchd_provider.rb +++ b/acceptance/tests/resource/service/launchd_provider.rb @@ -20,11 +20,11 @@ launchd_script_path = "/Library/LaunchDaemons/#{svc}.plist" def launchctl_assert_status(host, service, expect_running) - on host, 'launchctl list' do + on(host, 'launchctl list') do |result| if expect_running - assert_match(/#{service}/, stdout, 'Service was not found in launchctl list') + assert_match(/#{service}/, result.stdout, 'Service was not found in launchctl list') else - refute_match(/#{service}/, stdout, 'Service was not expected in launchctl list') + refute_match(/#{service}/, result.stdout, 'Service was not expected in launchctl list') end end end diff --git a/acceptance/tests/resource/service/should_not_change_the_system.rb b/acceptance/tests/resource/service/should_not_change_the_system.rb index 7d72992d663..2a3b46d3750 100644 --- a/acceptance/tests/resource/service/should_not_change_the_system.rb +++ b/acceptance/tests/resource/service/should_not_change_the_system.rb @@ -24,10 +24,12 @@ end step "list running services and make sure ssh reports running" - on(agent, puppet('resource service')) - assert_match(/service { '#{service_name}':\n\s*ensure\s*=>\s*'(?:true|running)'/, stdout, "ssh is not running") + on(agent, puppet('resource service')) do |result| + assert_match(/service { '#{service_name}':\n\s*ensure\s*=>\s*'(?:true|running)'/, result.stdout, "ssh is not running") + end step "list running services again and make sure ssh is still running" - on(agent, puppet('resource service')) - assert_match(/service { '#{service_name}':\n\s*ensure\s*=>\s*'(?:true|running)'/, stdout, "ssh is no longer running") + on(agent, puppet('resource service')) do |result| + assert_match(/service { '#{service_name}':\n\s*ensure\s*=>\s*'(?:true|running)'/, result.stdout, "ssh is no longer running") + end end diff --git a/acceptance/tests/resource/service/should_query_all.rb b/acceptance/tests/resource/service/should_query_all.rb index 38dd2a63706..f0ab8e2ad94 100644 --- a/acceptance/tests/resource/service/should_query_all.rb +++ b/acceptance/tests/resource/service/should_query_all.rb @@ -7,8 +7,8 @@ agents.each do |agent| step "query with puppet" - on(agent, puppet_resource('service'), :accept_all_exit_codes => true) do + on(agent, puppet_resource('service'), :accept_all_exit_codes => true) do |result| assert_equal(exit_code, 0, "'puppet resource service' should have an exit code of 0") - assert(/^service/ =~ stdout, "'puppet resource service' should present service details") + assert(/^service/ =~ result.stdout, "'puppet resource service' should present service details") end end diff --git a/acceptance/tests/resource/service/systemd_resource_shows_correct_output.rb b/acceptance/tests/resource/service/systemd_resource_shows_correct_output.rb index 916edc5a013..21a63ccbf0f 100644 --- a/acceptance/tests/resource/service/systemd_resource_shows_correct_output.rb +++ b/acceptance/tests/resource/service/systemd_resource_shows_correct_output.rb @@ -24,9 +24,9 @@ end step "Expect reported status to match system state" do - on(agent, puppet_resource('service', package_name, 'ensure=stopped', 'enable=true')) do - assert_match(/ensure\s*=>\s*'stopped'/, stdout, "Expected '#{package_name}' service to appear as stopped") - assert_match(/enable\s*=>\s*'true'/, stdout, "Expected '#{package_name}' service to appear as enabled") + on(agent, puppet_resource('service', package_name, 'ensure=stopped', 'enable=true')) do |result| + assert_match(/ensure\s*=>\s*'stopped'/, result.stdout, "Expected '#{package_name}' service to appear as stopped") + assert_match(/enable\s*=>\s*'true'/, result.stdout, "Expected '#{package_name}' service to appear as enabled") end end end diff --git a/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb b/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb index 30ce975d864..839841ef4bc 100644 --- a/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb +++ b/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb @@ -71,21 +71,21 @@ step "Masking the #{package_name[platform]} service" apply_manifest_on(agent, manifest_service_masked, :catch_failures => true) - on(agent, puppet_resource('service', package_name[platform])) do - assert_match(/ensure.+=> 'stopped'/, stdout, "Expected #{package_name[platform]} service to be stopped") - assert_match(/enable.+=> 'false'/, stdout, "Expected #{package_name[platform]} service to be masked") - on(agent, "readlink #{masked_symlink_systemd}") do - assert_equal('/dev/null', stdout.chomp, "Expected service symlink to point to /dev/null") + on(agent, puppet_resource('service', package_name[platform])) do |result| + assert_match(/ensure.+=> 'stopped'/, result.stdout, "Expected #{package_name[platform]} service to be stopped") + assert_match(/enable.+=> 'false'/, result.stdout, "Expected #{package_name[platform]} service to be masked") + on(agent, "readlink #{masked_symlink_systemd}") do |readlink_result| + assert_equal('/dev/null', readlink_result.stdout.chomp, "Expected service symlink to point to /dev/null") end end step "Enabling the #{package_name[platform]} service" apply_manifest_on(agent, manifest_service_enabled, :catch_failures => true) - on(agent, puppet_resource('service', package_name[platform])) do - assert_match(/ensure.+=> 'running'/, stdout, "Expected #{package_name[platform]} service to be running") - assert_match(/enable.+=> 'true'/, stdout, "Expected #{package_name[platform]} service to be enabled") - on(agent, "readlink #{symlink_systemd}") do - assert_equal(init_script_systemd, stdout.chomp, "Expected service symlink to point to systemd init script") + on(agent, puppet_resource('service', package_name[platform])) do |result| + assert_match(/ensure.+=> 'running'/, result.stdout, "Expected #{package_name[platform]} service to be running") + assert_match(/enable.+=> 'true'/, result.stdout, "Expected #{package_name[platform]} service to be enabled") + on(agent, "readlink #{symlink_systemd}") do |readlink_result| + assert_equal(init_script_systemd, readlink_result.stdout.chomp, "Expected service symlink to point to systemd init script") end end end diff --git a/acceptance/tests/resource/user/should_create_modify_with_password.rb b/acceptance/tests/resource/user/should_create_modify_with_password.rb index 1349a384029..123599d5cda 100644 --- a/acceptance/tests/resource/user/should_create_modify_with_password.rb +++ b/acceptance/tests/resource/user/should_create_modify_with_password.rb @@ -35,8 +35,8 @@ end step 'verify the password was set correctly' do - on(agent, puppet('resource', 'user', name), acceptable_exit_codes: 0) do - assert_match(/password\s*=>\s*'#{initial_password}'/, stdout, 'Password was not set correctly') + on(agent, puppet('resource', 'user', name), acceptable_exit_codes: 0) do |result| + assert_match(/password\s*=>\s*'#{initial_password}'/, result.stdout, 'Password was not set correctly') end end @@ -50,8 +50,8 @@ end step 'verify the password was set correctly' do - on(agent, "puppet resource user #{name}", acceptable_exit_codes: 0) do - assert_match(/password\s*=>\s*'#{modified_password}'/, stdout, 'Password was not changed correctly') + on(agent, "puppet resource user #{name}", acceptable_exit_codes: 0) do |result| + assert_match(/password\s*=>\s*'#{modified_password}'/, result.stdout, 'Password was not changed correctly') end end diff --git a/acceptance/tests/resource/user/should_not_create_existing.rb b/acceptance/tests/resource/user/should_not_create_existing.rb index 87bbb25d310..6ea19f77e55 100644 --- a/acceptance/tests/resource/user/should_not_create_existing.rb +++ b/acceptance/tests/resource/user/should_not_create_existing.rb @@ -25,8 +25,8 @@ step "verify that we don't try to create a user account that already exists" do agents.each do |agent| - on(agent, puppet_resource('user', user, 'ensure=present')) do - fail_test "tried to create '#{user}' user" if stdout.include? 'created' + on(agent, puppet_resource('user', user, 'ensure=present')) do |result| + fail_test "tried to create '#{user}' user" if result.stdout.include? 'created' end end end diff --git a/acceptance/tests/resource/user/should_not_destroy_unexisting.rb b/acceptance/tests/resource/user/should_not_destroy_unexisting.rb index 3a6e626e2a7..b8290237d68 100644 --- a/acceptance/tests/resource/user/should_not_destroy_unexisting.rb +++ b/acceptance/tests/resource/user/should_not_destroy_unexisting.rb @@ -15,6 +15,6 @@ end step "ensure absent doesn't try and do anything" -on(agents, puppet_resource('user', name, 'ensure=absent')) do - fail_test "tried to remove the user, apparently" if stdout.include? 'removed' +on(agents, puppet_resource('user', name, 'ensure=absent')) do |result| + fail_test "tried to remove the user, apparently" if result.stdout.include? 'removed' end diff --git a/acceptance/tests/resource/user/should_query.rb b/acceptance/tests/resource/user/should_query.rb index e9ce3b921ef..3e544be27d5 100644 --- a/acceptance/tests/resource/user/should_query.rb +++ b/acceptance/tests/resource/user/should_query.rb @@ -14,8 +14,8 @@ agent.user_present(name) step "query for the resource and verify it was found" - on(agent, puppet_resource('user', name)) do - fail_test "didn't find the user #{name}" unless stdout.include? 'present' + on(agent, puppet_resource('user', name)) do |result| + fail_test "didn't find the user #{name}" unless result.stdout.include? 'present' end step "clean up the user and group we added" diff --git a/acceptance/tests/resource/user/should_query_all.rb b/acceptance/tests/resource/user/should_query_all.rb index 07b0a221c9e..1caaba1e11f 100644 --- a/acceptance/tests/resource/user/should_query_all.rb +++ b/acceptance/tests/resource/user/should_query_all.rb @@ -14,8 +14,8 @@ fail_test("No users found") unless users step "query with puppet" - on(agent, puppet_resource('user')) do - stdout.each_line do |line| + on(agent, puppet_resource('user')) do |result| + result.stdout.each_line do |line| name = ( line.match(/^user \{ '([^']+)'/) or next )[1] unless users.delete(name) diff --git a/acceptance/tests/security/cve-2013-2275_report_acl.rb b/acceptance/tests/security/cve-2013-2275_report_acl.rb index 714fd8dfd31..0ab74854f6e 100644 --- a/acceptance/tests/security/cve-2013-2275_report_acl.rb +++ b/acceptance/tests/security/cve-2013-2275_report_acl.rb @@ -28,8 +28,8 @@ "\"https://#{master}:8140/puppet/v3/report/mccune?environment=production\"", ].join(" ") - on master, submit_fake_report_cmd, :acceptable_exit_codes => [0] do + on(master, submit_fake_report_cmd, :acceptable_exit_codes => [0]) do |result| msg = "(#19531) (CVE-2013-2275) Puppet Server accepted a report for a node that does not match the certname" - assert_match(/Forbidden request/, stdout, msg) + assert_match(/Forbidden request/, result.stdout, msg) end end diff --git a/acceptance/tests/ssl/autosign_command.rb b/acceptance/tests/ssl/autosign_command.rb index b764d20880a..e0b393ff698 100644 --- a/acceptance/tests/ssl/autosign_command.rb +++ b/acceptance/tests/ssl/autosign_command.rb @@ -5,7 +5,7 @@ 'audit:integration', 'server' # Ruby implementation is deprecated - def assert_key_generated(name) + def assert_key_generated(name, stdout) assert_match(/Creating a new RSA SSL key for #{name}/, stdout, "Expected agent to create a new SSL key for autosigning") end @@ -66,10 +66,11 @@ def assert_key_generated(name) on(agent, puppet("agent --test", "--waitforcert 0", "--ssldir", "'#{testdirs[agent]}/ssldir-autosign'", - "--certname #{certname}"), :acceptable_exit_codes => [0,2]) - unless agent['locale'] == 'ja' - assert_key_generated(agent) - assert_match(/Downloaded certificate for #{agent}/, stdout, "Expected certificate to be autosigned") + "--certname #{certname}"), :acceptable_exit_codes => [0,2]) do |result| + unless agent['locale'] == 'ja' + assert_key_generated(agent, result.stdout) + assert_match(/Downloaded certificate for #{agent}/, result.stdout, "Expected certificate to be autosigned") + end end end end @@ -106,10 +107,11 @@ def assert_key_generated(name) on(agent, puppet("agent --test", "--waitforcert 0", "--ssldir", "'#{testdirs[agent]}/ssldir-reject'", - "--certname #{certname}"), :acceptable_exit_codes => [1]) - unless agent['locale'] == 'ja' - assert_key_generated(agent) - assert_match(/Certificate for #{agent}-reject has not been signed yet/, stdout, "Expected certificate to not be autosigned") + "--certname #{certname}"), :acceptable_exit_codes => [1]) do |result| + unless agent['locale'] == 'ja' + assert_key_generated(agent, result.stdout) + assert_match(/Certificate for #{agent}-reject has not been signed yet/, result.stdout, "Expected certificate to not be autosigned") + end end end end @@ -175,9 +177,10 @@ def unwrap_attr(attr) "--waitforcert 0", "--ssldir", "'#{testdirs[agent]}/ssldir-attrs'", "--csr_attributes '#{agent_csr_attributes[agent]}'", - "--certname #{certname}"), :acceptable_exit_codes => [0,2]) - assert_key_generated(agent) unless agent['locale'] == 'ja' - assert_match(/Downloaded certificate for #{agent}/, stdout, "Expected certificate to be autosigned") + "--certname #{certname}"), :acceptable_exit_codes => [0,2]) do |result| + assert_key_generated(agent, result.stdout) unless agent['locale'] == 'ja' + assert_match(/Downloaded certificate for #{agent}/, result.stdout, "Expected certificate to be autosigned") + end end end end diff --git a/acceptance/tests/ticket_2455_on_solaris_init_provider_should_start_service_in_own_smf_contract.rb b/acceptance/tests/ticket_2455_on_solaris_init_provider_should_start_service_in_own_smf_contract.rb index 5589ddee812..66ee6db516f 100644 --- a/acceptance/tests/ticket_2455_on_solaris_init_provider_should_start_service_in_own_smf_contract.rb +++ b/acceptance/tests/ticket_2455_on_solaris_init_provider_should_start_service_in_own_smf_contract.rb @@ -115,9 +115,9 @@ step "Start the fixture service on #{agent} " on(agent, puppet("resource service #{fixture_service} provider=init ensure=stopped")) - on(agent, puppet("resource service #{fixture_service} provider=init ensure=running")) - - assert_match(/ensure changed 'stopped' to 'running'/, stdout, "The fixture service #{fixture_service} is not in a testable state on #{agent}.") + on(agent, puppet("resource service #{fixture_service} provider=init ensure=running")) do |result| + assert_match(/ensure changed 'stopped' to 'running'/, stdout, "The fixture service #{fixture_service} is not in a testable state on #{agent}.") + end step "Verify whether the fixture process is alone in its SMF contract on #{agent}" service_ctid = on(agent, "sleep 10;ps -eo ctid,args | grep #{fixture_service} | grep -v grep | awk '{print $1}'").stdout.chomp.to_i diff --git a/acceptance/tests/ticket_5477_master_not_dectect_sitepp.rb b/acceptance/tests/ticket_5477_master_not_dectect_sitepp.rb index 7065dd96e62..77090aba2d7 100644 --- a/acceptance/tests/ticket_5477_master_not_dectect_sitepp.rb +++ b/acceptance/tests/ticket_5477_master_not_dectect_sitepp.rb @@ -53,8 +53,8 @@ step "Agent: puppet agent --test" agents.each do |host| - on(host, puppet('agent', "-t"), :acceptable_exit_codes => [2]) do - assert_match(/ticket_5477_notify/, stdout, "#{host}: Site.pp not detected on Puppet Master") + on(host, puppet('agent', "-t"), :acceptable_exit_codes => [2]) do |result| + assert_match(/ticket_5477_notify/, result.stdout, "#{host}: Site.pp not detected on Puppet Master") end end end diff --git a/acceptance/tests/ticket_5592_hiera_lookup_when_param_undef.rb b/acceptance/tests/ticket_5592_hiera_lookup_when_param_undef.rb index 935e7cd2ad1..e789102623d 100644 --- a/acceptance/tests/ticket_5592_hiera_lookup_when_param_undef.rb +++ b/acceptance/tests/ticket_5592_hiera_lookup_when_param_undef.rb @@ -65,8 +65,9 @@ class test ( end step 'Invoke class with undef param and verify hiera value was applied' do - on(agent, puppet('apply', "-e 'class {\"test\": my_param => undef }'", "--modulepath=#{testdir}/environments/production/modules", "--hiera_config=#{testdir}/hiera.yaml" ), :acceptable_exit_codes => [0,2]) - assert_match("hiera lookup value", stdout) + on(agent, puppet('apply', "-e 'class {\"test\": my_param => undef }'", "--modulepath=#{testdir}/environments/production/modules", "--hiera_config=#{testdir}/hiera.yaml" ), :acceptable_exit_codes => [0,2]) do |result| + assert_match('hiera lookup value', result.stdout) + end end end diff --git a/acceptance/tests/ticket_6541_invalid_filebucket_files.rb b/acceptance/tests/ticket_6541_invalid_filebucket_files.rb index 7c432b29db2..abced104755 100644 --- a/acceptance/tests/ticket_6541_invalid_filebucket_files.rb +++ b/acceptance/tests/ticket_6541_invalid_filebucket_files.rb @@ -8,7 +8,7 @@ agents.each do |agent| target=agent.tmpfile('6541-target') - on agent, "rm -rf \"#{agent.puppet['vardir']}/*bucket\"" + on(agent, "rm -rf \"#{agent.puppet['vardir']}/*bucket\"") step "write zero length file" manifest = "file { '#{target}': content => '' }" @@ -22,20 +22,20 @@ manifest = "file { '#{target}': content => '{sha256}notahash' }" - apply_manifest_on(agent, manifest) do - refute_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote the file") + apply_manifest_on(agent, manifest) do |result| + refute_match(/content changed/, result.stdout, "#{agent}: shouldn't have overwrote the file") end test_name "verify valid but unbucketed hashes should not change the file" manifest = "file { '#{target}': content => '{md5}13ad7345d56b566a4408ffdcd877bc78' }" - apply_manifest_on(agent, manifest) do - refute_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote the file") + apply_manifest_on(agent, manifest) do |result| + refute_match(/content changed/, result.stdout, "#{agent}: shouldn't have overwrote the file") end test_name "verify that an empty file can be retrieved from the filebucket" manifest = "file { '#{target}': content => '{sha256}e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', backup => 'puppet' }" - apply_manifest_on(agent, manifest) do - assert_match(/content changed '\{sha256\}b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2' to '\{sha256\}e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'/, stdout, "#{agent}: shouldn't have overwrote the file") + apply_manifest_on(agent, manifest) do |result| + assert_match(/content changed '\{sha256\}b94f6f125c79e3a5ffaa826f584c10d52ada669e6762051b826b55776d05aed2' to '\{sha256\}e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'/, result.stdout, "#{agent}: shouldn't have overwrote the file") end end diff --git a/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb b/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb index 7df10622c90..56ff0886aeb 100644 --- a/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb +++ b/acceptance/tests/ticket_9862_puppet_runs_without_service_user_or_group_present.rb @@ -21,19 +21,19 @@ def assert_ownership(agent, location, expected_user, expected_group) def missing_directory_for(agent, dir) agent_dir = get_test_file_path(agent, dir) - on agent, "rm -rf #{agent_dir}" + on(agent, "rm -rf #{agent_dir}") agent_dir end teardown do agents.each do |agent| step "ensure puppet resets it's user/group settings" - on agent, puppet('apply', '-e', '"notify { puppet_run: }"') - on agent, "find \"#{agent.puppet['vardir']}\" -user exist_u", {:acceptable_exit_codes => [0, 1]} do - assert_equal('',stdout) + on(agent, puppet('apply', '-e', '"notify { puppet_run: }"')) + on(agent, "find \"#{agent.puppet['vardir']}\" -user exist_u", {:acceptable_exit_codes => [0, 1]}) do |result| + assert_equal('', result.stdout) end - on agent, puppet('resource', 'user', 'exist_u', 'ensure=absent') - on agent, puppet('resource', 'group', 'exist_g', 'ensure=absent') + on(agent, puppet('resource', 'user', 'exist_u', 'ensure=absent')) + on(agent, puppet('resource', 'group', 'exist_g', 'ensure=absent')) end end @@ -41,13 +41,13 @@ def missing_directory_for(agent, dir) agents.each do |agent| logdir = missing_directory_for(agent, 'log') - on agent, puppet('apply', + on(agent, puppet('apply', '-e', '"notify { puppet_run: }"', '--logdir', logdir, '--user', 'missinguser', - '--group', 'missinggroup') do + '--group', 'missinggroup')) do |result| - assert_match(/puppet_run/, stdout) + assert_match(/puppet_run/, result.stdout) assert_ownership(agent, logdir, root_user(agent), root_group(agent)) end end @@ -56,16 +56,16 @@ def missing_directory_for(agent, dir) agents.each do |agent| logdir = missing_directory_for(agent, 'log') - on agent, puppet('resource', 'user', 'exist_u', 'ensure=present') - on agent, puppet('resource', 'group', 'exist_g', 'ensure=present') + on(agent, puppet('resource', 'user', 'exist_u', 'ensure=present')) + on(agent, puppet('resource', 'group', 'exist_g', 'ensure=present')) - on agent, puppet('apply', + on(agent, puppet('apply', '-e', '"notify { puppet_run: }"', '--logdir', logdir, '--user', 'exist_u', - '--group', 'exist_g') do + '--group', 'exist_g')) do |result| - assert_match(/puppet_run/, stdout) + assert_match(/puppet_run/, result.stdout) assert_ownership(agent, logdir, 'exist_u', 'exist_g') end end diff --git a/acceptance/tests/utf8/utf8-in-file-resource.rb b/acceptance/tests/utf8/utf8-in-file-resource.rb index 6583a0fa0f9..ed913936be7 100755 --- a/acceptance/tests/utf8/utf8-in-file-resource.rb +++ b/acceptance/tests/utf8/utf8-in-file-resource.rb @@ -42,14 +42,8 @@ :environment => {:LANG => "en_US.UTF-8"} } ) - on( - agent, "cat #{agent_file}", :environment => {:LANG => "en_US.UTF-8"} - ) do - assert_match( - /#{utf8chars}/, - stdout, - "result stdout did not contain \"#{utf8chars}\"", - ) + on(agent, "cat #{agent_file}", :environment => {:LANG => "en_US.UTF-8"}) do |result| + assert_match(/#{utf8chars}/, result.stdout, "result stdout did not contain \"#{utf8chars}\"") end end @@ -68,16 +62,8 @@ :environment => {:LANG => "en_US.UTF-8"} } ) - on( - agent, - "cat #{agent_file}", - :environment => {:LANG => "en_US.UTF-8"} - ) do - assert_match( - /#{utf8chars}/, - stdout, - "result stdout did not contain \"#{utf8chars}\"" - ) + on(agent, "cat #{agent_file}", :environment => {:LANG => "en_US.UTF-8"}) do |result| + assert_match(/#{utf8chars}/, result.stdout, "result stdout did not contain \"#{utf8chars}\"") end end end