summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acceptance/tests/environment/use_environment_from_environmentdir.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/acceptance/tests/environment/use_environment_from_environmentdir.rb b/acceptance/tests/environment/use_environment_from_environmentdir.rb
new file mode 100644
index 000000000..dcf12e40c
--- /dev/null
+++ b/acceptance/tests/environment/use_environment_from_environmentdir.rb
@@ -0,0 +1,68 @@
+test_name "Use environments from the environmentdir"
+
+testdir = master.tmpdir('use_environmentdir')
+
+apply_manifest_on(master, <<-MANIFEST)
+File {
+ ensure => directory,
+ owner => puppet,
+ mode => 0700,
+}
+
+file {
+ "#{testdir}/environments":;
+ "#{testdir}/environments/special":;
+ "#{testdir}/environments/special/manifest":;
+ "#{testdir}/environments/special/modules":;
+ "#{testdir}/environments/special/modules/amod":;
+ "#{testdir}/environments/special/modules/amod/manifests":;
+ "#{testdir}/environments/special/modules/amod/files":;
+ "#{testdir}/environments/special/modules/amod/templates":;
+ "#{testdir}/environments/special/modules/amod/lib":;
+ "#{testdir}/environments/special/modules/amod/lib/facter":;
+
+ "#{testdir}/environments/special/modules/amod/manifests/init.pp":
+ ensure => file,
+ content => 'class amod { notify { template: message => template("amod/our_template.erb") } file { "$agent_file_location/file": source => "puppet:///modules/amod/data" }'
+ ;
+ "#{testdir}/environments/special/modules/amod/lib/facter/environment_fact.rb":
+ ensure => file,
+ content => "Facter.add(:environment_fact) { setcode { 'environment fact' } }"
+ ;
+ "#{testdir}/environments/special/modules/amod/files/data":
+ ensure => file,
+ content => "data file"
+ ;
+ "#{testdir}/environments/special/modules/amod/templates/our_template.erb":
+ ensure => file,
+ content => "<%= @environment_fact %>"
+ ;
+ "#{testdir}/environments/special/manifests/site.pp":
+ ensure => file,
+ content => "include amod"
+ ;
+}
+MANIFEST
+
+master_opts = {
+ 'master' => {
+ 'environmentdir' => "#{testdir}/environments"
+ }
+}
+
+with_puppet_running_on master, master_opts, testdir do
+ agents.each do |agent|
+ atmp = agent.tmpdir('use_environmentdir')
+ on agent, puppet("agent", "--environment", "special", "-t", "--server", master, "--trace"), :environment => {
+ "FACTER_agent_file_location" => atmp
+ } do |result|
+ assert_match(/environment fact/, result.stdout)
+ end
+
+ on agent, "cat #{atmp}/file" do |result|
+ assert_match(/data file/, result.stdout)
+ end
+
+ on agent, "rm -rf #{atmp}"
+ end
+end