summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Duarte <john.duarte@puppetlabs.com>2014-09-19 14:01:57 -0700
committerJohn Duarte <john.duarte@puppetlabs.com>2014-09-19 16:09:16 -0700
commit5a49f76f484dfc6cd436480ae86dcb1848e9695b (patch)
tree4235b9df6fb2db2d7f74f736006495d21b5bca75
parent012662728269875470b3ee56325bebe0ad841bd4 (diff)
downloadpuppet-5a49f76f484dfc6cd436480ae86dcb1848e9695b.tar.gz
(PUP-3248) Use tmpdir for generating environments
This commit changes calls to the generate_base_legacy_and_directory_environments helper to use a tmpdir rather than master['puppetpath'] to isolate the test environments and prevent collisions. The generate_base_legacy_and_directory_environments has also been altered to remove the `environmentpath` setting in the generated configuration file.
-rw-r--r--acceptance/lib/puppet/acceptance/module_utils.rb3
-rw-r--r--acceptance/tests/modules/install/with_environment.rb14
-rw-r--r--acceptance/tests/modules/list/with_environment.rb12
-rw-r--r--acceptance/tests/modules/uninstall/with_environment.rb22
-rw-r--r--acceptance/tests/modules/upgrade/with_environment.rb12
5 files changed, 29 insertions, 34 deletions
diff --git a/acceptance/lib/puppet/acceptance/module_utils.rb b/acceptance/lib/puppet/acceptance/module_utils.rb
index cc009e050..5b6124998 100644
--- a/acceptance/lib/puppet/acceptance/module_utils.rb
+++ b/acceptance/lib/puppet/acceptance/module_utils.rb
@@ -267,6 +267,9 @@ module Puppet
}
}
+ # remove environmentpath entry from config
+ on master, "sed '/environmentpath/d' #{puppet_conf} > #{path_to_environments}/tmp && mv #{path_to_environments}/tmp #{puppet_conf}"
+
on master, puppet("config", "set",
"modulepath", "#{legacy_env}/modules",
"--section", "legacyenv",
diff --git a/acceptance/tests/modules/install/with_environment.rb b/acceptance/tests/modules/install/with_environment.rb
index dcba46e45..fa608f230 100644
--- a/acceptance/tests/modules/install/with_environment.rb
+++ b/acceptance/tests/modules/install/with_environment.rb
@@ -2,9 +2,7 @@ test_name 'puppet module install (with environment)'
require 'puppet/acceptance/module_utils'
extend Puppet::Acceptance::ModuleUtils
-if master.is_pe?
- skip_test
-end
+tmpdir = master.tmpdir('environmentpath')
module_author = "pmtacceptance"
module_name = "nginx"
@@ -18,7 +16,7 @@ step 'Setup'
stub_forge_on(master)
-puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath'])
+puppet_conf = generate_base_legacy_and_directory_environments(tmpdir)
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
@@ -30,19 +28,19 @@ check_module_install_in = lambda do |environment_path, module_install_args|
end
step 'Install a module into a non default legacy environment' do
- check_module_install_in.call("#{master['puppetpath']}/legacyenv/modules",
+ check_module_install_in.call("#{tmpdir}/legacyenv/modules",
"--environment=legacyenv")
end
step 'Enable directory environments' do
on master, puppet("config", "set",
- "environmentpath", "#{master['puppetpath']}/environments",
+ "environmentpath", "#{tmpdir}/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",
+ check_module_install_in.call("#{tmpdir}/environments/direnv/modules",
"--environment=direnv")
end
@@ -51,7 +49,7 @@ modulepath_dir = master.tmpdir("modulepath")
apply_manifest_on(master, <<-MANIFEST , :catch_failures => true)
file {
[
- '#{master['puppetpath']}/environments/production',
+ '#{tmpdir}/environments/production',
'#{modulepath_dir}',
]:
diff --git a/acceptance/tests/modules/list/with_environment.rb b/acceptance/tests/modules/list/with_environment.rb
index fd6515c9d..e57138150 100644
--- a/acceptance/tests/modules/list/with_environment.rb
+++ b/acceptance/tests/modules/list/with_environment.rb
@@ -2,15 +2,13 @@ test_name 'puppet module list (with environment)'
require 'puppet/acceptance/module_utils'
extend Puppet::Acceptance::ModuleUtils
-if master.is_pe?
- skip_test
-end
+tmpdir = master.tmpdir('environmentpath')
step 'Setup'
stub_forge_on(master)
-puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath'])
+puppet_conf = generate_base_legacy_and_directory_environments(tmpdir)
install_test_module_in = lambda do |environment|
on master, puppet("module", "install",
@@ -31,17 +29,17 @@ 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")
+ check_module_list_in.call('legacyenv', "#{tmpdir}/legacyenv/modules")
end
step 'Enable directory environments' do
on master, puppet("config", "set",
- "environmentpath", "#{master['puppetpath']}/environments",
+ "environmentpath", "#{tmpdir}/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")
+ check_module_list_in.call('direnv', "#{tmpdir}/environments/direnv/modules")
end
diff --git a/acceptance/tests/modules/uninstall/with_environment.rb b/acceptance/tests/modules/uninstall/with_environment.rb
index c8a438da0..77a682f14 100644
--- a/acceptance/tests/modules/uninstall/with_environment.rb
+++ b/acceptance/tests/modules/uninstall/with_environment.rb
@@ -2,15 +2,13 @@ test_name 'puppet module uninstall (with environment)'
require 'puppet/acceptance/module_utils'
extend Puppet::Acceptance::ModuleUtils
-if master.is_pe?
- skip_test
-end
+tmpdir = master.tmpdir('environmentpath')
step 'Setup'
stub_forge_on(master)
-puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath'])
+puppet_conf = generate_base_legacy_and_directory_environments(tmpdir)
crakorn_metadata = <<-EOS
{
@@ -27,18 +25,18 @@ EOS
apply_manifest_on master, %Q{
file {
[
- '#{master['puppetpath']}/legacyenv/modules/crakorn',
- '#{master['puppetpath']}/environments/direnv/modules',
- '#{master['puppetpath']}/environments/direnv/modules/crakorn',
+ '#{tmpdir}/legacyenv/modules/crakorn',
+ '#{tmpdir}/environments/direnv/modules',
+ '#{tmpdir}/environments/direnv/modules/crakorn',
]:
ensure => directory,
}
file {
- '#{master['puppetpath']}/legacyenv/modules/crakorn/metadata.json':
+ '#{tmpdir}/legacyenv/modules/crakorn/metadata.json':
content => '#{crakorn_metadata}',
}
file {
- '#{master['puppetpath']}/environments/direnv/modules/crakorn/metadata.json':
+ '#{tmpdir}/environments/direnv/modules/crakorn/metadata.json':
content => '#{crakorn_metadata}',
}
}
@@ -54,16 +52,16 @@ Removed 'jimmy-crakorn' (\e[0;36mv0.4.0\e[0m) from #{environment_path}
end
step 'Uninstall a module from a non default legacy environment' do
- check_module_uninstall_in.call('legacyenv', "#{master['puppetpath']}/legacyenv/modules")
+ check_module_uninstall_in.call('legacyenv', "#{tmpdir}/legacyenv/modules")
end
step 'Enable directory environments' do
on master, puppet("config", "set",
- "environmentpath", "#{master['puppetpath']}/environments",
+ "environmentpath", "#{tmpdir}/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")
+ check_module_uninstall_in.call('direnv', "#{tmpdir}/environments/direnv/modules")
end
diff --git a/acceptance/tests/modules/upgrade/with_environment.rb b/acceptance/tests/modules/upgrade/with_environment.rb
index de8077486..3a4aa8c72 100644
--- a/acceptance/tests/modules/upgrade/with_environment.rb
+++ b/acceptance/tests/modules/upgrade/with_environment.rb
@@ -2,9 +2,7 @@ test_name "puppet module upgrade (with environment)"
require 'puppet/acceptance/module_utils'
extend Puppet::Acceptance::ModuleUtils
-if master.is_pe?
- skip_test
-end
+tmpdir = master.tmpdir('environmentpath')
module_author = "pmtacceptance"
module_name = "java"
@@ -19,7 +17,7 @@ step 'Setup'
stub_forge_on(master)
-puppet_conf = generate_base_legacy_and_directory_environments(master['puppetpath'])
+puppet_conf = generate_base_legacy_and_directory_environments(tmpdir)
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
@@ -37,17 +35,17 @@ 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")
+ check_module_upgrade_in.call('legacyenv', "#{tmpdir}/legacyenv/modules")
end
step 'Enable directory environments' do
on master, puppet("config", "set",
- "environmentpath", "#{master['puppetpath']}/environments",
+ "environmentpath", "#{tmpdir}/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")
+ check_module_upgrade_in.call('direnv', "#{tmpdir}/environments/direnv/modules")
end