Skip to content

Commit

Permalink
Update deprecated Beaker method
Browse files Browse the repository at this point in the history
The assert_no_match method in Beaker was long deprecated then eventually
removed altogether in voxpupuli/beaker@6282311

This commit updates all instances of assert_no_match in Puppet's Beaker
tests with refute_match.
  • Loading branch information
mhashizume committed Jan 30, 2024
1 parent 99ae2cf commit 0162588
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion acceptance/tests/agent/last_run_summary_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

step "Check that '#{statedir}' exists and has no 'last_run_summary.yaml' file" do
on(agent, "ls #{statedir}",:acceptable_exit_codes => [0]) do |result|
assert_no_match(/last_run_summary.yaml/, result.stdout)
refute_match(/last_run_summary.yaml/, result.stdout)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

step 'Expect no production environment folder changes' do
on(agent, "ls #{custom_environment_path}") do |result|
assert_no_match(/production/, result.stdout)
refute_match(/production/, result.stdout)
end

on(agent, "ls #{default_environment_path}") do |result|
Expand All @@ -110,7 +110,7 @@
step 'Expect production environment folder to be recreated in the custom path' do
on(agent, puppet("agent -t"), :acceptable_exit_codes => [0, 2]) do |result|
step 'Expect the module to be gone on the server node' do
assert_no_match(/Error:.*i18ndemo/, result.stderr)
refute_match(/Error:.*i18ndemo/, result.stderr)
end if agent == master

step 'Expect the production environment, along with the module, to be synced back on the agent node' do
Expand All @@ -123,7 +123,7 @@
end

on(agent, "ls #{default_environment_path}") do |result|
assert_no_match(/production/, result.stdout)
refute_match(/production/, result.stdout)
end
end

Expand All @@ -134,7 +134,7 @@
step 'Expect production environment folder to be found in both paths but use the default one' do
on(agent, puppet("agent -t"), :acceptable_exit_codes => [0, 2]) do |result|
step 'Expect the module to be gone' do
assert_no_match(/Error:.*i18ndemo/, result.stderr)
refute_match(/Error:.*i18ndemo/, result.stderr)
end if agent == master
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def run_with_environment(agent, environment, options = {})
end

run_with_environment(agent, "production", :expected_exit_code => 2) do |tmpdir, catalog_result|
assert_no_match(/module-atmp/, catalog_result.stdout, "module-atmp was included despite the default environment being loaded")
refute_match(/module-atmp/, catalog_result.stdout, "module-atmp was included despite the default environment being loaded")

assert_match(/environment fact from module-globalmod/, catalog_result.stdout)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def refresh

step 'compile catalog and make sure that ruby code is NOT executed' do
on master, puppet('catalog', 'find', master.hostname) do |result|
assert_no_match(/running ruby code/, result.stderr)
refute_match(/running ruby code/, result.stderr)
catalog_results[master.hostname]['pcore_cat'] = JSON.parse(result.stdout.sub(/^[^{]+/,''))
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
with_puppet_running_on master, master_opts, basedir do
agents.each do |agent|
on(agent, puppet('agent', "-t"))
assert_no_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/pluginfacts/, stderr)
assert_no_match(/Could not retrieve information from environment production source\(s\) puppet:\/\/\/plugins/, stderr)
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)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def main()

step "run the agent" do
on(agent, puppet("agent --libdir='#{agent_lib_dir}' --test --environment '#{tmp_environment}'")) do |result|
assert_no_match(
refute_match(
/The \`source_permissions\` parameter is deprecated/,
result.stderr,
"pluginsync should not get a deprecation warning for source_permissions")
Expand Down
4 changes: 2 additions & 2 deletions acceptance/tests/provider/package/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
package_manifest = resource_manifest('package', package, { ensure: 'absent', provider: 'gem' } )
apply_manifest_on(agent, package_manifest, :catch_failures => true) do
list = on(agent, "#{system_gem_command} list").stdout
assert_no_match(/#{package} \(/, list)
refute_match(/#{package} \(/, list)
end
on(agent, "#{system_gem_command} uninstall #{package}")
end
Expand Down Expand Up @@ -106,7 +106,7 @@
package_manifest = resource_manifest('package', package, { ensure: 'absent', provider: 'gem', command: puppet_gem_command } )
apply_manifest_on(agent, package_manifest, :catch_failures => true) do
list = on(agent, "#{puppet_gem_command} list").stdout
assert_no_match(/#{package} \(/, list)
refute_match(/#{package} \(/, list)
end
on(agent, "#{puppet_gem_command} uninstall #{package}")
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/provider/package/pip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
package_manifest = resource_manifest('package', package, { ensure: 'absent', provider: 'pip' } )
apply_manifest_on(agent, package_manifest, :catch_failures => true) do
list = on(agent, "#{pip_command} list --disable-pip-version-check").stdout
assert_no_match(/#{package} \(/, list)
refute_match(/#{package} \(/, list)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/provider/package/puppetserver_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
package_manifest = resource_manifest('package', package, { ensure: 'absent', provider: 'puppetserver_gem' } )
apply_manifest_on(master, package_manifest, catch_failures: true) do
list = on(master, "puppetserver gem list").stdout
assert_no_match(/#{package} \(/, list)
refute_match(/#{package} \(/, list)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

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")
assert_no_match(/content: Received a Log attribute with invalid encoding:/, stdout, "#{agent}: Received a Log attribute with invalid encoding")
refute_match(/content: Received a Log attribute with invalid encoding:/, 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")
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/file/content_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}.join("\n")
apply_manifest_on agent, manifest do
checksums.each do |checksum_type|
assert_no_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote #{target+checksum_type}")
refute_match(/content changed/, stdout, "#{agent}: shouldn't have overwrote #{target+checksum_type}")
end
end

Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/file/handle_fifo_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def ensure_content_to_file_manifest(file_path, ensure_value)
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)
assert_no_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr)
refute_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ensure_owner_recursively_manifest(path, owner_value)
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)
assert_no_match(/Error: .+ Failed to generate additional resources using ‘eval_generate’: Cannot manage files of type fifo/, stderr)
refute_match(/Error: .+ Failed to generate additional resources using ‘eval_generate’: Cannot manage files of type fifo/, stderr)
end
end

Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/file/should_default_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def regexp_mode(mode)
file = "#{parent}/file.txt"
on(agent, "echo foobar > #{file}")
on(agent, "#{file}", :acceptable_exit_codes => (1..255)) do
assert_no_match(/foobar/, stdout)
refute_match(/foobar/, stdout)
end

step "set execute bit on file if explicitly specified"
Expand Down
10 changes: 5 additions & 5 deletions acceptance/tests/resource/file/source_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class source_test_module {

step "second run should not update file"
on(agent, puppet('agent', "--test"), :acceptable_exit_codes => [0,2]) do
assert_no_match(/content changed.*(md5|sha256)/, stdout, "Shouldn't have overwritten any files")
refute_match(/content changed.*(md5|sha256)/, 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
Expand Down Expand Up @@ -255,7 +255,7 @@ class source_test_module {

step "second run should not update any files"
apply_manifest_on agent, local_apply_manifest do
assert_no_match(/content changed/, stdout, "Shouldn't have overwrote any files")
refute_match(/content changed/, stdout, "Shouldn't have overwrote any files")
end

# changes in source file producing updates is tested elsewhere
Expand All @@ -266,11 +266,11 @@ class source_test_module {

if fips_host_present
apply_manifest_on agent, "file { '#{localsource_testdir}/targetsha256lite': source => '#{source}', ensure => present, checksum => sha256lite }" do
assert_no_match(/(content changed|defined content)/, stdout, "Shouldn't have overwrote any files")
refute_match(/(content changed|defined content)/, 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
assert_no_match(/(content changed|defined content)/, stdout, "Shouldn't have overwrote any files")
refute_match(/(content changed|defined content)/, stdout, "Shouldn't have overwrote any files")
end
end

Expand All @@ -294,7 +294,7 @@ class source_test_module {

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
assert_no_match(/content changed/, stdout, "Shouldn't have overwrote any files")
refute_match(/content changed/, stdout, "Shouldn't have overwrote any files")
end
end

Expand Down
6 changes: 3 additions & 3 deletions acceptance/tests/resource/file/symbolic_modes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def manifest

def puppet_reapply
@testcase.apply_manifest_on(@agent, manifest) do |apply_result|
assert_no_match(/mode changed/, apply_result.stdout, "reapplied the symbolic mode change")
refute_match(/mode changed/, apply_result.stdout, "reapplied the symbolic mode change")
(@file_list + @directory_list).each do |file|
assert_no_match(/#{Regexp.escape(file.path)}/, apply_result.stdout, "Expected to not see '#{file.path}' in 'puppet apply' output")
refute_match(/#{Regexp.escape(file.path)}/, apply_result.stdout, "Expected to not see '#{file.path}' in 'puppet apply' output")
end
end
end
Expand Down Expand Up @@ -119,7 +119,7 @@ def puppet_apply
assert_match(/File\[#{Regexp.escape(file.path)}.* mode changed '#{'%04o' % file.start_mode}'.* to '#{'%04o' % file.mode}'/,
apply_result, "couldn't set mode to #{file.symbolic_mode}")
else
assert_no_match(/#{Regexp.escape(file.path)}.*mode changed/, apply_result, "reapplied the symbolic mode change for file #{file.path}")
refute_match(/#{Regexp.escape(file.path)}.*mode changed/, apply_result, "reapplied the symbolic mode change for file #{file.path}")
end
assert_mode(@agent, file.path, file.mode)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def verify_present(hosts, pkg)
end

def verify_absent(hosts, pkg)
verify_state(hosts, pkg, '(?:purged|absent)', :assert_no_match)
verify_state(hosts, pkg, '(?:purged|absent)', :refute_match)
end

# Setup repo and package
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/package/does_not_exist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
agents.each do |agent|
step "test puppet apply" do
on(agent, puppet('apply', '-e', %Q|"package {'not-installed-on-this-host': ensure => purged }"|)) do
assert_no_match(/warning/i, stdout)
refute_match(/warning/i, stdout)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions acceptance/tests/resource/package/ips/basic_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
step "IPS: basic ensure we are clean"
apply_manifest_on(agent, 'package {mypkg : ensure=>absent}')
on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do
assert_no_match( /[email protected]/, result.stdout, "err: #{agent}")
refute_match( /[email protected]/, result.stdout, "err: #{agent}")
end

step "IPS: basic - it should create"
Expand All @@ -47,7 +47,7 @@
step "IPS: do not upgrade until latest is mentioned"
send_pkg agent,:pkg => '[email protected]'
apply_manifest_on(agent, 'package {mypkg : ensure=>present}') do
assert_no_match( /ensure: created/, result.stdout, "err: #{agent}")
refute_match( /ensure: created/, result.stdout, "err: #{agent}")
end

step "IPS: verify it was not upgraded"
Expand All @@ -74,6 +74,6 @@
step "IPS: ensure removed."
apply_manifest_on(agent, 'package {mypkg : ensure=>absent}')
on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do
assert_no_match( /[email protected]/, result.stdout, "err: #{agent}")
refute_match( /[email protected]/, result.stdout, "err: #{agent}")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
setup_fakeroot2 agent
send_pkg2 agent, :pkg => '[email protected]', :pkgdep => '[email protected]'
apply_manifest_on(agent, 'package {mypkg2 : ensure=>"0.0.2"}') do
assert_no_match( /changed/, result.stdout, "err: #{agent}")
refute_match( /changed/, result.stdout, "err: #{agent}")
end
on agent, "pkg list -v mypkg" do
assert_match( /[email protected]/, result.stdout, "err: #{agent}")
Expand Down
12 changes: 6 additions & 6 deletions acceptance/tests/resource/package/ips/should_be_idempotent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

step "IPS: should be idempotent (present)"
apply_manifest_on(agent, 'package {mypkg : ensure=>present}') do
assert_no_match( /created/, result.stdout, "err: #{agent}")
assert_no_match( /changed/, result.stdout, "err: #{agent}")
refute_match( /created/, result.stdout, "err: #{agent}")
refute_match( /changed/, result.stdout, "err: #{agent}")
end
send_pkg agent, :pkg => '[email protected]'

Expand All @@ -42,7 +42,7 @@

step "IPS: ask for latest version again: should be idempotent (latest)"
apply_manifest_on(agent, 'package {mypkg : ensure=>latest}') do
assert_no_match( /created/, result.stdout, "err: #{agent}")
refute_match( /created/, result.stdout, "err: #{agent}")
end

step "IPS: ask for specific version"
Expand All @@ -53,14 +53,14 @@

step "IPS: ask for specific version again: should be idempotent (version)"
apply_manifest_on(agent, 'package {mypkg : ensure=>"0.0.3"}') do
assert_no_match( /created/, result.stdout, "err: #{agent}")
assert_no_match( /changed/, result.stdout, "err: #{agent}")
refute_match( /created/, result.stdout, "err: #{agent}")
refute_match( /changed/, result.stdout, "err: #{agent}")
end

step "IPS: ensure removed."
apply_manifest_on(agent, 'package {mypkg : ensure=>absent}')
on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do
assert_no_match( /mypkg/, result.stdout, "err: #{agent}")
refute_match( /mypkg/, result.stdout, "err: #{agent}")
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
assert_match( /ensure changed/, result.stdout, "err: #{agent}")
end
on agent, "pkg list mypkg" do
assert_no_match( /0.0.1/, result.stdout, "err: #{agent}")
refute_match( /0.0.1/, result.stdout, "err: #{agent}")
assert_match( /0.0.2/, result.stdout, "err: #{agent}")
end
step "IPS: it should downpgrade if asked for previous version"
apply_manifest_on(agent, 'package {mypkg : ensure=>"0.0.1"}') do
assert_match( /ensure changed/, result.stdout, "err: #{agent}")
end
on agent, "pkg list mypkg" do
assert_no_match( /0.0.2/, result.stdout, "err: #{agent}")
refute_match( /0.0.2/, result.stdout, "err: #{agent}")
assert_match( /0.0.1/, result.stdout, "err: #{agent}")
end
end
2 changes: 1 addition & 1 deletion acceptance/tests/resource/package/ips/should_remove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
apply_manifest_on(agent, 'package {mypkg : ensure=>absent}')

on(agent, "pkg list -v mypkg", :acceptable_exit_codes => [1]) do
assert_no_match( /[email protected]/, result.stdout, "err: #{agent}")
refute_match( /[email protected]/, result.stdout, "err: #{agent}")
end

end
12 changes: 6 additions & 6 deletions acceptance/tests/resource/package/yum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def verify_present(hosts, pkg)
end

def verify_absent(hosts, pkg)
verify_state(hosts, pkg, '(?:purged|absent)', :assert_no_match)
verify_state(hosts, pkg, '(?:purged|absent)', :refute_match)
end

step "Managing a package which does not include an epoch in its version" do
Expand Down Expand Up @@ -144,7 +144,7 @@ def verify_absent(hosts, pkg)
end

apply_manifest_on(agent, "package {'epoch': ensure => '1:1.1-1.noarch'}") do |result|
assert_no_match(/epoch/, result.stdout)
refute_match(/epoch/, result.stdout)
end
end

Expand All @@ -162,11 +162,11 @@ def verify_absent(hosts, pkg)
end

apply_manifest_on(agent, 'package {"epoch": ensure => "1:1.1-1"}') do |result|
assert_no_match(/epoch/, result.stdout)
refute_match(/epoch/, result.stdout)
end

apply_manifest_on(agent, "package {'epoch': ensure => '1:1.1-1.noarch'}") do |result|
assert_no_match(/epoch/, result.stdout)
refute_match(/epoch/, result.stdout)
end
end
end
Expand All @@ -185,11 +185,11 @@ def verify_absent(hosts, pkg)
end

apply_manifest_on(agent, 'package {"epoch": ensure => "1.1-1"}') do |result|
assert_no_match(/epoch/, result.stdout)
refute_match(/epoch/, result.stdout)
end

apply_manifest_on(agent, "package {'epoch': ensure => '1:1.1-1.noarch'}") do |result|
assert_no_match(/epoch/, result.stdout)
refute_match(/epoch/, result.stdout)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/service/launchd_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def launchctl_assert_status(host, service, expect_running)
if expect_running
assert_match(/#{service}/, stdout, 'Service was not found in launchctl list')
else
assert_no_match(/#{service}/, stdout, 'Service was not expected in launchctl list')
refute_match(/#{service}/, stdout, 'Service was not expected in launchctl list')
end
end
end
Expand Down
Loading

0 comments on commit 0162588

Please sign in to comment.