diff --git a/acceptance/tests/config/puppet_manages_own_configuration_in_robust_manner.rb b/acceptance/tests/config/puppet_manages_own_configuration_in_robust_manner.rb index 9f56ee449..8b3a91537 100644 --- a/acceptance/tests/config/puppet_manages_own_configuration_in_robust_manner.rb +++ b/acceptance/tests/config/puppet_manages_own_configuration_in_robust_manner.rb @@ -1,71 +1,71 @@ # User story: # A new user has installed puppet either from source or from a gem, which does # not put the "puppet" user or group on the system. They run the puppet master, # which fails because of the missing user and then correct their actions. They # expect that after correcting their actions, puppet will work correctly. test_name "Puppet manages its own configuration in a robust manner" # when owner/group works on windows for settings, this confine should be removed. confine :except, :platform => 'windows' # when managhome roundtrips for solaris, this confine should be removed confine :except, :platform => 'solaris' # pe setup includes ownership of external directories such as the passenger # document root, which puppet itself knows nothing about confine :except, :type => 'pe' step "Clear out yaml directory because of a bug in the indirector/yaml. (See #21145)" on master, 'rm -rf $(puppet master --configprint yamldir)' original_state = {} step "Record original state of system users" do hosts.each do |host| original_state[host] = {} original_state[host][:user] = user = host.execute('puppet config print user') original_state[host][:group] = group = host.execute('puppet config print group') - original_state[host][:ug_resources] = on(host, puppet('resource', 'user', user)).output - original_state[host][:ug_resources] += on(host, puppet('resource', 'group', group)).output + original_state[host][:ug_resources] = on(host, puppet('resource', 'user', user)).stdout + original_state[host][:ug_resources] += on(host, puppet('resource', 'group', group)).stdout original_state[host][:ug_resources] += "Group['#{group}'] -> User['#{user}']\n" end end teardown do # And cleaning up yaml dir again here because we are changing service # user and group ids back to the original uid and gid on master, 'rm -rf $(puppet master --configprint yamldir)' hosts.each do |host| apply_manifest_on(host, <<-ORIG) #{original_state[host][:ug_resources]} ORIG end with_puppet_running_on(master, {}) do agents.each do |agent| on agent, puppet('agent', '-t', '--server', master) end end end step "Remove system users" do hosts.each do |host| on host, puppet('resource', 'user', original_state[host][:user], 'ensure=absent') on host, puppet('resource', 'group', original_state[host][:group], 'ensure=absent') end end step "Ensure master fails to start when missing system user" do on master, puppet('master'), :acceptable_exit_codes => [74] do assert_match(/could not change to group "#{original_state[master][:group]}"/, result.output) assert_match(/Could not change to user #{original_state[master][:user]}/, result.output) end end step "Ensure master starts when making users after having previously failed startup" do with_puppet_running_on(master, :__commandline_args__ => '--debug --trace', :master => { :mkusers => true }) do agents.each do |agent| on agent, puppet('agent', '-t', '--server', master) end end end diff --git a/acceptance/tests/modules/build/build_basic.rb b/acceptance/tests/modules/build/build_basic.rb index 890c89123..dd89e585b 100644 --- a/acceptance/tests/modules/build/build_basic.rb +++ b/acceptance/tests/modules/build/build_basic.rb @@ -1,47 +1,47 @@ begin test_name "puppet module build (basic)" step 'Setup' on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/nginx', ]: ensure => directory; '#{master['distmoduledir']}/nginx/Modulefile': content => 'name "puppetlabs-nginx" version "0.0.1" source "git://github.com/puppetlabs/puppetlabs-nginx.git" author "Puppet Labs" license "Apache Version 2.0" summary "Nginx Module" description "Nginx" project_page "http://github.com/puppetlabs/puppetlabs-ntp" dependency "puppetlabs/stdlib", ">= 1.0.0" '; } PP step "Try to build a module with an absolute path" on master, puppet("module build #{master['distmoduledir']}/nginx") do - assert_output <<-OUTPUT - \e[mNotice: Building #{master['distmoduledir']}/nginx for release\e[0m - Module built: #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz + assert_equal <<-OUTPUT, stdout +\e[mNotice: Building #{master['distmoduledir']}/nginx for release\e[0m +Module built: #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz OUTPUT end on master, "[ -d #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1 ]" on master, "[ -f #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz ]" step "Try to build a module without providing a path" on master, ("cd #{master['distmoduledir']}/nginx && puppet module build") do - assert_output <<-OUTPUT - \e[mNotice: Building #{master['distmoduledir']}/nginx for release\e[0m - Module built: #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz + assert_equal <<-OUTPUT, stdout +\e[mNotice: Building #{master['distmoduledir']}/nginx for release\e[0m +Module built: #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz OUTPUT end on master, "[ -d #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1 ]" on master, "[ -f #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz ]" ensure step "Teardown" apply_manifest_on master, "file { '#{master['distmoduledir']}/nginx': ensure => absent, force => true }" end diff --git a/acceptance/tests/modules/build/build_no_modulefile.rb b/acceptance/tests/modules/build/build_no_modulefile.rb index 638905461..1dad8299d 100644 --- a/acceptance/tests/modules/build/build_no_modulefile.rb +++ b/acceptance/tests/modules/build/build_no_modulefile.rb @@ -1,26 +1,27 @@ begin test_name "puppet module build (bad modulefiles)" step 'Setup' apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/nginx', ]: ensure => directory; '#{master['distmoduledir']}/nginx/Modulefile': ensure => absent; } PP step "Try to build a module with no modulefile" on master, puppet("module build #{master['distmoduledir']}/nginx"), :acceptable_exit_codes => [1] do - assert_equal <<-OUTPUT, stderr -\e[1;31mError: Unable to find module root at #{master['distmoduledir']}/nginx\e[0m -\e[1;31mError: Try 'puppet help module build' for usage\e[0m - OUTPUT + pattern = Regexp.new([ + ".*Error: Unable to find module root at #{master['distmoduledir']}/nginx.*", + ".*Error: Try 'puppet help module build' for usage.*", + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) end on master, "[ ! -d #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1 ]" on master, "[ ! -f #{master['distmoduledir']}/nginx/pkg/puppetlabs-nginx-0.0.1.tar.gz ]" ensure step "Teardown" apply_manifest_on master, "file { '#{master['distmoduledir']}/nginx': ensure => absent, force => true }" end diff --git a/acceptance/tests/modules/changes/invalid_module_install_path.rb b/acceptance/tests/modules/changes/invalid_module_install_path.rb index d6e5e803f..bb8cdb3e3 100644 --- a/acceptance/tests/modules/changes/invalid_module_install_path.rb +++ b/acceptance/tests/modules/changes/invalid_module_install_path.rb @@ -1,14 +1,15 @@ test_name 'puppet module changes (on an invalid module install path)' step 'Setup' stub_forge_on(master) testdir = master.tmpdir('module_changes_with_invalid_path') step 'Run module changes on an invalid module install path' on master, puppet("module changes #{testdir}/nginx"), :acceptable_exit_codes => [1] do - assert_equal <<-STDERR, stderr -\e[1;31mError: Could not find a valid module at "#{testdir}/nginx"\e[0m -\e[1;31mError: Try 'puppet help module changes' for usage\e[0m - STDERR + pattern = Regexp.new([ +%Q{.*Error: Could not find a valid module at "#{testdir}/nginx".*}, +%Q{.*Error: Try 'puppet help module changes' for usage.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) end diff --git a/acceptance/tests/modules/changes/missing_metadata_json.rb b/acceptance/tests/modules/changes/missing_metadata_json.rb index 38dd3fefd..054e62cf0 100644 --- a/acceptance/tests/modules/changes/missing_metadata_json.rb +++ b/acceptance/tests/modules/changes/missing_metadata_json.rb @@ -1,21 +1,22 @@ test_name 'puppet module changes (on a module which is missing metadata.json)' step 'Setup' stub_forge_on(master) testdir = master.tmpdir('module_changes_on_invalid_metadata') apply_manifest_on master, %Q{ file { '#{testdir}/nginx': ensure => directory; '#{testdir}/nginx/Modulefile': ensure => present } } step 'Run module changes on a module witch is missing metadata.json' on( master, puppet("module changes #{testdir}/nginx"), :acceptable_exit_codes => [1] ) do - assert_equal <<-STDERR, stderr -\e[1;31mError: No metadata.json found.\e[0m -\e[1;31mError: Try 'puppet help module changes' for usage\e[0m - STDERR + pattern = Regexp.new([ +%Q{.*Error: No metadata.json found..*}, +%Q{.*Error: Try 'puppet help module changes' for usage.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) end diff --git a/acceptance/tests/modules/changes/module_with_modified_file.rb b/acceptance/tests/modules/changes/module_with_modified_file.rb index 9b0496627..aa0f4889c 100644 --- a/acceptance/tests/modules/changes/module_with_modified_file.rb +++ b/acceptance/tests/modules/changes/module_with_modified_file.rb @@ -1,22 +1,23 @@ test_name 'puppet module changes (on a module with a modified file)' step 'Setup' stub_forge_on(master) testdir = master.tmpdir('module_changes_with_modified_file') on master, puppet("module install pmtacceptance-nginx --modulepath #{testdir}") on master, "echo >> #{testdir}/nginx/README" step 'Run module changes to check a module with a modified file' on( master, puppet("module changes #{testdir}/nginx"), :acceptable_exit_codes => [0] ) do - assert_equal <<-STDERR, stderr -\e[1;31mWarning: 1 files modified\e[0m - STDERR + pattern = Regexp.new([ +%Q{.*Warning: 1 files modified.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) assert_equal <<-OUTPUT, stdout README OUTPUT end diff --git a/acceptance/tests/modules/changes/module_with_removed_file.rb b/acceptance/tests/modules/changes/module_with_removed_file.rb index d5d229eea..33c2391a1 100644 --- a/acceptance/tests/modules/changes/module_with_removed_file.rb +++ b/acceptance/tests/modules/changes/module_with_removed_file.rb @@ -1,23 +1,24 @@ test_name 'puppet module changes (on a module with a removed file)' step 'Setup' stub_forge_on(master) testdir = master.tmpdir('module_changes_with_removed_file') on master, puppet("module install pmtacceptance-nginx --modulepath #{testdir}") on master, "rm -rf #{testdir}/nginx/README" step 'Run module changes to check a module with a removed file' on( master, puppet("module changes #{testdir}/nginx"), :acceptable_exit_codes => [0] ) do - assert_equal <<-STDERR, stderr -\e[1;31mWarning: 1 files modified\e[0m - STDERR + pattern = Regexp.new([ +%Q{.*Warning: 1 files modified.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) assert_equal <<-OUTPUT, stdout README OUTPUT end diff --git a/acceptance/tests/modules/install/with_cycles.rb b/acceptance/tests/modules/install/with_cycles.rb index e1fed1d77..c65af3e4c 100644 --- a/acceptance/tests/modules/install/with_cycles.rb +++ b/acceptance/tests/modules/install/with_cycles.rb @@ -1,38 +1,38 @@ test_name "puppet module install (with cycles)" require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils module_author = "pmtacceptance" module_name = "php" module_dependencies = ["apache"] orig_installed_modules = get_installed_modules_for_hosts hosts teardown do rm_installed_modules_from_hosts orig_installed_modules, (get_installed_modules_for_hosts hosts) end step 'Setup' stub_forge_on(master) # How does this test differ from a with_version test??? step "Install a module with cycles" on master, puppet("module install #{module_author}-#{module_name} --version 0.0.1") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to install into #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Installing -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └─┬ #{module_author}-#{module_name} (\e[0;36mv0.0.1\e[0m) - └── #{module_author}-apache (\e[0;36mv0.0.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to install into #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Installing -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└─┬ #{module_author}-#{module_name} (\e[0;36mv0.0.1\e[0m) + └── #{module_author}-apache (\e[0;36mv0.0.1\e[0m) OUTPUT end # This isn't going to work on master, puppet("module list --modulepath #{master['distmoduledir']}") do |res| - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── #{module_author}-apache (\e[0;36mv0.0.1\e[0m) - └── #{module_author}-#{module_name} (\e[0;36mv0.0.1\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── #{module_author}-apache (\e[0;36mv0.0.1\e[0m) +└── #{module_author}-#{module_name} (\e[0;36mv0.0.1\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/list/with_circular_dependencies.rb b/acceptance/tests/modules/list/with_circular_dependencies.rb index 224b8bf8e..c73bfab2f 100644 --- a/acceptance/tests/modules/list/with_circular_dependencies.rb +++ b/acceptance/tests/modules/list/with_circular_dependencies.rb @@ -1,61 +1,59 @@ test_name "puppet module list (with circular dependencies)" teardown do on master, "rm -rf #{master['distmoduledir']}/appleseed" on master, "rm -rf #{master['sitemoduledir']}/crakorn" end step "Setup" on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/appleseed', '#{master['sitemoduledir']}/crakorn', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['sitemoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/appleseed", "version_requirement": "1.1.0" } ] }'; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; } PP on master, "[ -d #{master['distmoduledir']}/appleseed ]" on master, "[ -d #{master['sitemoduledir']}/crakorn ]" step "List the installed modules" on master, puppet("module list") do - assert_equal '', stderr assert_match /jimmy-crakorn/, stdout, 'Could not find jimmy crakorn' assert_match /jimmy-appleseed/, stdout, 'Could not find jimmy appleseed, but then again... wasnt it johnny appleseed?' end step "List the installed modules as a dependency tree" on master, puppet("module list --tree") do - assert_equal '', stderr assert_match /jimmy-crakorn.*\[#{master['sitemoduledir']}\]/, stdout, 'Could not find jimmy crakorn' assert_match /jimmy-appleseed.*\[#{master['distmoduledir']}\]/, stdout, 'Could not find jimmy appleseed, but then again... wasnt it johnny appleseed?' end diff --git a/acceptance/tests/modules/list/with_installed_modules.rb b/acceptance/tests/modules/list/with_installed_modules.rb index 9aa261ad0..abe27721e 100644 --- a/acceptance/tests/modules/list/with_installed_modules.rb +++ b/acceptance/tests/modules/list/with_installed_modules.rb @@ -1,111 +1,109 @@ test_name "puppet module list (with installed modules)" teardown do on master, "rm -rf #{master['distmoduledir']}/thelock" on master, "rm -rf #{master['distmoduledir']}/appleseed" on master, "rm -rf #{master['distmoduledir']}/crakorn" on master, "rm -rf #{master['sitemoduledir']}/crick" end step "Setup" on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/crakorn', '#{master['distmoduledir']}/appleseed', '#{master['distmoduledir']}/thelock', '#{master['sitemoduledir']}/crick', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; '#{master['distmoduledir']}/thelock/metadata.json': content => '{ "name": "jimmy/thelock", "version": "1.0.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/appleseed", "version_requirement": "1.x" } ] }'; '#{master['sitemoduledir']}/crick/metadata.json': content => '{ "name": "jimmy/crick", "version": "1.0.1", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.x" } ] }'; } PP on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" on master, "[ -d #{master['distmoduledir']}/thelock ]" on master, "[ -d #{master['sitemoduledir']}/crick ]" step "List the installed modules" on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout #{master['distmoduledir']} ├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m) ├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m) └── jimmy-thelock (\e[0;36mv1.0.0\e[0m) STDOUT end on master, puppet("module list --modulepath #{master['sitemoduledir']}") do |res| assert_match( /jimmy-crick/, res.stdout, 'Did not find module jimmy-crick in module site path') end step "List the installed modules as a dependency tree" on master, puppet("module list --tree --modulepath #{master['distmoduledir']}") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout #{master['distmoduledir']} └─┬ jimmy-thelock (\e[0;36mv1.0.0\e[0m) └─┬ jimmy-appleseed (\e[0;36mv1.1.0\e[0m) └── jimmy-crakorn (\e[0;36mv0.4.0\e[0m) STDOUT end on master, puppet("module list --tree --modulepath #{master['sitemoduledir']}") do |res| assert_match( /jimmy-crakorn/, res.stdout, 'Did not find module jimmy-crakorn in module site path') assert_match( /jimmy-crick/, res.stdout, 'Did not find module jimmy-crick in module site path') end diff --git a/acceptance/tests/modules/list/with_invalid_dependencies.rb b/acceptance/tests/modules/list/with_invalid_dependencies.rb index 22f1defd0..089b8590c 100644 --- a/acceptance/tests/modules/list/with_invalid_dependencies.rb +++ b/acceptance/tests/modules/list/with_invalid_dependencies.rb @@ -1,94 +1,96 @@ test_name "puppet module list (with invalid dependencies)" teardown do on master, "rm -rf #{master['distmoduledir']}/thelock" on master, "rm -rf #{master['distmoduledir']}/appleseed" on master, "rm -rf #{master['distmoduledir']}/crakorn" on master, "rm -rf #{master['sitemoduledir']}/crick" end step "Setup" on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/appleseed', '#{master['distmoduledir']}/crakorn', '#{master['distmoduledir']}/thelock', '#{master['sitemoduledir']}/crick', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.3.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.x" } ] }'; '#{master['distmoduledir']}/thelock/metadata.json': content => '{ "name": "jimmy/thelock", "version": "1.0.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/appleseed", "version_requirement": "1.x" } ] }'; '#{master['sitemoduledir']}/crick/metadata.json': content => '{ "name": "jimmy/crick", "version": "1.0.1", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.x" } ] }'; } PP on master, "[ -d #{master['distmoduledir']}/appleseed ]" on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/thelock ]" on master, "[ -d #{master['sitemoduledir']}/crick ]" step "List the installed modules" on master, puppet("module list") do |res| - assert_equal <<-STDERR, res.stderr -\e[1;31mWarning: Module 'jimmy-crakorn' (v0.3.0) fails to meet some dependencies: - 'jimmy-crick' (v1.0.1) requires 'jimmy-crakorn' (v0.4.x)\e[0m -STDERR + pattern = Regexp.new([ + %Q{.*Warning: Module 'jimmy-crakorn' \\(v0.3.0\\) fails to meet some dependencies:}, + %Q{ 'jimmy-crick' \\(v1.0.1\\) requires 'jimmy-crakorn' \\(v0.4.x\\).*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) assert_match /jimmy-crakorn.*invalid/, res.stdout, 'Did not find module jimmy-crick in module site path' end step "List the installed modules as a dependency tree" on master, puppet("module list --tree") do |res| - assert_equal <<-STDERR, res.stderr -\e[1;31mWarning: Module 'jimmy-crakorn' (v0.3.0) fails to meet some dependencies: - 'jimmy-crick' (v1.0.1) requires 'jimmy-crakorn' (v0.4.x)\e[0m -STDERR + pattern = Regexp.new([ + %Q{.*Warning: Module 'jimmy-crakorn' \\(v0.3.0\\) fails to meet some dependencies:}, + %Q{ 'jimmy-crick' \\(v1.0.1\\) requires 'jimmy-crakorn' \\(v0.4.x\\).*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) assert_match /jimmy-crakorn.*\[#{master['distmoduledir']}\].*invalid/, res.stdout end diff --git a/acceptance/tests/modules/list/with_missing_dependencies.rb b/acceptance/tests/modules/list/with_missing_dependencies.rb index 7f92b24d4..ce1b6cd13 100644 --- a/acceptance/tests/modules/list/with_missing_dependencies.rb +++ b/acceptance/tests/modules/list/with_missing_dependencies.rb @@ -1,89 +1,91 @@ test_name "puppet module list (with missing dependencies)" teardown do on master, "rm -rf #{master['distmoduledir']}/thelock" on master, "rm -rf #{master['distmoduledir']}/appleseed" on master, "rm -rf #{master['sitemoduledir']}/crick" end step "Setup" on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/appleseed', '#{master['distmoduledir']}/thelock', '#{master['sitemoduledir']}/crick', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; '#{master['distmoduledir']}/thelock/metadata.json': content => '{ "name": "jimmy/thelock", "version": "1.0.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/appleseed", "version_requirement": "1.x" }, { "name": "jimmy/sprinkles", "version_requirement": "2.x" } ] }'; '#{master['sitemoduledir']}/crick/metadata.json': content => '{ "name": "jimmy/crick", "version": "1.0.1", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.x" } ] }'; } PP on master, "[ -d #{master['distmoduledir']}/appleseed ]" on master, "[ -d #{master['distmoduledir']}/thelock ]" on master, "[ -d #{master['sitemoduledir']}/crick ]" step "List the installed modules" on master, puppet('module list') do - assert_equal <<-STDERR, stderr -\e[1;31mWarning: Missing dependency 'jimmy-crakorn': - 'jimmy-appleseed' (v1.1.0) requires 'jimmy-crakorn' (v0.4.0) - 'jimmy-crick' (v1.0.1) requires 'jimmy-crakorn' (v0.4.x)\e[0m -\e[1;31mWarning: Missing dependency 'jimmy-sprinkles': - 'jimmy-thelock' (v1.0.0) requires 'jimmy-sprinkles' (v2.x)\e[0m -STDERR + pattern = Regexp.new([ + %Q{.*Warning: Missing dependency 'jimmy-crakorn':}, + %Q{ 'jimmy-appleseed' \\(v1.1.0\\) requires 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ 'jimmy-crick' \\(v1.0.1\\) requires 'jimmy-crakorn' \\(v0.4.x\\).*}, + %Q{.*Warning: Missing dependency 'jimmy-sprinkles':}, + %Q{ 'jimmy-thelock' \\(v1.0.0\\) requires 'jimmy-sprinkles' \\(v2.x\\).*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) end step "List the installed modules as a dependency tree" on master, puppet('module list --tree') do - assert_equal <<-STDERR, stderr -\e[1;31mWarning: Missing dependency 'jimmy-crakorn': - 'jimmy-appleseed' (v1.1.0) requires 'jimmy-crakorn' (v0.4.0) - 'jimmy-crick' (v1.0.1) requires 'jimmy-crakorn' (v0.4.x)\e[0m -\e[1;31mWarning: Missing dependency 'jimmy-sprinkles': - 'jimmy-thelock' (v1.0.0) requires 'jimmy-sprinkles' (v2.x)\e[0m -STDERR + pattern = Regexp.new([ + %Q{.*Warning: Missing dependency 'jimmy-crakorn':}, + %Q{ 'jimmy-appleseed' \\(v1.1.0\\) requires 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ 'jimmy-crick' \\(v1.0.1\\) requires 'jimmy-crakorn' \\(v0.4.x\\).*}, + %Q{.*Warning: Missing dependency 'jimmy-sprinkles':}, + %Q{ 'jimmy-thelock' \\(v1.0.0\\) requires 'jimmy-sprinkles' \\(v2.x\\).*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.stderr) assert_match /UNMET DEPENDENCY.*jimmy-sprinkles/, stdout, 'Did not find unmeet dependency for jimmy-sprinkles warning' assert_match /UNMET DEPENDENCY.*jimmy-crakorn/, stdout, 'Did not find unmeet dependency for jimmy-crakorn warning' end diff --git a/acceptance/tests/modules/list/with_modulepath.rb b/acceptance/tests/modules/list/with_modulepath.rb index 58a81ef48..adaeb7ddb 100644 --- a/acceptance/tests/modules/list/with_modulepath.rb +++ b/acceptance/tests/modules/list/with_modulepath.rb @@ -1,77 +1,75 @@ test_name "puppet module list (with modulepath)" step "Setup" apply_manifest_on master, <<-PP file { [ '#{master['puppetpath']}/modules2', '#{master['puppetpath']}/modules2/crakorn', '#{master['puppetpath']}/modules2/appleseed', '#{master['puppetpath']}/modules2/thelock', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['puppetpath']}/modules2/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['puppetpath']}/modules2/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; '#{master['puppetpath']}/modules2/thelock/metadata.json': content => '{ "name": "jimmy/thelock", "version": "1.0.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/appleseed", "version_requirement": "1.x" } ] }'; } PP teardown do on master, "rm -rf #{master['puppetpath']}/modules2" end on master, "[ -d #{master['puppetpath']}/modules2/crakorn ]" on master, "[ -d #{master['puppetpath']}/modules2/appleseed ]" on master, "[ -d #{master['puppetpath']}/modules2/thelock ]" step "List the installed modules with relative modulepath" on master, "cd #{master['puppetpath']}/modules2 && puppet module list --modulepath=." do - assert_equal '', stderr assert_equal <<-STDOUT, stdout #{master['puppetpath']}/modules2 ├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m) ├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m) └── jimmy-thelock (\e[0;36mv1.0.0\e[0m) STDOUT end step "List the installed modules with absolute modulepath" on master, puppet("module list --modulepath=#{master['puppetpath']}/modules2") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout #{master['puppetpath']}/modules2 ├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m) ├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m) └── jimmy-thelock (\e[0;36mv1.0.0\e[0m) STDOUT end diff --git a/acceptance/tests/modules/list/with_repeated_dependencies.rb b/acceptance/tests/modules/list/with_repeated_dependencies.rb index 6cb1f0d1d..7cab94441 100644 --- a/acceptance/tests/modules/list/with_repeated_dependencies.rb +++ b/acceptance/tests/modules/list/with_repeated_dependencies.rb @@ -1,116 +1,112 @@ test_name "puppet module list (with repeated dependencies)" teardown do on master, "rm -rf #{master['distmoduledir']}/crakorn" on master, "rm -rf #{master['distmoduledir']}/steward" on master, "rm -rf #{master['distmoduledir']}/appleseed" on master, "rm -rf #{master['distmoduledir']}/thelock" on master, "rm -rf #{master['sitemoduledir']}/crick" end step "Setup" on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/crakorn', '#{master['distmoduledir']}/steward', '#{master['distmoduledir']}/appleseed', '#{master['distmoduledir']}/thelock', '#{master['sitemoduledir']}/crick', ]: ensure => directory, recurse => true, purge => true, force => true; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/steward", "version_requirement": ">= 0.0.0" } ] }'; '#{master['distmoduledir']}/steward/metadata.json': content => '{ "name": "jimmy/steward", "version": "0.9.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; '#{master['distmoduledir']}/thelock/metadata.json': content => '{ "name": "jimmy/thelock", "version": "1.0.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": ">= 0.0.0" }, { "name": "jimmy/appleseed", "version_requirement": "1.x" } ] }'; '#{master['sitemoduledir']}/crick/metadata.json': content => '{ "name": "jimmy/crick", "version": "1.0.1", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.x" } ] }'; } PP on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/steward ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" on master, "[ -d #{master['distmoduledir']}/thelock ]" on master, "[ -d #{master['sitemoduledir']}/crick ]" step "List the installed modules" -on master, puppet('module list') do - assert_equal '', stderr -end +on master, puppet('module list') # assertion is exit code 0 step "List the installed modules as a dependency tree" on master, puppet("module list --tree --modulepath #{master['distmoduledir']}") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout #{master['distmoduledir']} └─┬ jimmy-thelock (\e[0;36mv1.0.0\e[0m) ├─┬ jimmy-crakorn (\e[0;36mv0.4.0\e[0m) │ └── jimmy-steward (\e[0;36mv0.9.0\e[0m) └── jimmy-appleseed (\e[0;36mv1.1.0\e[0m) STDOUT end on master, puppet("module list --tree") do - assert_equal '', stderr assert_match( /jimmy-crakorn.*\[#{master['distmoduledir']}\]/, stdout, 'Did not find cross modulepath reference to jimmy-crakorn' ) assert_match( /jimmy-steward.*\[#{master['distmoduledir']}\]/, stdout, 'Did not find cross modulepath reference to jimmy-steward' ) end diff --git a/acceptance/tests/modules/search/by_description.rb b/acceptance/tests/modules/search/by_description.rb deleted file mode 100644 index 4088364cb..000000000 --- a/acceptance/tests/modules/search/by_description.rb +++ /dev/null @@ -1,23 +0,0 @@ -test_name 'puppet module search should do substring matches on description' - -step 'Setup' -stub_forge_on(master) - -step 'Search for a module by description' -on master, puppet("module search dummy") do - assert_equal '', stderr - # FIXME: The Forge does not presently match against description. -# assert_equal <<-STDOUT, stdout -# \e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m -# NAME DESCRIPTION AUTHOR KEYWORDS -# pmtacceptance-nginx This is a dummy nginx mo... @pmtacceptance nginx -# pmtacceptance-thin This is a dummy thin mod... @pmtacceptance ruby thin -# pmtacceptance-apollo This is a dummy apollo m... @pmtacceptance stomp apollo -# pmtacceptance-java This is a dummy java mod... @pmtacceptance java -# pmtacceptance-stdlib This is a dummy stdlib m... @pmtacceptance stdlib libs -# pmtacceptance-git This is a dummy git modu... @pmtacceptance git dvcs -# pmtacceptance-apache This is a dummy apache m... @pmtacceptance apache php -# pmtacceptance-php This is a dummy php modu... @pmtacceptance apache php -# pmtacceptance-geordi This is a module that do... @pmtacceptance star trek -# STDOUT -end diff --git a/acceptance/tests/modules/search/by_keyword.rb b/acceptance/tests/modules/search/by_keyword.rb index c34abc049..6755eaf64 100644 --- a/acceptance/tests/modules/search/by_keyword.rb +++ b/acceptance/tests/modules/search/by_keyword.rb @@ -1,25 +1,24 @@ test_name 'puppet module search should do exact keyword matches' step 'Setup' stub_forge_on(master) step 'Search for a module by exact keyword' on master, puppet("module search github") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout \e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m NAME DESCRIPTION AUTHOR KEYWORDS pmtacceptance-git UNKNOWN @pmtacceptance git \e[0;32mgithub\e[0m STDOUT end # FIXME: The Forge presently matches partial keywords. # step 'Search for a module by partial keyword' # on master, puppet("module search hub") do # assert_equal '', stderr # assert_equal <<-STDOUT, stdout # \e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m # No results found for 'hub'. # STDOUT # end diff --git a/acceptance/tests/modules/search/by_module_name.rb b/acceptance/tests/modules/search/by_module_name.rb index b7de93e9e..24d609813 100644 --- a/acceptance/tests/modules/search/by_module_name.rb +++ b/acceptance/tests/modules/search/by_module_name.rb @@ -1,27 +1,26 @@ test_name 'Searching for modules by part of the name' module_name = "pmtacceptance-geordi" expected_output = <<-STDOUT \e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m NAME DESCRIPTION AUTHOR KEYWORDS %s UNKNOWN @pmtacceptance star trek STDOUT step 'Setup' stub_forge_on(master) search_types = { 'Search for modules by partial name' => "geordi", 'Search for modules by partial full name (dashed)' => "tance-ge", 'Search for modules by partial full name (slashed)' => "tance/ge", } search_types.each do |type, search_string| step type on master, puppet("module search #{search_string}") do search_string = search_string.gsub(/\//, "-") em_module_name = module_name.gsub(/#{search_string}/, "\e[0;32m#{search_string}\e[0m") - assert_equal '', stderr assert_equal expected_output % [em_module_name], stdout end end diff --git a/acceptance/tests/modules/search/formatting.rb b/acceptance/tests/modules/search/formatting.rb index 22f1c6262..6c0ac3fd1 100644 --- a/acceptance/tests/modules/search/formatting.rb +++ b/acceptance/tests/modules/search/formatting.rb @@ -1,17 +1,16 @@ test_name 'puppet module search output should be well structured' step 'Setup' stub_forge_on(master) step 'Search results should line up by column' on master, puppet("module search apache") do - assert_equal('', stderr) assert_equal "\e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m\n", stdout.lines.first columns = stdout.lines.to_a[1].split(/\s{2}(?=\S)/) pattern = /^#{ columns.map { |c| c.chomp.gsub(/./, '.') }.join(' ') }$/ stdout.gsub(/\e.*?m/, '').lines.to_a[1..-1].each do |line| assert_match(pattern, line.chomp, 'columns were misaligned') end end diff --git a/acceptance/tests/modules/search/no_results.rb b/acceptance/tests/modules/search/no_results.rb index 10a45bed9..2a11c8fef 100644 --- a/acceptance/tests/modules/search/no_results.rb +++ b/acceptance/tests/modules/search/no_results.rb @@ -1,13 +1,12 @@ test_name 'puppet module search should print a reasonable message for no results' step 'Setup' stub_forge_on(master) step "Search for a module that doesn't exist" on master, puppet("module search module_not_appearing_in_this_forge") do - assert_equal '', stderr assert_equal <<-STDOUT, stdout \e[mNotice: Searching https://forge.puppetlabs.com ...\e[0m No results found for 'module_not_appearing_in_this_forge'. STDOUT end diff --git a/acceptance/tests/modules/uninstall/using_directory_name.rb b/acceptance/tests/modules/uninstall/using_directory_name.rb index 3d7a54ed4..505e6e166 100644 --- a/acceptance/tests/modules/uninstall/using_directory_name.rb +++ b/acceptance/tests/modules/uninstall/using_directory_name.rb @@ -1,48 +1,49 @@ test_name "puppet module uninstall (using directory name)" teardown do on master, "rm -rf #{master['distmoduledir']}/apache" on master, "rm -rf #{master['distmoduledir']}/crakorn" end step "Setup" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/apache', '#{master['distmoduledir']}/crakorn', ]: ensure => directory; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; } PP on master, "[ -d #{master['distmoduledir']}/apache ]" on master, "[ -d #{master['distmoduledir']}/crakorn ]" step "Try to uninstall the module apache" on master, puppet('module uninstall apache') do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'apache' ...\e[0m - Removed 'apache' from #{master['distmoduledir']} + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'apache' ...\e[0m +Removed 'apache' from #{master['distmoduledir']} OUTPUT end on master, "[ ! -d #{master['distmoduledir']}/apache ]" step "Try to uninstall the module crakorn" on master, puppet('module uninstall crakorn'), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to uninstall 'crakorn' ...\e[0m - STDERR> \e[1;31mError: Could not uninstall module 'crakorn' - STDERR> Module 'crakorn' is not installed - STDERR> You may have meant `puppet module uninstall jimmy-crakorn`\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to uninstall 'crakorn' ....*}, + %Q{.*Error: Could not uninstall module 'crakorn'}, + %Q{ Module 'crakorn' is not installed}, + %Q{ You may have meant `puppet module uninstall jimmy-crakorn`.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end on master, "[ -d #{master['distmoduledir']}/crakorn ]" diff --git a/acceptance/tests/modules/uninstall/with_active_dependency.rb b/acceptance/tests/modules/uninstall/with_active_dependency.rb index d6ffb46fb..f4fc185af 100644 --- a/acceptance/tests/modules/uninstall/with_active_dependency.rb +++ b/acceptance/tests/modules/uninstall/with_active_dependency.rb @@ -1,75 +1,77 @@ test_name "puppet module uninstall (with active dependency)" step "Setup" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/crakorn', '#{master['distmoduledir']}/appleseed', ]: ensure => directory; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['distmoduledir']}/appleseed/metadata.json': content => '{ "name": "jimmy/appleseed", "version": "1.1.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [ { "name": "jimmy/crakorn", "version_requirement": "0.4.0" } ] }'; } PP teardown do on master, "rm -rf #{master['distmoduledir']}/crakorn" on master, "rm -rf #{master['distmoduledir']}/appleseed" end on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" step "Try to uninstall the module jimmy-crakorn" on master, puppet('module uninstall jimmy-crakorn'), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m - STDERR> \e[1;31mError: Could not uninstall module 'jimmy-crakorn' - STDERR> Other installed modules have dependencies on 'jimmy-crakorn' (v0.4.0) - STDERR> 'jimmy/appleseed' (v1.1.0) requires 'jimmy-crakorn' (v0.4.0) - STDERR> Use `puppet module uninstall --force` to uninstall this module anyway\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to uninstall 'jimmy-crakorn' .*}, + %Q{.*Error: Could not uninstall module 'jimmy-crakorn'}, + %Q{ Other installed modules have dependencies on 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ 'jimmy/appleseed' \\(v1.1.0\\) requires 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ Use `puppet module uninstall --force` to uninstall this module anyway.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" step "Try to uninstall the module jimmy-crakorn with a version range" on master, puppet('module uninstall jimmy-crakorn --version 0.x'), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to uninstall 'jimmy-crakorn' (\e[0;36mv0.x\e[m) ...\e[0m - STDERR> \e[1;31mError: Could not uninstall module 'jimmy-crakorn' (v0.x) - STDERR> Other installed modules have dependencies on 'jimmy-crakorn' (v0.4.0) - STDERR> 'jimmy/appleseed' (v1.1.0) requires 'jimmy-crakorn' (v0.4.0) - STDERR> Use `puppet module uninstall --force` to uninstall this module anyway\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to uninstall 'jimmy-crakorn' \\(.*v0.x.*\\) .*}, + %Q{.*Error: Could not uninstall module 'jimmy-crakorn' \\(v0.x\\)}, + %Q{ Other installed modules have dependencies on 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ 'jimmy/appleseed' \\(v1.1.0\\) requires 'jimmy-crakorn' \\(v0.4.0\\)}, + %Q{ Use `puppet module uninstall --force` to uninstall this module anyway.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end on master, "[ -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" step "Uninstall the module jimmy-crakorn forcefully" on master, puppet('module uninstall jimmy-crakorn --force') do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m - Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['distmoduledir']} + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m +Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['distmoduledir']} OUTPUT end on master, "[ ! -d #{master['distmoduledir']}/crakorn ]" on master, "[ -d #{master['distmoduledir']}/appleseed ]" diff --git a/acceptance/tests/modules/uninstall/with_environment.rb b/acceptance/tests/modules/uninstall/with_environment.rb index ac35dadcd..6fb0b6833 100644 --- a/acceptance/tests/modules/uninstall/with_environment.rb +++ b/acceptance/tests/modules/uninstall/with_environment.rb @@ -1,58 +1,58 @@ test_name 'puppet module uninstall (with environment)' require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils step 'Setup' stub_forge_on(master) puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath']) crakorn_metadata = <<-EOS { "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] } EOS # Configure a non-default environment apply_manifest_on master, %Q{ file { [ '#{master['puppetpath']}/legacyenv/modules/crakorn', '#{master['puppetpath']}/environments/direnv/modules', '#{master['puppetpath']}/environments/direnv/modules/crakorn', ]: ensure => directory, } file { '#{master['puppetpath']}/legacyenv/modules/crakorn/metadata.json': content => '#{crakorn_metadata}', } file { '#{master['puppetpath']}/environments/direnv/modules/crakorn/metadata.json': content => '#{crakorn_metadata}', } } check_module_uninstall_in = lambda do |environment, environment_path| on master, "puppet module uninstall jimmy-crakorn --config=#{puppet_conf} --environment=#{environment}" do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m - Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{environment_path} + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m +Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{environment_path} OUTPUT end on master, "[ ! -d #{environment_path}/crakorn ]" end step 'Uninstall a module from a non default legacy environment' do check_module_uninstall_in.call('legacyenv', "#{master['puppetpath']}/legacyenv/modules") end step 'Uninstall a module from a non default directory environment' do check_module_uninstall_in.call('direnv', "#{master['puppetpath']}/environments/direnv/modules") end diff --git a/acceptance/tests/modules/uninstall/with_module_installed.rb b/acceptance/tests/modules/uninstall/with_module_installed.rb index 2f160f105..c81bc9ece 100644 --- a/acceptance/tests/modules/uninstall/with_module_installed.rb +++ b/acceptance/tests/modules/uninstall/with_module_installed.rb @@ -1,34 +1,34 @@ test_name "puppet module uninstall (with module installed)" teardown do on master, "rm -rf #{master['distmoduledir']}/crakorn" end step "Setup" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/crakorn', ]: ensure => directory; '#{master['distmoduledir']}/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; } PP on master, "[ -d #{master['distmoduledir']}/crakorn ]" step "Uninstall the module jimmy-crakorn" on master, puppet('module uninstall jimmy-crakorn') do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m - Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['distmoduledir']} + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m +Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['distmoduledir']} OUTPUT end on master, "[ ! -d #{master['distmoduledir']}/crakorn ]" diff --git a/acceptance/tests/modules/uninstall/with_modulepath.rb b/acceptance/tests/modules/uninstall/with_modulepath.rb index f5a39b40d..7915f0c6d 100644 --- a/acceptance/tests/modules/uninstall/with_modulepath.rb +++ b/acceptance/tests/modules/uninstall/with_modulepath.rb @@ -1,56 +1,56 @@ test_name "puppet module uninstall (with modulepath)" teardown do on master, "rm -rf #{master['puppetpath']}/modules2" end step "Setup" apply_manifest_on master, <<-PP file { [ '#{master['puppetpath']}/modules2', '#{master['puppetpath']}/modules2/crakorn', '#{master['puppetpath']}/modules2/absolute', ]: ensure => directory; '#{master['puppetpath']}/modules2/crakorn/metadata.json': content => '{ "name": "jimmy/crakorn", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; '#{master['puppetpath']}/modules2/absolute/metadata.json': content => '{ "name": "jimmy/absolute", "version": "0.4.0", "source": "", "author": "jimmy", "license": "MIT", "dependencies": [] }'; } PP on master, "[ -d #{master['puppetpath']}/modules2/crakorn ]" on master, "[ -d #{master['puppetpath']}/modules2/absolute ]" step "Try to uninstall the module jimmy-crakorn using relative modulepath" on master, "cd #{master['puppetpath']}/modules2 && puppet module uninstall jimmy-crakorn --modulepath=." do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m - Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['puppetpath']}/modules2 + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'jimmy-crakorn' ...\e[0m +Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{master['puppetpath']}/modules2 OUTPUT end on master, "[ ! -d #{master['puppetpath']}/modules2/crakorn ]" step "Try to uninstall the module jimmy-absolute using an absolute modulepath" on master, "cd #{master['puppetpath']}/modules2 && puppet module uninstall jimmy-absolute --modulepath=#{master['puppetpath']}/modules2" do - assert_output <<-OUTPUT - \e[mNotice: Preparing to uninstall 'jimmy-absolute' ...\e[0m - Removed 'jimmy-absolute' (\e[0;36mv0.4.0\e[0m) from #{master['puppetpath']}/modules2 + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to uninstall 'jimmy-absolute' ...\e[0m +Removed 'jimmy-absolute' (\e[0;36mv0.4.0\e[0m) from #{master['puppetpath']}/modules2 OUTPUT end on master, "[ ! -d #{master['puppetpath']}/modules2/absolute ]" diff --git a/acceptance/tests/modules/uninstall/with_multiple_modules_installed.rb b/acceptance/tests/modules/uninstall/with_multiple_modules_installed.rb index 90b092ede..4e1e3072d 100644 --- a/acceptance/tests/modules/uninstall/with_multiple_modules_installed.rb +++ b/acceptance/tests/modules/uninstall/with_multiple_modules_installed.rb @@ -1,64 +1,64 @@ test_name "puppet module uninstall (with multiple modules installed)" step 'Setup' testdir = master.tmpdir('unistallmultiple') stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, "mkdir -p #{testdir}/modules" on master, "chown -R #{master['user']}:#{master['group']} #{testdir}" master_opts = { 'main' => { 'modulepath' => "#{testdir}/modules:#{master['sitemoduledir']}:#{master['distmoduledir']}" } } with_puppet_running_on master, master_opts, testdir do on master, puppet("module install pmtacceptance-java --version 1.6.0 --modulepath #{master['distmoduledir']}") on master, puppet("module install pmtacceptance-java --version 1.7.0 --modulepath #{testdir}/modules") on master, puppet("module list --modulepath #{master['distmoduledir']}") do pattern = Regexp.new([ "#{master['distmoduledir']}", "├── pmtacceptance-java \\(.*v1.6.0.*\\)", "└── pmtacceptance-stdlib \\(.*v1.0.0.*\\)" ].join("\n")) assert_match(pattern, result.output) end on master, puppet("module list --modulepath #{testdir}/modules") do pattern = Regexp.new([ "#{testdir}/modules", "├── pmtacceptance-java \\(.*v1.7.0.*\\)", "└── pmtacceptance-stdlib \\(.*v1.0.0.*\\)", ].join("\n")) assert_match(pattern, result.output) end step "Try to uninstall a module that exists multiple locations in the module path" on master, puppet("module uninstall pmtacceptance-java"), :acceptable_exit_codes => [1] do pattern = Regexp.new([ ".*Notice: Preparing to uninstall 'pmtacceptance-java' .*", ".*Error: Could not uninstall module 'pmtacceptance-java'", " Module 'pmtacceptance-java' appears multiple places in the module path", " 'pmtacceptance-java' \\(v1.7.0\\) was found in #{testdir}/modules", " 'pmtacceptance-java' \\(v1.6.0\\) was found in #{master['distmoduledir']}", " Use the `--modulepath` option to limit the search to specific directories.*" - ].join("\n")) + ].join("\n"), Regexp::MULTILINE) assert_match(pattern, result.output) end step "Uninstall a module that exists multiple locations by restricting the --modulepath" on master, puppet("module uninstall pmtacceptance-java --modulepath #{master['distmoduledir']}") do pattern = Regexp.new([ ".*Notice: Preparing to uninstall 'pmtacceptance-java' .*", "Removed 'pmtacceptance-java' \\(.*v1.6.0.*\\) from #{master['distmoduledir']}" - ].join("\n")) + ].join("\n"), Regexp::MULTILINE) assert_match(pattern, result.output) end end diff --git a/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb b/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb index 1b18a4fcb..8f2d33b82 100644 --- a/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb +++ b/acceptance/tests/modules/upgrade/in_a_secondary_directory.rb @@ -1,32 +1,32 @@ test_name "puppet module upgrade (in a secondary directory)" step 'Setup' stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, "mkdir -p #{master['distmoduledir']}" on master, puppet("module install pmtacceptance-java --version 1.6.0 --target-dir #{master['distmoduledir']}") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-java") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb b/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb index 19a4b7456..c8deaea2b 100644 --- a/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb +++ b/acceptance/tests/modules/upgrade/introducing_new_dependencies.rb @@ -1,37 +1,37 @@ test_name "puppet module upgrade (introducing new dependencies)" step 'Setup' stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/postgresql" on master, "rm -rf #{master['distmoduledir']}/stdlib" on master, "rm -rf #{master['distmoduledir']}/geordi" end on master, puppet("module install pmtacceptance-stdlib --version 1.0.0") on master, puppet("module install pmtacceptance-java --version 1.7.0") on master, puppet("module install pmtacceptance-postgresql --version 0.0.2") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) - ├── pmtacceptance-postgresql (\e[0;36mv0.0.2\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) +├── pmtacceptance-postgresql (\e[0;36mv0.0.2\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Upgrade a module to a version that introduces new dependencies" on master, puppet("module upgrade pmtacceptance-postgresql") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-postgresql' ...\e[0m - \e[mNotice: Found 'pmtacceptance-postgresql' (\e[0;36mv0.0.2\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └─┬ pmtacceptance-postgresql (\e[0;36mv0.0.2 -> v1.0.0\e[0m) - └── pmtacceptance-geordi (\e[0;36mv0.0.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-postgresql' ...\e[0m +\e[mNotice: Found 'pmtacceptance-postgresql' (\e[0;36mv0.0.2\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└─┬ pmtacceptance-postgresql (\e[0;36mv0.0.2 -> v1.0.0\e[0m) + └── pmtacceptance-geordi (\e[0;36mv0.0.1\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/upgrade/not_upgradable.rb b/acceptance/tests/modules/upgrade/not_upgradable.rb index 133c48afc..575b3cf24 100644 --- a/acceptance/tests/modules/upgrade/not_upgradable.rb +++ b/acceptance/tests/modules/upgrade/not_upgradable.rb @@ -1,85 +1,89 @@ test_name "puppet module upgrade (not upgradable)" step 'Setup' stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/unicorns" on master, "rm -rf #{master['distmoduledir']}/stdlib" on master, "rm -rf #{master['distmoduledir']}/nginx" end on master, "mkdir -p #{master['distmoduledir']}" apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/nginx', '#{master['distmoduledir']}/unicorns', ]: ensure => directory; '#{master['distmoduledir']}/unicorns/metadata.json': content => '{ "name": "notpmtacceptance/unicorns", "version": "0.0.3", "source": "", "author": "notpmtacceptance", "license": "MIT", "dependencies": [] }'; } PP on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── nginx (\e[0;36m???\e[0m) - ├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── nginx (\e[0;36m???\e[0m) +├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Try to upgrade a module that is not installed" on master, puppet("module upgrade pmtacceptance-nginx"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-nginx' ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-nginx' - STDERR> Module 'pmtacceptance-nginx' is not installed - STDERR> Use `puppet module install` to install this module\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-nginx' .*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-nginx'}, + %Q{ Module 'pmtacceptance-nginx' is not installed}, + %Q{ Use `puppet module install` to install this module.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Try to upgrade a local module" on master, puppet("module upgrade nginx"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'nginx' ...\e[0m - STDOUT> \e[mNotice: Found 'nginx' (\e[0;36m???\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'nginx' (??? -> latest) - STDERR> Module 'nginx' does not exist on https://forge.puppetlabs.com\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'nginx' .*}, + %Q{.*Notice: Found 'nginx' \\(.*\\?\\?\\?.*\\) in #{master['distmoduledir']} .*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com .*}, + %Q{.*Error: Could not upgrade module 'nginx' \\(\\?\\?\\? -> latest\\)}, + %Q{ Module 'nginx' does not exist on https://forge.puppetlabs.com.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Try to upgrade a module that doesn't exist" on master, puppet("module upgrade notpmtacceptance-unicorns"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'notpmtacceptance-unicorns' ...\e[0m - STDOUT> \e[mNotice: Found 'notpmtacceptance-unicorns' (\e[0;36mv0.0.3\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'notpmtacceptance-unicorns' (v0.0.3 -> latest) - STDERR> Module 'notpmtacceptance-unicorns' does not exist on https://forge.puppetlabs.com\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'notpmtacceptance-unicorns' .*}, + %Q{.*Notice: Found 'notpmtacceptance-unicorns' \\(.*v0.0.3.*\\) in #{master['distmoduledir']} .*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com .*}, + %Q{.*Error: Could not upgrade module 'notpmtacceptance-unicorns' \\(v0.0.3 -> latest\\)}, + %Q{ Module 'notpmtacceptance-unicorns' does not exist on https://forge.puppetlabs.com.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Try to upgrade an installed module to a version that doesn't exist" on master, puppet("module upgrade pmtacceptance-java --version 2.0.0"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> v2.0.0) - STDERR> No version matching '2.0.0' exists on https://forge.puppetlabs.com\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-java' .*}, + %Q{.*Notice: Found 'pmtacceptance-java' \\(.*v1.6.0.*\\) in #{master['distmoduledir']} .*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com .*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-java' \\(v1.6.0 -> v2.0.0\\)}, + %Q{ No version matching '2.0.0' exists on https://forge.puppetlabs.com.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end diff --git a/acceptance/tests/modules/upgrade/that_was_installed_twice.rb b/acceptance/tests/modules/upgrade/that_was_installed_twice.rb index 507b89157..8db838d85 100644 --- a/acceptance/tests/modules/upgrade/that_was_installed_twice.rb +++ b/acceptance/tests/modules/upgrade/that_was_installed_twice.rb @@ -1,61 +1,61 @@ test_name "puppet module upgrade (that was installed twice)" step 'Setup' stub_forge_on(master) testdir = master.tmpdir('upgrademultimods') teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" on master, "rm -rf #{testdir}/modules/java" on master, "rm -rf #{testdir}/modules/stdlib" end master_opts = { 'main' => { 'modulepath' => "#{master['distmoduledir']}:#{testdir}/modules" } } with_puppet_running_on master, master_opts, testdir do on master, puppet("module install pmtacceptance-java --version 1.6.0 --modulepath #{master['distmoduledir']}") on master, puppet("module install pmtacceptance-java --version 1.7.0 --modulepath #{testdir}/modules") on master, puppet("module list") do pattern = Regexp.new([ "#{master['distmoduledir']}", "├── pmtacceptance-java \\(.*v1.6.0\e.*\\)", "└── pmtacceptance-stdlib \\(.*v1.0.0.*\\)", "#{testdir}/modules", "├── pmtacceptance-java \\(.*v1.7.0.*\\)", "└── pmtacceptance-stdlib \\(.*v1.0.0.*\\)", ].join("\n")) assert_match(pattern, result.output) end step "Try to upgrade a module that exists multiple locations in the module path" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do pattern = Regexp.new([ ".*Notice: Preparing to upgrade 'pmtacceptance-java' .*", ".*Error: Could not upgrade module 'pmtacceptance-java'", " Module 'pmtacceptance-java' appears multiple places in the module path", " 'pmtacceptance-java' \\(v1.6.0\\) was found in #{master['distmoduledir']}", " 'pmtacceptance-java' \\(v1.7.0\\) was found in #{testdir}/modules", " Use the `--modulepath` option to limit the search to specific directories", - ].join("\n")) + ].join("\n"), Regexp::MULTILINE) assert_match(pattern, result.output) end step "Upgrade a module that exists multiple locations by restricting the --modulepath" on master, puppet("module upgrade pmtacceptance-java --modulepath #{master['distmoduledir']}") do pattern = Regexp.new([ ".*Notice: Preparing to upgrade 'pmtacceptance-java' .*", ".*Notice: Found 'pmtacceptance-java' \\(.*v1.6.0.*\\) in #{master['distmoduledir']} .*", ".*Notice: Downloading from https://forge.puppetlabs.com .*", ".*Notice: Upgrading -- do not interrupt .*", "#{master['distmoduledir']}", "└── pmtacceptance-java \\(.*v1.6.0 -> v1.7.1.*\\)", - ].join("\n")) + ].join("\n"), Regexp::MULTILINE) assert_match(pattern, result.output) end end diff --git a/acceptance/tests/modules/upgrade/to_a_specific_version.rb b/acceptance/tests/modules/upgrade/to_a_specific_version.rb index 9bdaf7bb4..c28bce336 100644 --- a/acceptance/tests/modules/upgrade/to_a_specific_version.rb +++ b/acceptance/tests/modules/upgrade/to_a_specific_version.rb @@ -1,44 +1,44 @@ test_name "puppet module upgrade (to a specific version)" step 'Setup' stub_forge_on(master) on master, "mkdir -p #{master['distmoduledir']}" teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Upgrade a module to a specific (greater) version" on master, puppet("module upgrade pmtacceptance-java --version 1.7.0") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) OUTPUT end step "Upgrade a module to a specific (lesser) version" on master, puppet("module upgrade pmtacceptance-java --version 1.6.0") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.6.0\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.6.0\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/upgrade/to_installed_version.rb b/acceptance/tests/modules/upgrade/to_installed_version.rb index cd096d60f..565c05913 100644 --- a/acceptance/tests/modules/upgrade/to_installed_version.rb +++ b/acceptance/tests/modules/upgrade/to_installed_version.rb @@ -1,81 +1,83 @@ test_name "puppet module upgrade (to installed version)" step 'Setup' on master, "mkdir -p #{master['distmoduledir']}" stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Try to upgrade a module to the current version" on master, puppet("module upgrade pmtacceptance-java --version 1.6.x"), :acceptable_exit_codes => [0] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> v1.6.x) - STDERR> The installed version is already the best fit for the current dependencies - STDERR> You specified 'pmtacceptance-java' (v1.6.x) - STDERR> Use `puppet module install --force` to re-install this module\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-java' ....*}, + %Q{.*Notice: Found 'pmtacceptance-java' \\(.*v1.6.0.*\\) in #{master['distmoduledir']} ....*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com ....*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-java' \\(v1.6.0 -> v1.6.x\\)}, + %Q{ The installed version is already the best fit for the current dependencies}, + %Q{ You specified 'pmtacceptance-java' \\(v1.6.x\\)}, + %Q{ Use `puppet module install --force` to re-install this module.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Upgrade a module to the current version with --force" on master, puppet("module upgrade pmtacceptance-java --version 1.6.x --force") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.6.0\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.6.0\e[0m) OUTPUT end step "Upgrade to the latest version" on master, puppet("module upgrade pmtacceptance-java") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end step "Try to upgrade a module to the latest version with the latest version installed" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [0] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.1\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.7.1 -> latest: v1.7.1) - STDERR> The installed version is already the latest version - STDERR> Use `puppet module install --force` to re-install this module\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-java' ....*}, + %Q{.*Notice: Found 'pmtacceptance-java' \\(.*v1.7.1.*\\) in #{master['distmoduledir']} ....*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com ....*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-java' \\(v1.7.1 -> latest: v1.7.1\\)}, + %Q{ The installed version is already the latest version}, + %Q{ Use `puppet module install --force` to re-install this module.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Upgrade a module to the latest version with --force" on master, puppet("module upgrade pmtacceptance-java --force") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.1\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.7.1 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.1\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.7.1 -> v1.7.1\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/upgrade/with_constraints_on_it.rb b/acceptance/tests/modules/upgrade/with_constraints_on_it.rb index 7bf4cc0ce..748d87b84 100644 --- a/acceptance/tests/modules/upgrade/with_constraints_on_it.rb +++ b/acceptance/tests/modules/upgrade/with_constraints_on_it.rb @@ -1,48 +1,50 @@ test_name "puppet module upgrade (with constraints on it)" step 'Setup' stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/apollo" on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, puppet("module install pmtacceptance-java --version 1.7.0") on master, puppet("module install pmtacceptance-apollo") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) - ├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-apollo (\e[0;36mv0.0.1\e[0m) +├── pmtacceptance-java (\e[0;36mv1.7.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end + step "Upgrade a version-constrained module that has an upgrade" on master, puppet("module upgrade pmtacceptance-java") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) OUTPUT end step "Try to upgrade a version-constrained module that has no upgrade" on master, puppet("module upgrade pmtacceptance-stdlib"), :acceptable_exit_codes => [0] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-stdlib' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-stdlib' (\e[0;36mv1.0.0\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-stdlib' (v1.0.0 -> best: v1.0.0) - STDERR> The installed version is already the best fit for the current dependencies - STDERR> 'pmtacceptance-apollo' (v0.0.1) requires 'pmtacceptance-stdlib' (>= 1.0.0) - STDERR> 'pmtacceptance-java' (v1.7.1) requires 'pmtacceptance-stdlib' (v1.0.0) - STDERR> Use `puppet module install --force` to re-install this module\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-stdlib' ....*}, + %Q{.*Notice: Found 'pmtacceptance-stdlib' \\(.*v1.0.0.*\\) in #{master['distmoduledir']} ....*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com ....*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-stdlib' \\(v1.0.0 -> best: v1.0.0\\)}, + %Q{ The installed version is already the best fit for the current dependencies}, + %Q{ 'pmtacceptance-apollo' \\(v0.0.1\\) requires 'pmtacceptance-stdlib' \\(>= 1.0.0\\)}, + %Q{ 'pmtacceptance-java' \\(v1.7.1\\) requires 'pmtacceptance-stdlib' \\(v1.0.0\\)}, + %Q{ Use `puppet module install --force` to re-install this module.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end diff --git a/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb b/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb index 67edf26aa..fe9f245c0 100644 --- a/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb +++ b/acceptance/tests/modules/upgrade/with_constraints_on_its_dependencies.rb @@ -1,89 +1,90 @@ test_name "puppet module upgrade (with constraints on its dependencies)" step 'Setup' stub_forge_on(master) teardown do on master, "rm -rf #{master['distmoduledir']}/unicorns" on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end apply_manifest_on master, <<-PP file { [ '#{master['distmoduledir']}/unicorns', ]: ensure => directory; '#{master['distmoduledir']}/unicorns/metadata.json': content => '{ "name": "notpmtacceptance/unicorns", "version": "0.0.3", "source": "", "author": "notpmtacceptance", "license": "MIT", "dependencies": [ { "name": "pmtacceptance/stdlib", "version_requirement": "0.0.2" } ] }'; } PP on master, puppet("module install pmtacceptance-stdlib --version 0.0.2") on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── notpmtacceptance-unicorns (\e[0;36mv0.0.3\e[0m) +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) OUTPUT end step "Try to upgrade a module with constraints on its dependencies that cannot be met" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - STDOUT> \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> latest: v1.7.1) - STDERR> No version of 'pmtacceptance-stdlib' will satisfy dependencies - STDERR> 'notpmtacceptance-unicorns' (v0.0.3) requires 'pmtacceptance-stdlib' (v0.0.2) - STDERR> 'pmtacceptance-java' (v1.7.1) requires 'pmtacceptance-stdlib' (v1.0.0) - STDERR> Use `puppet module upgrade --ignore-dependencies` to upgrade only this module\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-java' ....*}, + %Q{.*Notice: Found 'pmtacceptance-java' \\(.*v1.6.0.*\\) in #{master['distmoduledir']} ....*}, + %Q{.*Notice: Downloading from https://forge.puppetlabs.com ....*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-java' \\(v1.6.0 -> latest: v1.7.1\\)}, + %Q{ No version of 'pmtacceptance-stdlib' will satisfy dependencies}, + %Q{ 'notpmtacceptance-unicorns' \\(v0.0.3\\) requires 'pmtacceptance-stdlib' \\(v0.0.2\\)}, + %Q{ 'pmtacceptance-java' \\(v1.7.1\\) requires 'pmtacceptance-stdlib' \\(v1.0.0\\)}, + %Q{ Use `puppet module upgrade --ignore-dependencies` to upgrade only this module.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end step "Relax constraints" on master, puppet("module uninstall notpmtacceptance-unicorns") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv0.0.2\e[0m) OUTPUT end step "Upgrade a single module, ignoring its dependencies" on master, puppet("module upgrade pmtacceptance-java --version 1.7.0 --ignore-dependencies") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.0\e[0m) OUTPUT end step "Upgrade a module with constraints on its dependencies that can be met" on master, puppet("module upgrade pmtacceptance-java") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └─┬ pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv0.0.2 -> v1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.7.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└─┬ pmtacceptance-java (\e[0;36mv1.7.0 -> v1.7.1\e[0m) + └── pmtacceptance-stdlib (\e[0;36mv0.0.2 -> v1.0.0\e[0m) OUTPUT end diff --git a/acceptance/tests/modules/upgrade/with_local_changes.rb b/acceptance/tests/modules/upgrade/with_local_changes.rb index c60637d4b..cd9c4e88b 100644 --- a/acceptance/tests/modules/upgrade/with_local_changes.rb +++ b/acceptance/tests/modules/upgrade/with_local_changes.rb @@ -1,53 +1,54 @@ test_name "puppet module upgrade (with local changes)" step 'Setup' stub_forge_on(master) on master, "mkdir -p #{master['distmoduledir']}" teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end apply_manifest_on master, <<-PP file { '#{master['distmoduledir']}/java/README': content => "I CHANGE MY READMES"; '#{master['distmoduledir']}/java/NEWFILE': content => "I don't exist.'"; } PP step "Try to upgrade a module with local changes" on master, puppet("module upgrade pmtacceptance-java"), :acceptable_exit_codes => [1] do - assert_output <<-OUTPUT - STDOUT> \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - STDOUT> \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - STDERR> \e[1;31mError: Could not upgrade module 'pmtacceptance-java' (v1.6.0 -> latest) - STDERR> Installed module has had changes made locally - STDERR> Use `puppet module upgrade --force` to upgrade this module anyway\e[0m - OUTPUT + pattern = Regexp.new([ + %Q{.*Notice: Preparing to upgrade 'pmtacceptance-java' ....*}, + %Q{.*Notice: Found 'pmtacceptance-java' \\(.*v1.6.0.*\\) in #{master['distmoduledir']} ....*}, + %Q{.*Error: Could not upgrade module 'pmtacceptance-java' \\(v1.6.0 -> latest\\)}, + %Q{ Installed module has had changes made locally}, + %Q{ Use `puppet module upgrade --force` to upgrade this module anyway.*}, + ].join("\n"), Regexp::MULTILINE) + assert_match(pattern, result.output) end on master, %{[[ "$(cat #{master['distmoduledir']}/java/README)" == "I CHANGE MY READMES" ]]} on master, "[ -f #{master['distmoduledir']}/java/NEWFILE ]" step "Upgrade a module with local changes with --force" on master, puppet("module upgrade pmtacceptance-java --force") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT end on master, %{[[ "$(cat #{master['distmoduledir']}/java/README)" != "I CHANGE MY READMES" ]]} on master, "[ ! -f #{master['distmoduledir']}/java/NEWFILE ]" diff --git a/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb b/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb index 5a426bbd7..8309d1d7e 100644 --- a/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb +++ b/acceptance/tests/modules/upgrade/with_scattered_dependencies.rb @@ -1,47 +1,47 @@ test_name "puppet module upgrade (with scattered dependencies)" step 'Setup' stub_forge_on(master) testdir = master.tmpdir('scattereddeps') on master, "mkdir -p #{master['distmoduledir']}" on master, "mkdir -p #{master['sitemoduledir']}" on master, "mkdir -p #{testdir}/modules" teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/postgresql" end master_opts = { 'main' => { 'modulepath' => "#{testdir}/modules:#{master['distmoduledir']}:#{master['sitemoduledir']}" } } with_puppet_running_on master, master_opts, testdir do on master, puppet("module install pmtacceptance-stdlib --version 0.0.2 --target-dir #{testdir}/modules") on master, puppet("module install pmtacceptance-java --version 1.6.0 --target-dir #{master['distmoduledir']} --ignore-dependencies") on master, puppet("module install pmtacceptance-postgresql --version 0.0.1 --target-dir #{master['distmoduledir']} --ignore-dependencies") on master, puppet("module list") do assert_match /pmtacceptance-java.*1\.6\.0/, stdout, 'Could not find pmtacceptance/java' assert_match /pmtacceptance-postgresql.*0\.0\.1/, stdout, 'Could not find pmtacceptance/postgresql' assert_match /pmtacceptance-stdlib.*0\.0\.2/, stdout, 'Could not find pmtacceptance/stdlib' end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-postgresql --version 0.0.2") do pattern = Regexp.new([ ".*Notice: Preparing to upgrade 'pmtacceptance-postgresql' .*", ".*Notice: Found 'pmtacceptance-postgresql' \\(.*v0.0.1.*\\) in #{master['distmoduledir']} .*", ".*Notice: Downloading from https://forge.puppetlabs.com .*", ".*Notice: Upgrading -- do not interrupt .*", "#{master['distmoduledir']}", "└─┬ pmtacceptance-postgresql \\(.*v0.0.1 -> v0.0.2.*\\)", " ├─┬ pmtacceptance-java \\(.*v1.6.0 -> v1.7.0.*\\)", " │ └── pmtacceptance-stdlib \\(.*v0.0.2 -> v1.0.0.*\\) \\[#{testdir}/modules\\]", " └── pmtacceptance-stdlib \\(.*v0.0.2 -> v1.0.0.*\\) \\[#{testdir}/modules\\]", - ].join("\n")) + ].join("\n"), Regexp::MULTILINE) assert_match(pattern, result.output) end end diff --git a/acceptance/tests/modules/upgrade/with_update_available.rb b/acceptance/tests/modules/upgrade/with_update_available.rb index d102d1df6..48f03e497 100644 --- a/acceptance/tests/modules/upgrade/with_update_available.rb +++ b/acceptance/tests/modules/upgrade/with_update_available.rb @@ -1,35 +1,35 @@ test_name "puppet module upgrade (with update available)" step 'Setup' stub_forge_on(master) on master, "mkdir -p #{master['distmoduledir']}" teardown do on master, "rm -rf #{master['distmoduledir']}/java" on master, "rm -rf #{master['distmoduledir']}/stdlib" end on master, puppet("module install pmtacceptance-java --version 1.6.0") on master, puppet("module list --modulepath #{master['distmoduledir']}") do - assert_output <<-OUTPUT - #{master['distmoduledir']} - ├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) - └── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) + assert_equal <<-OUTPUT, stdout +#{master['distmoduledir']} +├── pmtacceptance-java (\e[0;36mv1.6.0\e[0m) +└── pmtacceptance-stdlib (\e[0;36mv1.0.0\e[0m) OUTPUT end step "Upgrade a module that has a more recent version published" on master, puppet("module upgrade pmtacceptance-java") do - assert_output <<-OUTPUT - \e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m - \e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m - \e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m - \e[mNotice: Upgrading -- do not interrupt ...\e[0m - #{master['distmoduledir']} - └── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) + assert_equal <<-OUTPUT, stdout +\e[mNotice: Preparing to upgrade 'pmtacceptance-java' ...\e[0m +\e[mNotice: Found 'pmtacceptance-java' (\e[0;36mv1.6.0\e[m) in #{master['distmoduledir']} ...\e[0m +\e[mNotice: Downloading from https://forge.puppetlabs.com ...\e[0m +\e[mNotice: Upgrading -- do not interrupt ...\e[0m +#{master['distmoduledir']} +└── pmtacceptance-java (\e[0;36mv1.6.0 -> v1.7.1\e[0m) OUTPUT on master, "[ -d #{master['distmoduledir']}/java ]" on master, "[ -f #{master['distmoduledir']}/java/Modulefile ]" on master, "grep 1.7.1 #{master['distmoduledir']}/java/Modulefile" end diff --git a/acceptance/tests/resource/package/does_not_exist.rb b/acceptance/tests/resource/package/does_not_exist.rb index d3931643f..a277dc6e8 100644 --- a/acceptance/tests/resource/package/does_not_exist.rb +++ b/acceptance/tests/resource/package/does_not_exist.rb @@ -1,33 +1,32 @@ # Redmine (#22529) test_name "Puppet returns only resource package declaration when querying an uninstalled package" do resource_declaration_regex = %r@package \{ 'not-installed-on-this-host': ensure => '(?:purged|absent)', \}@m package_apply_regex = %r@Notice: Compiled catalog for .* in environment production in \d+\.\d{2} seconds(?:\e\[0m)? (?:\e\[m)?Notice: Finished catalog run in \d+\.\d{2} seconds@m agents.each do |agent| step "test puppet resource package" do on(agent, puppet('resource', 'package', 'not-installed-on-this-host')) do assert_match(resource_declaration_regex, stdout) end end end # Until #3707 is fixed and purged rpm/yum packages no longer give spurious creation notices # Also skipping solaris, windows whose providers do not have purgeable implemented. 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 assert_match(package_apply_regex, stdout) - assert_equal('', stderr) end end end end end