diff --git a/acceptance/tests/resource/cron/should_create_cron.rb b/acceptance/tests/resource/cron/should_create_cron.rb index e455614913e..5badac05fed 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 @@ 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 b34a0498c63..b5c5d359d3a 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 @@ 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 @@ 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 035a0f7b9ff..9956d0d7155 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 @@ 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 @@ 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 e669f295928..f4de0de0c5b 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 @@ 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 @@ 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 3a2a5376970..ff179307f8d 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 @@ 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 @@ 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 diff --git a/acceptance/tests/resource/file/content_attribute.rb b/acceptance/tests/resource/file/content_attribute.rb index 4458e07a4da..31dbac1510b 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 @@ 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 859ebb3ba48..37ad9dbf821 100755 --- a/acceptance/tests/resource/file/should_create_directory.rb +++ b/acceptance/tests/resource/file/should_create_directory.rb @@ -3,7 +3,7 @@ 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 @@ 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 a38c35c2d85..e9d9d8e27f8 100755 --- a/acceptance/tests/resource/file/should_create_empty.rb +++ b/acceptance/tests/resource/file/should_create_empty.rb @@ -3,13 +3,13 @@ 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 0e58d213bb1..81fe4b4e3ba 100755 --- a/acceptance/tests/resource/file/should_create_symlink.rb +++ b/acceptance/tests/resource/file/should_create_symlink.rb @@ -5,7 +5,7 @@ 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 @@ 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 @@ 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 943410d203a..36fa1adee21 100755 --- a/acceptance/tests/resource/file/should_remove_dir.rb +++ b/acceptance/tests/resource/file/should_remove_dir.rb @@ -3,7 +3,7 @@ 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 3ad7510ade6..aadb8297139 100755 --- a/acceptance/tests/resource/file/should_remove_file.rb +++ b/acceptance/tests/resource/file/should_remove_file.rb @@ -3,7 +3,7 @@ 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 95a7f36b33e..3fa447a8a1b 100644 --- a/acceptance/tests/resource/file/source_attribtute.rb +++ b/acceptance/tests/resource/file/source_attribtute.rb @@ -4,35 +4,41 @@ 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 122c31a8f8a..efb80a4bc77 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 @@ def cleanup(name) 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 95405b24c75..b54d401186b 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 d5bd9e6e7d1..f5c0a17a5d7 100755 --- a/acceptance/tests/resource/host/should_create.rb +++ b/acceptance/tests/resource/host/should_create.rb @@ -3,7 +3,7 @@ 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 4cc0014f653..71e92aef905 100755 --- a/acceptance/tests/resource/host/should_create_aliases.rb +++ b/acceptance/tests/resource/host/should_create_aliases.rb @@ -3,7 +3,7 @@ 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 451b2d06169..69c74b82414 100755 --- a/acceptance/tests/resource/host/should_destroy.rb +++ b/acceptance/tests/resource/host/should_destroy.rb @@ -16,4 +16,4 @@ 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 312078fefbb..1ebbf3339db 100755 --- a/acceptance/tests/resource/host/should_modify_alias.rb +++ b/acceptance/tests/resource/host/should_modify_alias.rb @@ -16,4 +16,4 @@ 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 b16db597925..cf3c3f12db2 100755 --- a/acceptance/tests/resource/host/should_modify_ip.rb +++ b/acceptance/tests/resource/host/should_modify_ip.rb @@ -16,4 +16,4 @@ 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 c8a40df934c..a8f902286f9 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 @@ 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 983812ce034..76f84e49849 100755 --- a/acceptance/tests/resource/host/should_query.rb +++ b/acceptance/tests/resource/host/should_query.rb @@ -12,4 +12,4 @@ 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 654883aa0eb..bf1f1b89a57 100755 --- a/acceptance/tests/resource/host/should_query_all.rb +++ b/acceptance/tests/resource/host/should_query_all.rb @@ -23,4 +23,4 @@ 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 9bedd6e0478..127e943a981 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 @@ # 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 062883da356..0b2b0c65fe3 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 @@ 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 be36bf4e61e..c92d5c95dad 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 8ba7ace41ce..65550123178 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 6aba4aa7a21..d8bc60fc172 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 ceeea7da1c7..133d51395d8 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 6e2df534dbe..c976c878f76 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'))