From b94412afd6be6155b7384c37378d985826528670 Mon Sep 17 00:00:00 2001 From: Jorie Tappa Date: Thu, 23 Aug 2018 13:01:25 -0700 Subject: Fix acceptance tests --- spec/acceptance/nodesets/default.yml | 19 ++++++++++++ .../cron/should_allow_changing_parameters_spec.rb | 34 ++++++++++------------ .../resource/cron/should_be_idempotent_spec.rb | 10 +++---- .../tests/resource/cron/should_create_cron_spec.rb | 6 ++-- .../resource/cron/should_match_existing_spec.rb | 4 +-- .../tests/resource/cron/should_remove_cron_spec.rb | 8 ++--- ..._remove_leading_and_trailing_whitespace_spec.rb | 4 +-- .../resource/cron/should_remove_matching_spec.rb | 4 +-- .../resource/cron/should_update_existing_spec.rb | 4 +-- 9 files changed, 48 insertions(+), 45 deletions(-) create mode 100644 spec/acceptance/nodesets/default.yml (limited to 'spec/acceptance') diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000..2cd2823 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,19 @@ +--- +HOSTS: + centos7-64-1: + pe_dir: + pe_ver: + pe_upgrade_dir: + pe_upgrade_ver: + hypervisor: vmpooler + platform: centos-7-x86_64 + packaging_platform: el-7-x86_64 + template: centos-7-x86_64 + roles: + - agent + - default +CONFIG: + type: agent + nfs_server: none + consoleport: 443 + pooling_api: http://vmpooler.delivery.puppetlabs.net/ \ No newline at end of file diff --git a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb index 2ff0dc4..2df0ea2 100644 --- a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb @@ -1,19 +1,17 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when changing parameters' do +RSpec.context 'when changing parameters' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' - setup(agent) + setup agent end end after(:each) do compatible_agents.each do |agent| step 'Cron: cleanup' - clean(agent) + clean agent end end @@ -21,50 +19,50 @@ Rspec.context 'when changing parameters' do it "manages cron entries on #{agent}" do step 'Cron: basic - verify that it can be created' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/false", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{ensure: created}) + expect(@result.stdout).to match(%r{ensure: created}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{.bin.false}) + expect(@result.stdout).to match(%r{.bin.false}) end step 'Cron: allow changing command' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{command changed '.bin.false'.* to '.bin.true'}) + expect(@result.stdout).to match(%r{command changed '.bin.false'.* to '.bin.true'}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{1 . . . . .bin.true}) + expect(@result.stdout).to match(%r{1 . . . . .bin.true}) end step 'Cron: allow changing time' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "1", minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{hour: defined 'hour' as \['1'\]}) + expect(@result.stdout).to match(%r{hour: defined 'hour' as \['1'\]}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{1 1 . . . .bin.true}) + expect(@result.stdout).to match(%r{1 1 . . . .bin.true}) end step 'Cron: allow changing time(array)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["1","2"], minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{hour: hour changed \['1'\].* to \['1', '2'\]}) + expect(@result.stdout).to match(%r{hour: hour changed \['1'\].* to \['1', '2'\]}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{1 1,2 . . . .bin.true}) + expect(@result.stdout).to match(%r{1 1,2 . . . .bin.true}) end step 'Cron: allow changing time(array modification)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["3","2"], minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{hour: hour changed \['1', '2'\].* to \['3', '2'\]}) + expect(@result.stdout).to match(%r{hour: hour changed \['1', '2'\].* to \['3', '2'\]}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{1 3,2 . . . .bin.true}) + expect(@result.stdout).to match(%r{1 3,2 . . . .bin.true}) end step 'Cron: allow changing time(array modification to *)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => "*", ensure => present,}') do - expect(result.stdout).to match(%r{minute: undefined 'minute' from \['1'\]}) - expect(result.stdout).to match(%r{hour: undefined 'hour' from \['3', '2'\]}) + expect(@result.stdout).to match(%r{minute: undefined 'minute' from \['1'\]}) + expect(@result.stdout).to match(%r{hour: undefined 'hour' from \['3', '2'\]}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{\* \* . . . .bin.true}) + expect(@result.stdout).to match(%r{\* \* . . . .bin.true}) end end end diff --git a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb index 7d4d386..4bf515e 100644 --- a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when checking idempotency' do +RSpec.context 'when checking idempotency' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' @@ -21,15 +19,15 @@ Rspec.context 'when checking idempotency' do it "ensures idempotency on #{agent}" do step 'Cron: basic - verify that it can be created' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - expect(result.stdout).to match(%r{ensure: created}) + expect(@result.stdout).to match(%r{ensure: created}) end run_cron_on(agent, :list, 'tstuser') do - expect(result.stdout).to match(%r{. . . . . .bin.true}) + expect(@result.stdout).to match(%r{. . . . . .bin.true}) end step 'Cron: basic - should not create again' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - expect(result.stdout).not_to match(%r{ensure: created}) + expect(@result.stdout).not_to match(%r{ensure: created}) end end end diff --git a/spec/acceptance/tests/resource/cron/should_create_cron_spec.rb b/spec/acceptance/tests/resource/cron/should_create_cron_spec.rb index b1623a4..05ae5e5 100644 --- a/spec/acceptance/tests/resource/cron/should_create_cron_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_create_cron_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when creating cron' do +RSpec.context 'when creating cron' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' @@ -18,7 +16,7 @@ Rspec.context 'when creating cron' do end compatible_agents.each do |host| - it 'creates a cron' do + it 'creates a new cron job' do step 'apply the resource on the host using puppet resource' on(host, puppet_resource('cron', 'crontest', 'user=tstuser', 'command=/bin/true', 'ensure=present')) do expect(stdout).to match(%r{created}) diff --git a/spec/acceptance/tests/resource/cron/should_match_existing_spec.rb b/spec/acceptance/tests/resource/cron/should_match_existing_spec.rb index 8097714..ce25be7 100644 --- a/spec/acceptance/tests/resource/cron/should_match_existing_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_match_existing_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when matching cron' do +RSpec.context 'when matching cron' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' diff --git a/spec/acceptance/tests/resource/cron/should_remove_cron_spec.rb b/spec/acceptance/tests/resource/cron/should_remove_cron_spec.rb index 89190a5..d23cded 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_cron_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_cron_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when removing crontab' do +RSpec.context 'when removing crontab' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' @@ -28,9 +26,9 @@ Rspec.context 'when removing crontab' do expect(stdout).to match(%r{crontest\D+ensure:\s+removed}) end - step 'verify that crontab -l contains what you expected' + step ' contains what you expected' run_cron_on(host, :list, 'tstuser') do - expect(stderr).to match(%r{/bin/true}) + expect(stderr).not_to match(%r{/bin/true}) end end end diff --git a/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace_spec.rb b/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace_spec.rb index c840166..da04daa 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when stripping whitespace from cron jobs' do +RSpec.context 'when stripping whitespace from cron jobs' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' diff --git a/spec/acceptance/tests/resource/cron/should_remove_matching_spec.rb b/spec/acceptance/tests/resource/cron/should_remove_matching_spec.rb index 5a814ae..652d8c5 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_matching_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_matching_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when removing crontabs' do +RSpec.context 'when removing crontabs' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' diff --git a/spec/acceptance/tests/resource/cron/should_update_existing_spec.rb b/spec/acceptance/tests/resource/cron/should_update_existing_spec.rb index 9f0731b..3b226e7 100644 --- a/spec/acceptance/tests/resource/cron/should_update_existing_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_update_existing_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' -require 'puppet/acceptance/common_utils' -extend Puppet::Acceptance::CronUtils -Rspec.context 'when updating cron jobs' do +RSpec.context 'when updating cron jobs' do before(:each) do compatible_agents.each do |agent| step 'ensure the user exists via puppet' -- cgit v1.2.3