diff --git a/acceptance/tests/modules/install/with_environment.rb b/acceptance/tests/modules/install/with_environment.rb index d9200d138..4888f153f 100644 --- a/acceptance/tests/modules/install/with_environment.rb +++ b/acceptance/tests/modules/install/with_environment.rb @@ -1,63 +1,70 @@ test_name 'puppet module install (with environment)' require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils module_author = "pmtacceptance" module_name = "nginx" 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) puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath']) check_module_install_in = lambda do |environment_path, module_install_args| on master, "puppet module install #{module_author}-#{module_name} --config=#{puppet_conf} #{module_install_args}" do assert_module_installed_ui(stdout, module_author, module_name) assert_match(/#{environment_path}/, stdout, "Notice of non default install path was not displayed") end assert_module_installed_on_disk(master, "#{environment_path}", module_name) end step 'Install a module into a non default legacy environment' do check_module_install_in.call("#{master['puppetpath']}/legacyenv/modules", "--environment=legacyenv") end +step 'Enable directory environments' do + on master, puppet("config", "set", + "environmentpath", "#{master['puppetpath']}/environments", + "--section", "main", + "--config", puppet_conf) +end + step 'Install a module into a non default directory environment' do check_module_install_in.call("#{master['puppetpath']}/environments/direnv/modules", "--environment=direnv") end step 'Prepare a separate modulepath' modulepath_dir = master.tmpdir("modulepath") apply_manifest_on(master, <<-MANIFEST , :catch_failures => true) file { [ '#{master['puppetpath']}/environments/production', '#{modulepath_dir}', ]: ensure => directory, owner => puppet, } MANIFEST step "Install a module into --modulepath #{modulepath_dir} despite the implicit production directory env existing" do check_module_install_in.call(modulepath_dir, "--modulepath=#{modulepath_dir}") end step "Uninstall so we can try a different scenario" do on master, "puppet module uninstall #{module_author}-#{module_name} --config=#{puppet_conf} --modulepath=#{modulepath_dir}" end step "Install a module into --modulepath #{modulepath_dir} with a directory env specified" do check_module_install_in.call(modulepath_dir, "--modulepath=#{modulepath_dir} --environment=direnv") end diff --git a/acceptance/tests/modules/list/with_environment.rb b/acceptance/tests/modules/list/with_environment.rb index 841265e7a..bbbfed2fc 100644 --- a/acceptance/tests/modules/list/with_environment.rb +++ b/acceptance/tests/modules/list/with_environment.rb @@ -1,36 +1,43 @@ test_name 'puppet module list (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']) install_test_module_in = lambda do |environment| on master, puppet("module", "install", "pmtacceptance-nginx", "--config", puppet_conf, "--environment", environment) end check_module_list_in = lambda do |environment, environment_path| on master, puppet("module", "list", "--config", puppet_conf, "--environment", environment) do assert_match(/#{environment_path}/, stdout) assert_match(/pmtacceptance-nginx/, stdout) end end step 'List modules in a non default legacy environment' do install_test_module_in.call('legacyenv') check_module_list_in.call('legacyenv', "#{master['puppetpath']}/legacyenv/modules") end +step 'Enable directory environments' do + on master, puppet("config", "set", + "environmentpath", "#{master['puppetpath']}/environments", + "--section", "main", + "--config", puppet_conf) +end + step 'List modules in a non default directory environment' do install_test_module_in.call('direnv') check_module_list_in.call('direnv', "#{master['puppetpath']}/environments/direnv/modules") end diff --git a/acceptance/tests/modules/uninstall/with_environment.rb b/acceptance/tests/modules/uninstall/with_environment.rb index ac35dadcd..9790b5bdf 100644 --- a/acceptance/tests/modules/uninstall/with_environment.rb +++ b/acceptance/tests/modules/uninstall/with_environment.rb @@ -1,58 +1,65 @@ 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} 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 'Enable directory environments' do + on master, puppet("config", "set", + "environmentpath", "#{master['puppetpath']}/environments", + "--section", "main", + "--config", puppet_conf) +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/upgrade/with_environment.rb b/acceptance/tests/modules/upgrade/with_environment.rb index 4dc5dba4c..096549fdf 100644 --- a/acceptance/tests/modules/upgrade/with_environment.rb +++ b/acceptance/tests/modules/upgrade/with_environment.rb @@ -1,42 +1,49 @@ test_name "puppet module upgrade (with environment)" require 'puppet/acceptance/module_utils' extend Puppet::Acceptance::ModuleUtils module_author = "pmtacceptance" module_name = "java" module_dependencies = ["stdlib"] 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) puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath']) install_test_module_in = lambda do |environment| on master, puppet("module install #{module_author}-#{module_name} --config=#{puppet_conf} --version 1.6.0 --environment=#{environment}") do assert_module_installed_ui(stdout, module_author, module_name) end end check_module_upgrade_in = lambda do |environment, environment_path| on master, puppet("module upgrade #{module_author}-#{module_name} --config=#{puppet_conf} --environment=#{environment}") do assert_module_installed_ui(stdout, module_author, module_name) on master, "[ -f #{environment_path}/#{module_name}/Modulefile ]" on master, "grep 1.7.1 #{environment_path}/#{module_name}/Modulefile" end end step "Upgrade a module that has a more recent version published in a legacy environment" do install_test_module_in.call('legacyenv') check_module_upgrade_in.call('legacyenv', "#{master['puppetpath']}/legacyenv/modules") end +step 'Enable directory environments' do + on master, puppet("config", "set", + "environmentpath", "#{master['puppetpath']}/environments", + "--section", "main", + "--config", puppet_conf) +end + step "Upgrade a module that has a more recent version published in a directory environment" do install_test_module_in.call('direnv') check_module_upgrade_in.call('direnv', "#{master['puppetpath']}/environments/direnv/modules") end