Please review pull request #734: Update acceptance tests to use confine instead of skip_test loops opened by (mkincaid)

Description:

Now that the test harness supports confine :except, :platform = 'windows' (and the like), update the tests to use that syntax.

This addresses the issue raised in pull request #651, where symbolic_modes.rb should not have been modified. (For whatever reason, that request didn't update when I pushed this update to my branch.)

  • Opened: Wed May 02 21:51:26 UTC 2012
  • Based on: puppetlabs:master (ba80b0e9fad27f2171b7f5e5db4253b89c70dc85)
  • Requested merge: mkincaid:confines (727a1567aae3577ee35669857ff663bb97864aaa)

Diff follows:

diff --git a/acceptance/tests/allow_symlinks_as_config_directories.rb b/acceptance/tests/allow_symlinks_as_config_directories.rb
index 1f450fe..c8c8bbb 100644
--- a/acceptance/tests/allow_symlinks_as_config_directories.rb
+++ b/acceptance/tests/allow_symlinks_as_config_directories.rb
@@ -1,11 +1,7 @@
 test_name "Should allow symlinks to directories as configuration directories"
+confine :except, :platform => 'windows'
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   step "Create the test confdir with a link to it"
   confdir = agent.tmpdir('puppet_conf-directory')
   conflink = agent.tmpfile('puppet_conf-symlink')
diff --git a/acceptance/tests/resource/cron/should_create_cron.rb b/acceptance/tests/resource/cron/should_create_cron.rb
index 6a1d5c0..92e9c6f 100644
--- a/acceptance/tests/resource/cron/should_create_cron.rb
+++ b/acceptance/tests/resource/cron/should_create_cron.rb
@@ -1,4 +1,5 @@
 test_name "should create cron"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -9,11 +10,6 @@
 package_cron = "case $operatingsystem { centos, redhat: {$cron = 'cronie'}\n default: {$cron ='cron'} } package {'cron': name=> $cron, ensure=>present, }"
 
 agents.each do |host|
-    if host['platform'].include?('windows')
-      skip_test "Test not supported on this platform"
-      next
-    end
-
     step "ensure the user exist via puppet"
     apply_manifest_on host, create_user
     apply_manifest_on host, package_cron
diff --git a/acceptance/tests/resource/cron/should_match_existing.rb b/acceptance/tests/resource/cron/should_match_existing.rb
index e6b5080..81b480f 100755
--- a/acceptance/tests/resource/cron/should_match_existing.rb
+++ b/acceptance/tests/resource/cron/should_match_existing.rb
@@ -1,4 +1,5 @@
 test_name "puppet should match existing job"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -9,11 +10,6 @@
 package_cron = "case $operatingsystem { centos, redhat: {$cron = 'cronie'}\n default: {$cron ='cron'} } package {'cron': name=> $cron, ensure=>present, }"
 
 agents.each do |host|
-    if host['platform'].include?('windows')
-      skip_test "Test not supported on this platform"
-      next
-    end
-
     step "ensure the user exist via puppet"
     apply_manifest_on host, create_user
     apply_manifest_on host, package_cron
diff --git a/acceptance/tests/resource/cron/should_not_rewrite_with_trailing_whitespace.rb b/acceptance/tests/resource/cron/should_not_rewrite_with_trailing_whitespace.rb
index 26fb87b..ce51ba6 100644
--- a/acceptance/tests/resource/cron/should_not_rewrite_with_trailing_whitespace.rb
+++ b/acceptance/tests/resource/cron/should_not_rewrite_with_trailing_whitespace.rb
@@ -1,4 +1,5 @@
 test_name "should not rewrite if the job has trailing whitespace"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -7,11 +8,6 @@
 delete_user = "user { '#{tmpuser}': ensure => absent,  managehome => false }"
 
 agents.each do |host|
-  if host['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   step "ensure the user exist via puppet"
   apply_manifest_on host, create_user
 
diff --git a/acceptance/tests/resource/cron/should_remove_cron.rb b/acceptance/tests/resource/cron/should_remove_cron.rb
index fa72f5a..760316a 100755
--- a/acceptance/tests/resource/cron/should_remove_cron.rb
+++ b/acceptance/tests/resource/cron/should_remove_cron.rb
@@ -1,4 +1,5 @@
 test_name "puppet should remove a crontab entry as expected"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -9,11 +10,6 @@
 package_cron = "case $operatingsystem { centos, redhat: {$cron = 'cronie'}\n default: {$cron ='cron'} } package {'cron': name=> $cron, ensure=>present, }"
 
 agents.each do |host|
-    if host['platform'].include?('windows')
-      skip_test "Test not supported on this platform"
-      next
-    end
-
     step "ensure the user exist via puppet"
     apply_manifest_on host, create_user
     apply_manifest_on host, package_cron
diff --git a/acceptance/tests/resource/cron/should_remove_matching.rb b/acceptance/tests/resource/cron/should_remove_matching.rb
index f480867..0b7115a 100755
--- a/acceptance/tests/resource/cron/should_remove_matching.rb
+++ b/acceptance/tests/resource/cron/should_remove_matching.rb
@@ -1,4 +1,5 @@
 test_name "puppet should remove a crontab entry based on command matching"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -11,11 +12,6 @@
 package_cron = "case $operatingsystem { centos, redhat: {$cron = 'cronie'}\n default: {$cron ='cron'} } package {'cron': name=> $cron, ensure=>present, }"
 
 agents.each do |host|
-    if host['platform'].include?('windows')
-      skip_test "Test not supported on this platform"
-      next
-    end
-
     step "ensure the user exist via puppet"
     apply_manifest_on host, create_user
     apply_manifest_on host, package_cron
diff --git a/acceptance/tests/resource/cron/should_update_existing.rb b/acceptance/tests/resource/cron/should_update_existing.rb
index 1bd69b8..2b4926a 100755
--- a/acceptance/tests/resource/cron/should_update_existing.rb
+++ b/acceptance/tests/resource/cron/should_update_existing.rb
@@ -1,4 +1,5 @@
 test_name "puppet should update existing crontab entry"
+confine :except, :platform => 'windows'
 
 tmpuser = "pl#{rand(999999).to_i}"
 tmpfile = "/tmp/cron-test-#{Time.new.to_i}"
@@ -9,11 +10,6 @@
 package_cron = "case $operatingsystem { centos, redhat: {$cron = 'cronie'}\n default: {$cron ='cron'} } package {'cron': name=> $cron, ensure=>present, }"
 
 agents.each do |host|
-    if host['platform'].include?('windows')
-      skip_test "Test not supported on this platform"
-      next
-    end
-
     step "ensure the user exist via puppet"
     apply_manifest_on host, create_user
     apply_manifest_on host, package_cron
diff --git a/acceptance/tests/resource/exec/accept_multi-line_commands.rb b/acceptance/tests/resource/exec/accept_multi-line_commands.rb
index dafd86c..443c7d2 100644
--- a/acceptance/tests/resource/exec/accept_multi-line_commands.rb
+++ b/acceptance/tests/resource/exec/accept_multi-line_commands.rb
@@ -1,11 +1,7 @@
 test_name "Be able to execute multi-line commands (#9996)"
+confine :except, :platform => 'windows'
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   temp_file_name = agent.tmpfile('9996-multi-line-commands')
 
   test_manifest = <<HERE
diff --git a/acceptance/tests/resource/file/should_create_symlink.rb b/acceptance/tests/resource/file/should_create_symlink.rb
index 0721bb2..7889f62 100755
--- a/acceptance/tests/resource/file/should_create_symlink.rb
+++ b/acceptance/tests/resource/file/should_create_symlink.rb
@@ -1,15 +1,11 @@
 test_name "should create symlink"
+confine :except, :platform => 'windows'
 
 message = 'hello world'
 target  = "/tmp/test-#{Time.new.to_i}"
 source  = "/tmp/test-#{Time.new.to_i}-source"
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   step "clean up the system before we begin"
   on agent, "rm -rf #{target}"
   on agent, "echo '#{message}' > #{source}"
diff --git a/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb b/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb
index 6cef569..440389e 100644
--- a/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb
+++ b/acceptance/tests/resource/file/ticket_8740_should_not_enumerate_root_directory.rb
@@ -1,13 +1,9 @@
 test_name "#8740: should not enumerate root directory"
+confine :except, :platform => 'windows'
 
 target = "/test-socket-#{$$}"
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   step "clean up the system before we begin"
   on(agent, "rm -f #{target}")
 
diff --git a/acceptance/tests/resource/group/should_modify_gid.rb b/acceptance/tests/resource/group/should_modify_gid.rb
index 65e9a1f..43ba6fa 100755
--- a/acceptance/tests/resource/group/should_modify_gid.rb
+++ b/acceptance/tests/resource/group/should_modify_gid.rb
@@ -1,15 +1,11 @@
 test_name "should modify gid of existing group"
+confine :except, :platform => 'windows'
 
 name = "pl#{rand(999999).to_i}"
 gid1  = rand(999999).to_i
 gid2  = rand(999999).to_i
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   step "ensure that the group exists with gid #{gid1}"
   on(agent, puppet_resource('group', name, 'ensure=present', "gid=#{gid1}")) do
     fail_test "missing gid notice" unless stdout =~ /gid +=> +'#{gid1}'/
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 0644247..20a1203 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
@@ -2,11 +2,8 @@
 step "Validate services running agreement ralsh vs. OS service count"
 # This will remotely exec:
 # ticket_4123_should_list_all_running_redhat.sh
+confine :to, :platform => /el-/
 
 hosts.each do |host|
-  if host['platform'].include?('el-')
-    run_script_on(host, File.join(File.dirname(__FILE__), 'ticket_4123_should_list_all_running_redhat.sh'))
-  else
-    skip_test "Test not supported on this plaform" 
-  end
+  run_script_on(host, File.join(File.dirname(__FILE__), 'ticket_4123_should_list_all_running_redhat.sh'))
 end
diff --git a/acceptance/tests/resource/service/ticket_4124_should_list_all_disabled.rb b/acceptance/tests/resource/service/ticket_4124_should_list_all_disabled.rb
index 7ba3c1a..b502f3d 100755
--- a/acceptance/tests/resource/service/ticket_4124_should_list_all_disabled.rb
+++ b/acceptance/tests/resource/service/ticket_4124_should_list_all_disabled.rb
@@ -2,11 +2,8 @@
 step "Validate disabled services agreement ralsh vs. OS service count"
 # This will remotely exec:
 # ticket_4124_should_list_all_disabled.sh
+confine :to, :platform => /el-/
 
 hosts.each do |host|
-  unless host['platform'].include?('el-')
-    skip_test "Test not supported on this plaform"
-   else
-    run_script_on(host, File.join(File.dirname(__FILE__), 'ticket_4124_should_list_all_disabled.sh'))
-  end
+  run_script_on(host, File.join(File.dirname(__FILE__), 'ticket_4124_should_list_all_disabled.sh'))
 end
diff --git a/acceptance/tests/resource/user/should_create_with_gid.rb b/acceptance/tests/resource/user/should_create_with_gid.rb
index 0b9f00d..1cafe8f 100755
--- a/acceptance/tests/resource/user/should_create_with_gid.rb
+++ b/acceptance/tests/resource/user/should_create_with_gid.rb
@@ -1,34 +1,31 @@
 test_name "verifies that puppet resource creates a user and assigns the correct group"
+confine :except, :platform => 'windows'
 
 user = "pl#{rand(999999).to_i}"
 group = "gp#{rand(999999).to_i}"
 
 agents.each do |host|
-  if host['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-  else
-    step "user should not exist"
-    on host, "if getent passwd #{user}; then userdel #{user}; fi"
+  step "user should not exist"
+  on host, "if getent passwd #{user}; then userdel #{user}; fi"
 
-    step "group should exist"
-    on host, "getent group #{group} || groupadd #{group}"
+  step "group should exist"
+  on host, "getent group #{group} || groupadd #{group}"
 
-    step "create user with group"
-    on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group}"))
+  step "create user with group"
+  on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group}"))
 
-    step "verify the group exists and find the gid"
-    on(host, "getent group #{group}") do
-        gid = stdout.split(':')[2]
+  step "verify the group exists and find the gid"
+  on(host, "getent group #{group}") do
+      gid = stdout.split(':')[2]
 
-        step "verify that the user has that as their gid"
-        on(host, "getent passwd #{user}") do
-            got = stdout.split(':')[3]
-            fail_test "wanted gid #{gid} but found #{got}" unless gid == got
-        end
-    end
-
-    step "clean up after the test is done"
-    on(host, puppet_resource('user', user, 'ensure=absent'))
-    on(host, puppet_resource('group', group, 'ensure=absent'))
+      step "verify that the user has that as their gid"
+      on(host, "getent passwd #{user}") do
+          got = stdout.split(':')[3]
+          fail_test "wanted gid #{gid} but found #{got}" unless gid == got
+      end
   end
+
+  step "clean up after the test is done"
+  on(host, puppet_resource('user', user, 'ensure=absent'))
+  on(host, puppet_resource('group', group, 'ensure=absent'))
 end
diff --git a/acceptance/tests/resource/user/should_modify_gid.rb b/acceptance/tests/resource/user/should_modify_gid.rb
index 4c13dc4..850a3a7 100755
--- a/acceptance/tests/resource/user/should_modify_gid.rb
+++ b/acceptance/tests/resource/user/should_modify_gid.rb
@@ -1,45 +1,42 @@
 test_name "verify that we can modify the gid"
+confine :except, :platform => 'windows'
 
 user = "pl#{rand(99999).to_i}"
 group1 = "#{user}old"
 group2 = "#{user}new"
 
 agents.each do |host|
-  if host['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-  else
-    step "ensure that the groups both exist"
-    on(host, puppet_resource('group', group1, 'ensure=present'))
-    on(host, puppet_resource('group', group2, 'ensure=present'))
-
-    step "ensure the user exists and has the old group"
-    on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group1}"))
-
-    step "verify that the user has the correct gid"
-    on(host, "getent group #{group1}") do
-        gid = stdout.split(':')[2]
-        on(host, "getent passwd #{user}") do
-            got = stdout.split(':')[3]
-            fail_test "didn't have the expected old GID, but #{got}" unless got == gid
-        end
-    end
-
-    step "modify the GID of the user"
-    on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group2}"))
-
-
-    step "verify that the user has the updated gid"
-    on(host, "getent group #{group2}") do
-        gid = stdout.split(':')[2]
-        on(host, "getent passwd #{user}") do
-            got = stdout.split(':')[3]
-            fail_test "didn't have the expected old GID, but #{got}" unless got == gid
-        end
-    end
-
-    step "ensure that we remove the things we made"
-    on(host, puppet_resource('user',  user,   'ensure=absent'))
-    on(host, puppet_resource('group', group1, 'ensure=absent'))
-    on(host, puppet_resource('group', group2, 'ensure=absent'))
+  step "ensure that the groups both exist"
+  on(host, puppet_resource('group', group1, 'ensure=present'))
+  on(host, puppet_resource('group', group2, 'ensure=present'))
+
+  step "ensure the user exists and has the old group"
+  on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group1}"))
+
+  step "verify that the user has the correct gid"
+  on(host, "getent group #{group1}") do
+      gid = stdout.split(':')[2]
+      on(host, "getent passwd #{user}") do
+          got = stdout.split(':')[3]
+          fail_test "didn't have the expected old GID, but #{got}" unless got == gid
+      end
   end
+
+  step "modify the GID of the user"
+  on(host, puppet_resource('user', user, 'ensure=present', "gid=#{group2}"))
+
+
+  step "verify that the user has the updated gid"
+  on(host, "getent group #{group2}") do
+      gid = stdout.split(':')[2]
+      on(host, "getent passwd #{user}") do
+          got = stdout.split(':')[3]
+          fail_test "didn't have the expected old GID, but #{got}" unless got == gid
+      end
+  end
+
+  step "ensure that we remove the things we made"
+  on(host, puppet_resource('user',  user,   'ensure=absent'))
+  on(host, puppet_resource('group', group1, 'ensure=absent'))
+  on(host, puppet_resource('group', group2, 'ensure=absent'))
 end
diff --git a/acceptance/tests/ticket_3961_puppet_ca_should_produce_certs.rb b/acceptance/tests/ticket_3961_puppet_ca_should_produce_certs.rb
index 3f41aeb..09a0b5e 100644
--- a/acceptance/tests/ticket_3961_puppet_ca_should_produce_certs.rb
+++ b/acceptance/tests/ticket_3961_puppet_ca_should_produce_certs.rb
@@ -1,4 +1,5 @@
 test_name "#3961: puppet ca should produce certs spec"
+confine :except, :platform => 'windows'
 
 target  = "working3961.example.org"
 
@@ -9,11 +10,6 @@
           'notice: Removing file Puppet::SSL::CertificateRequest working3961.example.org']
 
 agents.each do |agent|
-  if agent['platform'].include?('windows')
-    skip_test "Test not supported on this platform"
-    next
-  end
-
   scratch = agent.tmpdir('puppet-ssl-3961')
   options = { :confdir => scratch, :vardir => scratch }
 

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to