diff options
| author | Dominic Maraglia <dmaraglia@gmail.com> | 2011-04-20 14:58:26 -0700 |
|---|---|---|
| committer | Dominic Maraglia <dmaraglia@gmail.com> | 2011-04-20 14:58:26 -0700 |
| commit | ac428b9557e2da251e4b51e48de844833ca0aa2a (patch) | |
| tree | b3ccc5cf1a0dae6e2662dc61855281dc6ba8e8d5 /acceptance/tests/resource/exec | |
| parent | 97e9e5f223cb7baefd52456e2324c592fe415dca (diff) | |
| download | puppet-ac428b9557e2da251e4b51e48de844833ca0aa2a.tar.gz puppet-ac428b9557e2da251e4b51e48de844833ca0aa2a.tar.xz puppet-ac428b9557e2da251e4b51e48de844833ca0aa2a.zip | |
Move tests from Puppet-acceptance repo
Diffstat (limited to 'acceptance/tests/resource/exec')
3 files changed, 81 insertions, 0 deletions
diff --git a/acceptance/tests/resource/exec/should_not_run_command_creates.rb b/acceptance/tests/resource/exec/should_not_run_command_creates.rb new file mode 100644 index 000000000..583ae4306 --- /dev/null +++ b/acceptance/tests/resource/exec/should_not_run_command_creates.rb @@ -0,0 +1,34 @@ +test_name "should not run command creates" + +touch = "/tmp/touched-#{Time.new.to_i}" +donottouch = "/tmp/not-touched-#{Time.new.to_i}" + +manifest = %Q{ + exec { "test#{Time.new.to_i}": command => '/bin/touch #{donottouch}', creates => "#{touch}"} +} + +step "prepare the agents for the test" +on agents, "touch #{touch} ; rm -f #{donottouch}" + +step "test using puppet apply" +apply_manifest_on(agents, manifest) do + fail_test "looks like the thing executed, which it shouldn't" if + stdout.include? 'executed successfully' +end + +step "verify the file didn't get created" +on agents, "test -f #{donottouch}", :acceptable_exit_codes => [1] + +step "prepare the agents for the second part of the test" +on agents, "touch #{touch} ; rm -f #{donottouch}" + +step "test using puppet resource" +on(agents, puppet_resource('exec', "test#{Time.new.to_i}", + "command='/bin/touch #{donottouch}'", + "creates='#{touch}'")) do + fail_test "looks like the thing executed, which it shouldn't" if + stdout.include? 'executed successfully' +end + +step "verify the file didn't get created the second time" +on agents, "test -f #{donottouch}", :acceptable_exit_codes => [1] diff --git a/acceptance/tests/resource/exec/should_run_command.rb b/acceptance/tests/resource/exec/should_run_command.rb new file mode 100644 index 000000000..b7156c6c9 --- /dev/null +++ b/acceptance/tests/resource/exec/should_run_command.rb @@ -0,0 +1,31 @@ +test_name "tests that puppet correctly runs an exec." +# original author: Dan Bode --daniel 2010-12-23 + +$touch = "/tmp/test-exec-#{Time.new.to_i}" + +def before + step "file to be touched should not exist." + on agents, "rm -f #{$touch}" +end + +def after + step "checking the output worked" + on agents, "test -f #{$touch}" + + step "clean up the system" + on agents, "rm -f #{$touch}" +end + +before +apply_manifest_on(agents, "exec {'test': command=>'/bin/touch #{$touch}'}") do + fail_test "didn't seem to run the command" unless + stdout.include? 'executed successfully' +end +after + +before +on(agents, puppet_resource('-d', 'exec', 'test', "command='/bin/touch #{$touch}'")) do + fail_test "didn't seem to run the command" unless + stdout.include? 'executed successfully' +end +after diff --git a/acceptance/tests/resource/exec/should_set_path.rb b/acceptance/tests/resource/exec/should_set_path.rb new file mode 100644 index 000000000..4d9ccb060 --- /dev/null +++ b/acceptance/tests/resource/exec/should_set_path.rb @@ -0,0 +1,16 @@ +test_name "the path statement should work to locate commands" + +file = "/tmp/touched-should-set-path-#{Time.new.to_i}" + +step "clean up the system for the test" +on agents, "rm -f #{file}" + +step "invoke the exec resource with a path set" +on(agents, puppet_resource('exec', 'test', + "command='touch #{file}'", 'path="/bin:/usr/bin"')) + +step "verify that the files were created" +on agents, "test -f #{file}" + +step "clean up the system after testing" +on agents, "rm -f #{file}" |
