summaryrefslogtreecommitdiffstats
path: root/acceptance/tests/resource/cron
diff options
context:
space:
mode:
authorDominic Maraglia <dominic@puppetlabs.com>2011-06-27 13:58:44 -0700
committerDominic Maraglia <dominic@puppetlabs.com>2011-06-27 13:58:44 -0700
commit3e3fc693c2a96f6cf56e670f6d5ae5cd70f6a523 (patch)
tree86b44b9cee04b3bd16d482fe8f897f9f5870665c /acceptance/tests/resource/cron
parentc9746538f486233f854382c4a0f6e46126ae339a (diff)
downloadpuppet-3e3fc693c2a96f6cf56e670f6d5ae5cd70f6a523.tar.gz
puppet-3e3fc693c2a96f6cf56e670f6d5ae5cd70f6a523.tar.xz
puppet-3e3fc693c2a96f6cf56e670f6d5ae5cd70f6a523.zip
(#7956) Port resource acceptance tests
Many of the Puppet resource acceptance tests were RHEL/Centos specifc. These tests were ported under the enterptise-dist repo; move the tests into 2.6.x for merging.
Diffstat (limited to 'acceptance/tests/resource/cron')
-rw-r--r--acceptance/tests/resource/cron/should_create_cron.rb6
-rwxr-xr-xacceptance/tests/resource/cron/should_match_existing.rb13
-rwxr-xr-xacceptance/tests/resource/cron/should_remove_cron.rb12
-rwxr-xr-xacceptance/tests/resource/cron/should_remove_matching.rb8
-rwxr-xr-xacceptance/tests/resource/cron/should_update_existing.rb14
5 files changed, 24 insertions, 29 deletions
diff --git a/acceptance/tests/resource/cron/should_create_cron.rb b/acceptance/tests/resource/cron/should_create_cron.rb
index e45561491..5badac05f 100644
--- a/acceptance/tests/resource/cron/should_create_cron.rb
+++ b/acceptance/tests/resource/cron/should_create_cron.rb
@@ -1,6 +1,6 @@
test_name "should create cron"
-tmpuser = "cron-test-#{Time.new.to_i}"
+tmpuser = "pl#{rand(999999).to_i}"
tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
create_user = "user { '#{tmpuser}': ensure => present, managehome => false }"
@@ -18,13 +18,13 @@ agents.each do |host|
end
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
+ run_cron_on(host, :list, tmpuser) do
fail_test "didn't find the command as expected" unless
stdout.include? "* * * * * /bin/true"
end
step "remove the crontab file for that user"
- on host, "crontab -r -u #{tmpuser}"
+ run_cron_on(host, :remove, tmpuser)
step "remove the user from the system"
apply_manifest_on host, delete_user
diff --git a/acceptance/tests/resource/cron/should_match_existing.rb b/acceptance/tests/resource/cron/should_match_existing.rb
index b34a0498c..b5c5d359d 100755
--- a/acceptance/tests/resource/cron/should_match_existing.rb
+++ b/acceptance/tests/resource/cron/should_match_existing.rb
@@ -1,6 +1,6 @@
+test_name "puppet should match existing job"
-
-tmpuser = "cron-test-#{Time.new.to_i}"
+tmpuser = "pl#{rand(999999).to_i}"
tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
create_user = "user { '#{tmpuser}': ensure => present, managehome => false }"
@@ -11,14 +11,11 @@ agents.each do |host|
apply_manifest_on host, create_user
step "create the existing job by hand..."
- on host, "echo '* * * * * /bin/true' | crontab -u #{tmpuser} -"
+ run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
step "apply the resource on the host using puppet resource"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
"command=/bin/true", "ensure=present")) do
- # REVISIT: This is ported from the original test, which seems to me a
- # weak test, but I don't want to improve it now. --daniel 2010-12-23
- #
# This is a weak/fragile test. The output has changed
# causing this test to fail erronously. Changed to the correct
# output to match, but this code should be re-feactored.
@@ -27,13 +24,13 @@ agents.each do |host|
end
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
+ run_cron_on(host, :list, tmpuser) do
fail_test "didn't find the command as expected" unless
stdout.include? "* * * * * /bin/true"
end
step "remove the crontab file for that user"
- on host, "crontab -r -u #{tmpuser}"
+ run_cron_on(host, :remove, tmpuser)
step "remove the user from the system"
apply_manifest_on host, delete_user
diff --git a/acceptance/tests/resource/cron/should_remove_cron.rb b/acceptance/tests/resource/cron/should_remove_cron.rb
index 035a0f7b9..9956d0d71 100755
--- a/acceptance/tests/resource/cron/should_remove_cron.rb
+++ b/acceptance/tests/resource/cron/should_remove_cron.rb
@@ -1,6 +1,6 @@
test_name "puppet should remove a crontab entry as expected"
-tmpuser = "cron-test-#{Time.new.to_i}"
+tmpuser = "pl#{rand(999999).to_i}"
tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
create_user = "user { '#{tmpuser}': ensure => present, managehome => false }"
@@ -11,7 +11,7 @@ agents.each do |host|
apply_manifest_on host, create_user
step "create the existing job by hand..."
- on host, "printf '# Puppet Name: crontest\n* * * * * /bin/true\n' | crontab -u #{tmpuser} -"
+ run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
step "apply the resource on the host using puppet resource"
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
@@ -23,13 +23,13 @@ agents.each do |host|
end
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
- fail_test "didn't found the command we tried to remove" if
- stdout.include? "/bin/true"
+ run_cron_on(host, :list, tmpuser) do
+ fail_test "didn't found the command we tried to remove" if
+ stdout.include? "/bin/true"
end
step "remove the crontab file for that user"
- on host, "crontab -r -u #{tmpuser}"
+ run_cron_on(host, :remove, tmpuser)
step "remove the user from the system"
apply_manifest_on host, delete_user
diff --git a/acceptance/tests/resource/cron/should_remove_matching.rb b/acceptance/tests/resource/cron/should_remove_matching.rb
index e669f2959..f4de0de0c 100755
--- a/acceptance/tests/resource/cron/should_remove_matching.rb
+++ b/acceptance/tests/resource/cron/should_remove_matching.rb
@@ -1,6 +1,6 @@
test_name "puppet should remove a crontab entry based on command matching"
-tmpuser = "cron-test-#{Time.new.to_i}"
+tmpuser = "pl#{rand(999999).to_i}"
tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
cron = '# Puppet Name: crontest\n* * * * * /bin/true\n1 1 1 1 1 /bin/true\n'
@@ -13,7 +13,7 @@ agents.each do |host|
apply_manifest_on host, create_user
step "create the existing job by hand..."
- on host, "printf '#{cron}' | crontab -u #{tmpuser} -"
+ run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
step "apply the resource change on the host"
on(host, puppet_resource("cron", "bogus", "user=#{tmpuser}",
@@ -23,13 +23,13 @@ agents.each do |host|
end
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
+ run_cron_on(host,:list,tmpuser) do
count = stdout.scan("/bin/true").length
fail_test "found /bin/true the wrong number of times (#{count})" unless count == 1
end
step "remove the crontab file for that user"
- on host, "crontab -r -u #{tmpuser}"
+ run_cron_on(host,:remove,tmpuser)
step "remove the user from the system"
apply_manifest_on host, delete_user
diff --git a/acceptance/tests/resource/cron/should_update_existing.rb b/acceptance/tests/resource/cron/should_update_existing.rb
index 3a2a53769..ff179307f 100755
--- a/acceptance/tests/resource/cron/should_update_existing.rb
+++ b/acceptance/tests/resource/cron/should_update_existing.rb
@@ -1,10 +1,8 @@
test_name "puppet should update existing crontab entry"
-tmpuser = "cron-test-#{Time.new.to_i}"
+tmpuser = "pl#{rand(999999).to_i}"
tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
-cron = '# Puppet Name: crontest\n* * * * * /bin/true\n'
-
create_user = "user { '#{tmpuser}': ensure => present, managehome => false }"
delete_user = "user { '#{tmpuser}': ensure => absent, managehome => false }"
@@ -13,10 +11,10 @@ agents.each do |host|
apply_manifest_on host, create_user
step "create the existing job by hand..."
- on host, "printf '#{cron}' | crontab -u #{tmpuser} -"
+ run_cron_on(host,:add,tmpuser,"* * * * * /bin/true")
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
+ run_cron_on(host,:list,tmpuser) do
fail_test "didn't find the content in the crontab" unless
stdout.include? '* * * * * /bin/true'
end
@@ -25,17 +23,17 @@ agents.each do |host|
on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}",
"command=/bin/true", "ensure=present", "hour='0-6'")) do
fail_test "didn't update the time as expected" unless
- stdout.include? "defined 'hour' as '0-6'"
+ stdout.include? "hour => ['0-6']"
end
step "verify that crontab -l contains what you expected"
- on host, "crontab -l -u #{tmpuser}" do
+ run_cron_on(host,:list,tmpuser) do
fail_test "didn't find the content in the crontab" unless
stdout.include? '* 0-6 * * * /bin/true'
end
step "remove the crontab file for that user"
- on host, "crontab -r -u #{tmpuser}"
+ run_cron_on(host,:remove,tmpuser)
step "remove the user from the system"
apply_manifest_on host, delete_user