diff options
| author | Jacob Helwig <jacob@puppetlabs.com> | 2011-06-28 17:40:53 -0700 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-06-28 17:40:53 -0700 |
| commit | 8432684e25cc82beb1f5d977dd509fd7bab3901b (patch) | |
| tree | 02d1bd4a254b1adf04ea574759dfa498c38c7863 /acceptance/tests | |
| parent | 1feaf7cf163c060eb213ce5f7a37faa0b7a4716f (diff) | |
| parent | 8bad457fb68f8550db4c1c4802cb024c4e719d33 (diff) | |
| download | puppet-8432684e25cc82beb1f5d977dd509fd7bab3901b.tar.gz puppet-8432684e25cc82beb1f5d977dd509fd7bab3901b.tar.xz puppet-8432684e25cc82beb1f5d977dd509fd7bab3901b.zip | |
Merge branch '2.6.x' into 2.7.x
* 2.6.x:
(#7956) Porting cron tests
(#7956) Port resource acceptance tests
Readying for release of 2.6.9
(#6854) Update Red Hat spec file
Bumping release in lib/puppet.rb and updating CHANGELOG.
Bumping RPM spec file to 2.6.9rc1.
(#7506) Organize READMEs; specify supported Ruby versions in README.md
(#6418) Make test 64118 more portable
(#7127) Stop puppet if a prerun command fails
Do not needlessly create multiple reports when creating a transaction
(#4416) Ensure types are providified after reloading
(#4416) Always remove old provider before recreating it
Cleanup indentation, comment, and unused code
Conflicts:
CHANGELOG
README.md
conf/redhat/puppet.spec
lib/puppet.rb
lib/puppet/transaction.rb
spec/unit/configurer_spec.rb
spec/unit/transaction_spec.rb
Diffstat (limited to 'acceptance/tests')
30 files changed, 145 insertions, 126 deletions
diff --git a/acceptance/tests/resource/cron/should_create_cron.rb b/acceptance/tests/resource/cron/should_create_cron.rb index e45561491..d40228070 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 }" @@ -13,18 +13,16 @@ agents.each do |host| step "apply the resource on the host using puppet resource" on(host, puppet_resource("cron", "crontest", "user=#{tmpuser}", "command=/bin/true", "ensure=present")) do - fail_test "didn't notice creation of the cron stuff" unless - stdout.include? 'created' + assert_match(/created/, stdout, "Did not create crontab for #{tmpuser} on #{host}") end step "verify that crontab -l contains what you expected" - on host, "crontab -l -u #{tmpuser}" do - fail_test "didn't find the command as expected" unless - stdout.include? "* * * * * /bin/true" + run_cron_on(host, :list, tmpuser) do + assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Incorrect crontab for #{tmpuser} on #{host}") 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..92e7dc2cc 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 }" @@ -10,30 +10,22 @@ agents.each do |host| step "ensure the user exist via puppet" apply_manifest_on host, create_user - step "create the existing job by hand..." - on host, "echo '* * * * * /bin/true' | crontab -u #{tmpuser} -" + step "Create the existing cron job by hand..." + run_cron_on(host,:add,tmpuser,"* * * * * /bin/true") - step "apply the resource on the host using puppet resource" + 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. - fail_test "didn't see the output we expected..." unless - stdout.include? 'present' + assert_match(/present/, stdout, "Failed creating crontab for #{tmpuser} on #{host}") end - step "verify that crontab -l contains what you expected" - on host, "crontab -l -u #{tmpuser}" do - fail_test "didn't find the command as expected" unless - stdout.include? "* * * * * /bin/true" + step "Verify that crontab -l contains what you expected" + run_cron_on(host, :list, tmpuser) do + assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Did not find crontab for #{tmpuser} on #{host}") 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..d6b8822d6 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,25 +11,21 @@ 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}", "command=/bin/true", "ensure=absent")) 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 - fail_test "didn't see the output we expected..." unless - stdout.include? 'removed' + assert_match(/crontest\D+ensure:\s+removed/, stdout, "Didn't remove crobtab entry for #{tmpuser} on #{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 + assert_match(/\/bin\/true/, stdout, "Error: Found entry for #{tmpuser} on #{host}") 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..59042c7a8 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,23 +13,22 @@ 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" + step "Remove cron resource" on(host, puppet_resource("cron", "bogus", "user=#{tmpuser}", "command=/bin/true", "ensure=absent")) do - fail_test "didn't see the output we expected..." unless - stdout.include? 'removed' + assert_match(/bogus\D+ensure: removed/, stdout, "Removing cron entry failed for #{tmpuser} on #{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..b37952a63 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,29 +11,26 @@ 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 - fail_test "didn't find the content in the crontab" unless - stdout.include? '* * * * * /bin/true' + run_cron_on(host,:list,tmpuser) do + assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Didn't find correct crobtab entry for #{tmpuser} on #{host}") end step "apply the resource change on the 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'" + "command=/bin/true", "ensure=present", "hour='0-6'")) do + assert_match(/hour\s+=>\s+\['0-6'\]/, stdout, "Modifying cron entry failed for #{tmpuser} on #{host}") end step "verify that crontab -l contains what you expected" - on host, "crontab -l -u #{tmpuser}" do - fail_test "didn't find the content in the crontab" unless - stdout.include? '* 0-6 * * * /bin/true' + run_cron_on(host,:list,tmpuser) do + assert_match(/\* 0-6 \* \* \* \/bin\/true/, stdout, "Didn't find correctly modified time entry in crobtab entry for #{tmpuser} on #{host}") 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/file/content_attribute.rb b/acceptance/tests/resource/file/content_attribute.rb index 4458e07a4..31dbac151 100644 --- a/acceptance/tests/resource/file/content_attribute.rb +++ b/acceptance/tests/resource/file/content_attribute.rb @@ -1,25 +1,33 @@ -test_name "The content attribute" -pass_test "Pass forced pending test failure investigation" +test_name "Content Attribute" step "Ensure the test environment is clean" on agents, 'rm -f /tmp/content_file_test.txt' -step "When using raw content" +step "Content Attribute: using raw content" manifest = "file { '/tmp/content_file_test.txt': content => 'This is the test file content', ensure => present }" apply_manifest_on agents, manifest -on agents, 'test "$(cat /tmp/content_file_test.txt)" = "This is the test file content"' +agents.each do |host| + on host, "cat /tmp/content_file_test.txt" do + assert_match(/This is the test file content/, stdout, "File content not matched on #{host}") + end +end step "Ensure the test environment is clean" on agents, 'rm -f /tmp/content_file_test.txt' -step "When using a filebucket checksum from filebucket" - +step "Content Attribute: using a checksum from filebucket" on agents, "echo 'This is the checksum file contents' > /tmp/checksum_test_file.txt" -on agents, "puppet filebucket backup --local /tmp/checksum_test_file.txt" +step "Backup file into the filebucket" +on agents, puppet_filebucket("backup --local /tmp/checksum_test_file.txt") + +agents.each do |agent| + bucketdir="not set" + on agent, puppet_filebucket("--configprint bucketdir") do + bucketdir = stdout.chomp + end -get_remote_option(agents, 'filebucket', 'bucketdir') do |bucketdir| manifest = %Q| filebucket { 'local': path => '#{bucketdir}', @@ -31,7 +39,14 @@ get_remote_option(agents, 'filebucket', 'bucketdir') do |bucketdir| backup => local, } | - apply_manifest_on agents, manifest + + step "Applying Manifest on Agents" + apply_manifest_on agent, manifest end -on agents, 'test "$(cat /tmp/content_file_test.txt)" = "This is the checksum file contents"' +step "Validate filebucket checksum file contents" +agents.each do |host| + on host, "cat /tmp/content_file_test.txt" do + assert_match(/This is the checksum file content/, stdout, "File content not matched on #{host}") + end +end diff --git a/acceptance/tests/resource/file/should_create_directory.rb b/acceptance/tests/resource/file/should_create_directory.rb index 859ebb3ba..37ad9dbf8 100755 --- a/acceptance/tests/resource/file/should_create_directory.rb +++ b/acceptance/tests/resource/file/should_create_directory.rb @@ -3,7 +3,7 @@ test_name "should create directory" target = "/tmp/test-#{Time.new.to_i}" step "clean up the system before we begin" -on agents, "rm -vrf #{target}" +on agents, "rm -rf #{target}" step "verify we can create a directory" on(agents, puppet_resource("file", target, 'ensure=directory')) @@ -12,4 +12,4 @@ step "verify the directory was created" on agents, "test -d #{target}" step "clean up after the test run" -on agents, "rm -vrf #{target}" +on agents, "rm -rf #{target}" diff --git a/acceptance/tests/resource/file/should_create_empty.rb b/acceptance/tests/resource/file/should_create_empty.rb index a38c35c2d..e9d9d8e27 100755 --- a/acceptance/tests/resource/file/should_create_empty.rb +++ b/acceptance/tests/resource/file/should_create_empty.rb @@ -3,13 +3,13 @@ test_name "should create empty file for 'present'" target = "/tmp/test-#{Time.new.to_i}" step "clean up the system before we begin" -on agents, "rm -vrf #{target}" +on agents, "rm -rf #{target}" step "verify we can create an empty file" on(agents, puppet_resource("file", target, 'ensure=present')) step "verify the target was created" -on agents, "test -f #{target} && ! test -s #{target}" +on agents, "test -f #{target} && test ! -s #{target}" step "clean up after the test run" -on agents, "rm -vrf #{target}" +on agents, "rm -rf #{target}" diff --git a/acceptance/tests/resource/file/should_create_symlink.rb b/acceptance/tests/resource/file/should_create_symlink.rb index 0e58d213b..81fe4b4e3 100755 --- a/acceptance/tests/resource/file/should_create_symlink.rb +++ b/acceptance/tests/resource/file/should_create_symlink.rb @@ -5,7 +5,7 @@ target = "/tmp/test-#{Time.new.to_i}" source = "/tmp/test-#{Time.new.to_i}-source" step "clean up the system before we begin" -on agents, "rm -vrf #{target}" +on agents, "rm -rf #{target}" on agents, "echo '#{message}' > #{source}" step "verify we can create a symlink" @@ -13,6 +13,7 @@ on(agents, puppet_resource("file", target, "ensure=#{source}")) step "verify the symlink was created" on agents, "test -L #{target} && test -f #{target}" +step "verify source file" on agents, "test -f #{source}" step "verify the content is identical on both sides" @@ -24,4 +25,4 @@ on(agents, "cat #{target}") do end step "clean up after the test run" -on agents, "rm -vrf #{target} #{source}" +on agents, "rm -rf #{target} #{source}" diff --git a/acceptance/tests/resource/file/should_remove_dir.rb b/acceptance/tests/resource/file/should_remove_dir.rb index 943410d20..36fa1adee 100755 --- a/acceptance/tests/resource/file/should_remove_dir.rb +++ b/acceptance/tests/resource/file/should_remove_dir.rb @@ -3,7 +3,7 @@ test_name "should remove directory, but force required" target = "/tmp/test-#{Time.new.to_i}" step "clean up the system before we begin" -on agents, "test -e #{target} && rm -vrf #{target} ; mkdir -p #{target}" +on agents, "rm -rf #{target} ; mkdir -p #{target}" step "verify we can't remove a directory without 'force'" on(agents, puppet_resource("file", target, 'ensure=absent')) do diff --git a/acceptance/tests/resource/file/should_remove_file.rb b/acceptance/tests/resource/file/should_remove_file.rb index 3ad7510ad..aadb82971 100755 --- a/acceptance/tests/resource/file/should_remove_file.rb +++ b/acceptance/tests/resource/file/should_remove_file.rb @@ -3,7 +3,7 @@ test_name "should remove file" target = "/tmp/test-#{Time.new.to_i}" step "clean up the system before we begin" -on agents, "rm -vrf #{target} && touch #{target}" +on agents, "rm -rf #{target} && touch #{target}" step "verify we can remove a file" on(agents, puppet_resource("file", target, 'ensure=absent')) diff --git a/acceptance/tests/resource/file/source_attribtute.rb b/acceptance/tests/resource/file/source_attribtute.rb index 95a7f36b3..3fa447a8a 100644 --- a/acceptance/tests/resource/file/source_attribtute.rb +++ b/acceptance/tests/resource/file/source_attribtute.rb @@ -4,35 +4,41 @@ step "Ensure the test environment is clean" on agents, 'rm -f /tmp/source_file_test.txt' # TODO: Add tests for puppet:// URIs with master/agent setups. -step "when using a puppet:/// URI with a master/agent setup" -step "when using a puppet://$server/ URI with a master/agent setup" - -step "when using a local file path" +# step "when using a puppet:/// URI with a master/agent setup" +# step "when using a puppet://$server/ URI with a master/agent setup" +step "Using a local file path" on agents, "echo 'Yay, this is the local file.' > /tmp/local_source_file_test.txt" - manifest = "file { '/tmp/source_file_test.txt': source => '/tmp/local_source_file_test.txt', ensure => present }" apply_manifest_on agents, manifest - -on agents, 'test "$(cat /tmp/source_file_test.txt)" = "Yay, this is the local file."' +agents.each do |host| + on host, "cat /tmp/source_file_test.txt" do + assert_match(/Yay, this is the local file./, stdout, "FIRST: File contents not matched on #{host}") + end +end step "Ensure the test environment is clean" on agents, 'rm -f /tmp/source_file_test.txt' -step "when using a puppet:/// URI with puppet apply" +step "Using a puppet:/// URI with puppet apply" -on agents, 'puppet agent --configprint modulepath' do +on agents, puppet_agent("--configprint modulepath") do modulepath = stdout.split(':')[0] modulepath = modulepath.chomp on agents, "mkdir -p #{modulepath}/test_module/files" - on agents, "echo 'Yay, this is the puppet:/// file.' > #{modulepath}/test_module/files/test_file.txt" + #on agents, "echo 'Yay, this is the puppet:/// file.' > #{modulepath}/test_module/files/test_file.txt" + on agents, "echo 'Yay, this is the puppetfile.' > #{modulepath}/test_module/files/test_file.txt" end on agents, %q{echo "file { '/tmp/source_file_test.txt': source => 'puppet:///modules/test_module/test_file.txt', ensure => present }" > /tmp/source_test_manifest.pp} -on agents, "puppet apply /tmp/source_test_manifest.pp" +on agents, puppet_apply("/tmp/source_test_manifest.pp") -on agents, 'test "$(cat /tmp/source_file_test.txt)" = "Yay, this is the puppet:/// file."' +agents.each do |host| + on host, "cat /tmp/source_file_test.txt" do + assert_match(/Yay, this is the puppetfile./, stdout, "SECOND: File contents not matched on #{host}") + end +end # Oops. We (Jesse & Jacob) ended up writing this before realizing that you # can't actually specify "source => 'http://...'". However, we're leaving it diff --git a/acceptance/tests/resource/group/should_create.rb b/acceptance/tests/resource/group/should_create.rb index 122c31a8f..efb80a4bc 100755 --- a/acceptance/tests/resource/group/should_create.rb +++ b/acceptance/tests/resource/group/should_create.rb @@ -1,6 +1,6 @@ test_name "should create group" -name = "test-group-#{Time.new.to_i}" +name = "pl#{rand(999999).to_i}" def cleanup(name) step "remove group #{name} if it exists" @@ -14,7 +14,7 @@ on(agents, puppet_resource('group', name, 'ensure=present')) step "verify the group #{name} was created" on(agents, "getent group #{name}") do - fail_test "group information is not sensible" unless stdout =~ /^#{name}:x:[0-9]+:/ + fail_test "group information is not sensible" unless stdout =~ /^#{name}:.*:[0-9]+:/ end cleanup(name) diff --git a/acceptance/tests/resource/group/should_modify_gid.rb b/acceptance/tests/resource/group/should_modify_gid.rb index 95405b24c..b54d40118 100755 --- a/acceptance/tests/resource/group/should_modify_gid.rb +++ b/acceptance/tests/resource/group/should_modify_gid.rb @@ -1,22 +1,23 @@ test_name "should modify gid of existing group" -name = "test-group-#{Time.new.to_i}" -gid = 12345 +name = "pl#{rand(999999).to_i}" +gid1 = rand(999999).to_i +gid2 = rand(999999).to_i -step "ensure that the group exists with gid #{gid}" -on(agents, puppet_resource('group', name, 'ensure=present', "gid=#{gid}")) do - fail_test "missing gid notice" unless stdout =~ /gid +=> +'#{gid}'/ +step "ensure that the group exists with gid #{gid1}" +on(agents, puppet_resource('group', name, 'ensure=present', "gid=#{gid1}")) do + fail_test "missing gid notice" unless stdout =~ /gid +=> +'#{gid1}'/ end -step "ensure that we can modify the GID of the group to #{gid*2}" -on(agents, puppet_resource('group', name, 'ensure=present', "gid=#{gid*2}")) do - fail_test "missing gid notice" unless stdout =~ /gid +=> +'#{gid*2}'/ +step "ensure that we can modify the GID of the group to #{gid2}" +on(agents, puppet_resource('group', name, 'ensure=present', "gid=#{gid2}")) do + fail_test "missing gid notice" unless stdout =~ /gid +=> +'#{gid2}'/ end step "verify that the GID changed" on(agents, "getent group #{name}") do fail_test "gid is wrong through getent output" unless - stdout =~ /^#{name}:x:#{gid*2}:/ + stdout =~ /^#{name}:.*:#{gid2}:/ end step "clean up the system after the test run" diff --git a/acceptance/tests/resource/host/should_create.rb b/acceptance/tests/resource/host/should_create.rb index d5bd9e6e7..f5c0a17a5 100755 --- a/acceptance/tests/resource/host/should_create.rb +++ b/acceptance/tests/resource/host/should_create.rb @@ -3,7 +3,7 @@ test_name "host should create" target = "/tmp/host-#{Time.new.to_i}" step "clean up for the test" -on agents, "rm -vf #{target}" +on agents, "rm -f #{target}" step "create the host record" on(agents, puppet_resource("host", "test", "ensure=present", diff --git a/acceptance/tests/resource/host/should_create_aliases.rb b/acceptance/tests/resource/host/should_create_aliases.rb index 4cc0014f6..71e92aef9 100755 --- a/acceptance/tests/resource/host/should_create_aliases.rb +++ b/acceptance/tests/resource/host/should_create_aliases.rb @@ -3,7 +3,7 @@ test_name "host should create aliases" target = "/tmp/host-#{Time.new.to_i}" step "clean up the system for testing" -on agents, "rm -vf #{target}" +on agents, "rm -f #{target}" step "create the record" on(agents, puppet_resource('host', 'test', "ensure=present", diff --git a/acceptance/tests/resource/host/should_destroy.rb b/acceptance/tests/resource/host/should_destroy.rb index 451b2d061..69c74b824 100755 --- a/acceptance/tests/resource/host/should_destroy.rb +++ b/acceptance/tests/resource/host/should_destroy.rb @@ -16,4 +16,4 @@ on(agents, "cat #{file}; rm -f #{file}") do end step "clean up after the test" -on agents, "rm -vf #{file}" +on agents, "rm -f #{file}" diff --git a/acceptance/tests/resource/host/should_modify_alias.rb b/acceptance/tests/resource/host/should_modify_alias.rb index 312078fef..1ebbf3339 100755 --- a/acceptance/tests/resource/host/should_modify_alias.rb +++ b/acceptance/tests/resource/host/should_modify_alias.rb @@ -16,4 +16,4 @@ on(agents, "cat #{file}; rm -f #{file}") do end step "clean up after the test" -on agents, "rm -vf #{file}" +on agents, "rm -f #{file}" diff --git a/acceptance/tests/resource/host/should_modify_ip.rb b/acceptance/tests/resource/host/should_modify_ip.rb index b16db5979..cf3c3f12d 100755 --- a/acceptance/tests/resource/host/should_modify_ip.rb +++ b/acceptance/tests/resource/host/should_modify_ip.rb @@ -16,4 +16,4 @@ on(agents, "cat #{file}; rm -f #{file}") do end step "clean up after the test" -on agents, "rm -vf #{file}" +on agents, "rm -f #{file}" diff --git a/acceptance/tests/resource/host/should_not_create_existing.rb b/acceptance/tests/resource/host/should_not_create_existing.rb index c8a40df93..a8f902286 100755 --- a/acceptance/tests/resource/host/should_not_create_existing.rb +++ b/acceptance/tests/resource/host/should_not_create_existing.rb @@ -13,5 +13,5 @@ on(agents, puppet_resource('host', 'test', "target=#{file}", end step "clean up after we created things" -on agents, "rm -vf #{file}" +on agents, "rm -f #{file}" diff --git a/acceptance/tests/resource/host/should_query.rb b/acceptance/tests/resource/host/should_query.rb index 983812ce0..76f84e498 100755 --- a/acceptance/tests/resource/host/should_query.rb +++ b/acceptance/tests/resource/host/should_query.rb @@ -12,4 +12,4 @@ on(agents, puppet_resource('host', 'localhost', "target=#{file}")) do end step "clean up the system" -on agents, "rm -vf #{file}" +on agents, "rm -f #{file}" diff --git a/acceptance/tests/resource/host/should_query_all.rb b/acceptance/tests/resource/host/should_query_all.rb index 654883aa0..bf1f1b89a 100755 --- a/acceptance/tests/resource/host/should_query_all.rb +++ b/acceptance/tests/resource/host/should_query_all.rb @@ -23,4 +23,4 @@ on(agents, puppet_resource('host')) do end step "clean up the system afterwards" -on agents, "mv -vf #{backup} /etc/hosts" +on agents, "mv -f #{backup} /etc/hosts" diff --git a/acceptance/tests/resource/service/ticket_4123_should_list_all_running_redhat.rb b/acceptance/tests/resource/service/ticket_4123_should_list_all_running_redhat.rb index 9bedd6e04..127e943a9 100755 --- a/acceptance/tests/resource/service/ticket_4123_should_list_all_running_redhat.rb +++ b/acceptance/tests/resource/service/ticket_4123_should_list_all_running_redhat.rb @@ -4,9 +4,10 @@ step "Validate services running agreement ralsh vs. OS service count" # ticket_4123_should_list_all_running_redhat.sh hosts.each do |host| - unless host['platform'].include? 'centos' or host['platform'].include? 'redhat' - skip_test "Test not supported on this plaform" - else + if host['platform'].include?('centos') or host['platform'].include?('redhat') + puts "XXX #{host['platform']}" run_script_on(host,'acceptance-tests/tests/resource/service/ticket_4123_should_list_all_running_redhat.sh') + else + skip_test "Test not supported on this plaform" end end diff --git a/acceptance/tests/resource/user/should_create.rb b/acceptance/tests/resource/user/should_create.rb index 062883da3..0b2b0c65f 100755 --- a/acceptance/tests/resource/user/should_create.rb +++ b/acceptance/tests/resource/user/should_create.rb @@ -1,9 +1,6 @@ test_name "should create a user, and the default matching group" -# REVISIT: This is a direct port of the original test, but it contains a -# non-portable assumption that "user private groups" are used by default by -# everything that we target. --daniel 2010-12-24 -name = "test-user-#{Time.new.to_i}" +name = "pl#{rand(999999).to_i}" step "ensure that the user and group #{name} do not exist" on agents, "if getent passwd #{name}; then userdel #{name}; fi" @@ -13,7 +10,14 @@ step "ask puppet to create the user" on(agents, puppet_resource('user', name, 'ensure=present')) step "verify that the user and group now exist" -on agents, "getent passwd #{name} && getent group #{name}" +agents.each do |agent| + if agent['platform'].include? 'sles' or agent['platform'].include? 'solaris' # no private user groups by default + on agent, "getent passwd #{name}" + else + on agent, "getent passwd #{name} && getent group #{name}" + end +end + step "ensure that the user and group #{name} do not exist" on agents, "if getent passwd #{name}; then userdel #{name}; fi" diff --git a/acceptance/tests/resource/user/should_create_with_gid.rb b/acceptance/tests/resource/user/should_create_with_gid.rb index be36bf4e6..c92d5c95d 100755 --- a/acceptance/tests/resource/user/should_create_with_gid.rb +++ b/acceptance/tests/resource/user/should_create_with_gid.rb @@ -1,14 +1,14 @@ test_name "verifies that puppet resource creates a user and assigns the correct group" -user = "test-user-#{Time.new.to_i}" -group = "test-user-#{Time.new.to_i}-group" +user = "pl#{rand(999999).to_i}" +group = "gp#{rand(999999).to_i}" agents.each do |host| step "user should not exist" on host, "if getent passwd #{user}; then userdel #{user}; fi" step "group should exist" - on host, "if ! getent group #{group}; then groupadd #{group}; fi" + on host, "getent group #{group} || groupadd #{group}" step "create user with group" on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group}")) diff --git a/acceptance/tests/resource/user/should_destroy.rb b/acceptance/tests/resource/user/should_destroy.rb index 8ba7ace41..655501231 100755 --- a/acceptance/tests/resource/user/should_destroy.rb +++ b/acceptance/tests/resource/user/should_destroy.rb @@ -1,6 +1,6 @@ test_name "verify that puppet resource correctly destroys users" -user = "test-user-#{Time.new.to_i}" +user = "pl#{rand(999999).to_i}" group = user step "ensure that the user and associated group exist" diff --git a/acceptance/tests/resource/user/should_modify_gid.rb b/acceptance/tests/resource/user/should_modify_gid.rb index 6aba4aa7a..d8bc60fc1 100755 --- a/acceptance/tests/resource/user/should_modify_gid.rb +++ b/acceptance/tests/resource/user/should_modify_gid.rb @@ -1,8 +1,8 @@ test_name "verify that we can modify the gid" -user = "test-user-#{Time.new.to_i}" -group1 = "#{user}-old" -group2 = "#{user}-new" +user = "pl#{rand(99999).to_i}" +group1 = "#{user}old" +group2 = "#{user}new" agents.each do |host| step "ensure that the groups both exist" diff --git a/acceptance/tests/resource/user/should_not_destoy_unexisting.rb b/acceptance/tests/resource/user/should_not_destoy_unexisting.rb index ceeea7da1..133d51395 100755 --- a/acceptance/tests/resource/user/should_not_destoy_unexisting.rb +++ b/acceptance/tests/resource/user/should_not_destoy_unexisting.rb @@ -1,6 +1,6 @@ test_name "ensure that puppet does not report removing a user that does not exist" -name = "test-user-#{Time.new.to_i}" +name = "pl#{rand(999999).to_i}" step "verify that user #{name} does not exist" on agents, "getent passwd #{name}", :acceptable_exit_codes => [2] diff --git a/acceptance/tests/resource/user/should_query.rb b/acceptance/tests/resource/user/should_query.rb index 6e2df534d..c976c878f 100755 --- a/acceptance/tests/resource/user/should_query.rb +++ b/acceptance/tests/resource/user/should_query.rb @@ -1,6 +1,6 @@ test_name "test that we can query and find a user that exists." -name = "test-user-#{Time.new.to_i}" +name = "pl#{rand(999999).to_i}" step "ensure that our test user exists" on(agents, puppet_resource('user', name, 'ensure=present')) diff --git a/acceptance/tests/ticket_6418_file_recursion_and_audit.rb b/acceptance/tests/ticket_6418_file_recursion_and_audit.rb index f0a55d029..b21e57ddb 100644 --- a/acceptance/tests/ticket_6418_file_recursion_and_audit.rb +++ b/acceptance/tests/ticket_6418_file_recursion_and_audit.rb @@ -2,11 +2,9 @@ # # AffectedVersion: 2.6.0-2.6.5 # FixedVersion: -# test_name "#6418: file recursion and audit" -on agents, "rm -f /var/lib/puppet/state/state.yaml " manifest = %q{ file { "/tmp/6418": ensure => directory } file { "/tmp/6418/dir": ensure => directory} @@ -17,6 +15,19 @@ manifest = %q{ File["/tmp/6418"] -> File["/tmp/6418/dir"] -> File["/tmp/6418/dir/dir"] -> File["/tmp/6418/dir/dir/dir"] -> File["/tmp/6418-copy"] } +step "Query agent for statefile" +agent=agents.first +on agent, puppet_agent('--configprint statefile') +statefile=stdout.chomp + +step "Remove the statefile on all Agents" +on agents, "rm -f #{statefile}" + step "Apply the manifest" apply_manifest_on agents, manifest -on agents, "! grep ensure.*directory /var/lib/puppet/state/state.yaml" + + +step "Verify corecct file recursion and audit state" +agents.each do |agent| + on(agent, "grep ensure.*directory #{statefile}", :acceptable_exit_codes => [ 1 ]) +end |
