aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb')
-rw-r--r--spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb29
1 files changed, 25 insertions, 4 deletions
diff --git a/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb b/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb
index 3e06d0c..1846523 100644
--- a/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb
+++ b/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb
@@ -1,12 +1,27 @@
require 'spec_helper_acceptance'
RSpec.context 'when Puppet cannot read a crontab file' do
+ # This test only makes sense for agents that shipped with PUP-9217's
+ # changes, so we do not want to run it on older agents.
+ def older_agent?(agent)
+ puppet_version = Gem::Version.new(on(agent, puppet('--version')).stdout.chomp)
+ minimum_puppet_version = if puppet_version < Gem::Version.new('6.0.0')
+ Gem::Version.new('5.5.9')
+ else
+ Gem::Version.new('6.0.5')
+ end
+
+ puppet_version < minimum_puppet_version
+ end
+
let(:username) { "pl#{rand(999_999).to_i}" }
let(:failed_username) { "pl#{rand(999_999).to_i}" }
before(:each) do
- step 'Create the users' do
- compatible_agents.each do |agent|
+ compatible_agents.each do |agent|
+ next if older_agent?(agent)
+
+ step "Create the users on #{agent}" do
user_present(agent, username)
user_present(agent, failed_username)
end
@@ -14,8 +29,10 @@ RSpec.context 'when Puppet cannot read a crontab file' do
end
after(:each) do
- step 'Teardown -- Erase the users' do
- compatible_agents.each do |agent|
+ compatible_agents.each do |agent|
+ next if older_agent?(agent)
+
+ step "Teardown -- Erase the users on #{agent}" do
run_cron_on(agent, :remove, username)
user_absent(agent, username)
@@ -26,6 +43,10 @@ RSpec.context 'when Puppet cannot read a crontab file' do
compatible_agents.each do |agent|
it "should only fail the associated resources on #{agent}" do
+ if older_agent?(agent)
+ skip('Skipping this test since we are on an older agent that does not have the PUP-9217 changes')
+ end
+
crontab_exe = nil
step 'Find the crontab executable' do
crontab_exe = on(agent, 'which crontab').stdout.chomp