diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 31c1647..10f72d9 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,210 +1,215 @@ require 'spec_helper_acceptance' case fact('osfamily') when 'AIX' - username = 'root' - groupname = 'system' + username = 'root' + groupname = 'system' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] when 'Darwin' - username = 'root' - groupname = 'wheel' + username = 'root' + groupname = 'wheel' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] when 'windows' - username = 'Administrator' - groupname = 'Administrators' + username = 'Administrator' + groupname = 'Administrators' + scriptname = 'concatfragments.rb' + result = on default, "echo #{default['puppetvardir']}" + vardir = result.raw_output.chomp +when 'Solaris' + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.rb' + vardir = default['puppetvardir'] else - username = 'root' - groupname = 'root' + username = 'root' + groupname = 'root' + scriptname = 'concatfragments.sh' + vardir = default['puppetvardir'] end describe 'basic concat test' do basedir = default.tmpdir('concat') - safe_basedir = basedir.gsub('/','_') + safe_basedir = basedir.gsub(/[\/:]/,'_') shared_examples 'successfully_applied' do |pp| it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - describe file("#{default['puppetvardir']}/concat") do + describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin") do + describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do + describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - #it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file") do + describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat.out") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end end context 'owner/group root' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': owner => '#{username}', group => '#{groupname}', mode => '0644', } concat::fragment { '1': target => '#{basedir}/file', content => '1', order => '01', } concat::fragment { '2': target => '#{basedir}/file', content => '2', order => '02', } EOS it_behaves_like 'successfully_applied', pp describe file("#{basedir}/file") do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 644 } it { should contain '1' } it { should contain '2' } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/01_1") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end - describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments/02_2") do + describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 640 } end end context 'ensure' do context 'works when set to present with path set' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } EOS apply_manifest(pp) end pp=" concat { 'file': ensure => present, path => '#{basedir}/file', mode => '0644', } concat::fragment { '1': target => 'file', content => '1', order => '01', } " it_behaves_like 'successfully_applied', pp describe file("#{basedir}/file") do it { should be_file } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 644 } it { should contain '1' } end end context 'works when set to absent with path set' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } EOS apply_manifest(pp) end pp=" concat { 'file': ensure => absent, path => '#{basedir}/file', mode => '0644', } concat::fragment { '1': target => 'file', content => '1', order => '01', } " it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should_not be_file } end end end end diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index 6f8fce1..7b0f5c5 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -1,230 +1,233 @@ require 'spec_helper_acceptance' describe 'deprecation warnings' do + basedir = default.tmpdir('concat') shared_examples 'has_warning'do |pp, w| it 'applies the manifest twice with a stderr regex' do expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) end end context 'concat gnu parameter' do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': gnu => 'foo', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS w = 'The $gnu parameter to concat is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat warn parameter =>' do ['true', 'yes', 'on'].each do |warn| context warn do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => '#{warn}', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain 'bar' } end end end ['false', 'no', 'off'].each do |warn| context warn do pp = <<-EOS - concat { '/tmp/concat/file': + concat { '#{basedir}/file': warn => '#{warn}', } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', } EOS w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } it { should contain 'bar' } end end end end context 'concat::fragment ensure parameter' do context 'target file exists' do before(:all) do - shell("/bin/echo 'file1 contents' > /tmp/concat/file1") - end - after(:all) do - # XXX this test may leave behind a symlink in the fragment directory - # which could cause warnings and/or breakage from the subsequent tests - # unless we clean it up. - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir -p /tmp/concat') + shell("/bin/echo 'file1 contents' > #{basedir}/file1") + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file1': + content => "file1 contents\n", + } + EOS + apply_manifest(pp) end pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - ensure => '/tmp/concat/file1', + target => '#{basedir}/file', + ensure => '#{basedir}/file1', } EOS w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'file1 contents' } end - describe 'the fragment can be changed from a symlink to a plain file' do + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new content', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new content' } it { should_not contain 'file1 contents' } end end end # target file exists context 'target does not exist' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', - ensure => '/tmp/concat/file1', + target => '#{basedir}/file', + ensure => '#{basedir}/file1', } EOS w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' it_behaves_like 'has_warning', pp, w - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } end - describe 'the fragment can be changed from a symlink to a plain file' do + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact('osfamily') == 'windows') do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'new content', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat/file') do + describe file("#{basedir}/file") do it { should be_file } it { should contain 'new content' } end end end # target file exists end # concat::fragment ensure parameter context 'concat::fragment mode parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', mode => 'bar', } EOS w = 'The $mode parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment owner parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', owner => 'bar', } EOS w = 'The $owner parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment group parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', group => 'bar', } EOS w = 'The $group parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'concat::fragment backup parameter' do pp = <<-EOS - concat { '/tmp/concat/file': } + concat { '#{basedir}/file': } concat::fragment { 'foo': - target => '/tmp/concat/file', + target => '#{basedir}/file', content => 'bar', backup => 'bar', } EOS w = 'The $backup parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end context 'include concat::setup' do pp = <<-EOS include concat::setup EOS w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.' it_behaves_like 'has_warning', pp, w end end diff --git a/spec/acceptance/fragments_are_always_replaced_spec.rb b/spec/acceptance/fragments_are_always_replaced_spec.rb index 2c999f7..ac714a9 100644 --- a/spec/acceptance/fragments_are_always_replaced_spec.rb +++ b/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -1,119 +1,133 @@ require 'spec_helper_acceptance' describe 'concat::fragment replace' do + basedir = default.tmpdir('concat') + context 'should create fragment files' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace unset run 1', } EOS pp2 = <<-EOS - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace unset run 2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp1, :catch_failures => true) apply_manifest(pp1, :catch_changes => true) apply_manifest(pp2, :catch_failures => true) apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace unset run 1' } it { should contain 'caller has replace unset run 2' } end end # should create fragment files context 'should replace its own fragment files when caller has File { replace=>true } set' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS File { replace=>true } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace true set run 1', } EOS pp2 = <<-EOS File { replace=>true } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace true set run 2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp1, :catch_failures => true) apply_manifest(pp1, :catch_changes => true) apply_manifest(pp2, :catch_failures => true) apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace true set run 1' } it { should contain 'caller has replace true set run 2' } end end # should replace its own fragment files when caller has File(replace=>true) set context 'should replace its own fragment files even when caller has File { replace=>false } set' do before(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') - shell('mkdir /tmp/concat') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + EOS + apply_manifest(pp) end pp1 = <<-EOS File { replace=>false } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace false set run 1', } EOS pp2 = <<-EOS File { replace=>false } - concat { '/tmp/concat/foo': } + concat { '#{basedir}/foo': } concat::fragment { '1': - target => '/tmp/concat/foo', + target => '#{basedir}/foo', content => 'caller has replace false set run 2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp1, :catch_failures => true) apply_manifest(pp1, :catch_changes => true) apply_manifest(pp2, :catch_failures => true) apply_manifest(pp2, :catch_changes => true) end - describe file('/tmp/concat/foo') do + describe file("#{basedir}/foo") do it { should be_file } it { should_not contain 'caller has replace false set run 1' } it { should contain 'caller has replace false set run 2' } end end # should replace its own fragment files even when caller has File(replace=>false) set end diff --git a/spec/acceptance/newline_spec.rb b/spec/acceptance/newline_spec.rb index 5554962..d182f2a 100644 --- a/spec/acceptance/newline_spec.rb +++ b/spec/acceptance/newline_spec.rb @@ -1,65 +1,67 @@ require 'spec_helper_acceptance' describe 'concat ensure_newline parameter' do basedir = default.tmpdir('concat') context '=> false' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': ensure_newline => false, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } it { should contain '12' } end end context '=> true' do pp = <<-EOS concat { '#{basedir}/file': ensure_newline => true, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } - it { should contain "1\n2\n" } + it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) { + should contain "1\n2\n" + } end end end diff --git a/spec/acceptance/quoted_paths_spec.rb b/spec/acceptance/quoted_paths_spec.rb index 0b6695d..165c153 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -1,33 +1,44 @@ require 'spec_helper_acceptance' describe 'quoted paths' do + basedir = default.tmpdir('concat') + before(:all) do - shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat') - shell('mkdir -p "/tmp/concat test"') + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/concat test': + ensure => directory, + } + EOS + apply_manifest(pp) end context 'path with blanks' do pp = <<-EOS - concat { '/tmp/concat test/foo': + concat { '#{basedir}/concat test/foo': } concat::fragment { '1': - target => '/tmp/concat test/foo', + target => '#{basedir}/concat test/foo', content => 'string1', } concat::fragment { '2': - target => '/tmp/concat test/foo', + target => '#{basedir}/concat test/foo', content => 'string2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - describe file('/tmp/concat test/foo') do + describe file("#{basedir}/concat test/foo") do it { should be_file } - it { should contain "string1\nsring2" } + it("should contain string1\nstring2", :unless => (fact('osfamily') == 'Solaris')) { + should contain "string1\nstring2" + } end end end diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index c200cb2..cc30d12 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -1,256 +1,256 @@ require 'spec_helper_acceptance' describe 'replacement of' do basedir = default.tmpdir('concat') context 'file' do context 'should not succeed' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } file { '#{basedir}/file': content => "file exists\n" } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': replace => false, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } it { should contain 'file exists' } it { should_not contain '1' } it { should_not contain '2' } end end context 'should succeed' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } file { '#{basedir}/file': content => "file exists\n" } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': replace => true, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } it { should_not contain 'file exists' } it { should contain '1' } it { should contain '2' } end end end # file - context 'symlink' do + context 'symlink', :unless => (fact("osfamily") == "windows") do context 'should not succeed' do # XXX the core puppet file type will replace a symlink with a plain file # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } file { '#{basedir}/file': ensure => link, target => '#{basedir}/dangling', } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': replace => false, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end # XXX specinfra doesn't support be_linked_to on AIX describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX") do it { should be_linked_to "#{basedir}/dangling" } end describe file("#{basedir}/dangling") do # XXX serverspec does not have a matcher for 'exists' it { should_not be_file } it { should_not be_directory } end end context 'should succeed' do # XXX the core puppet file type will replace a symlink with a plain file # when using ensure => present and source => ... but it will not when using # ensure => present and content => ...; this is somewhat confusing behavior before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } file { '#{basedir}/file': ensure => link, target => '#{basedir}/dangling', } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': replace => true, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } it { should contain '1' } it { should contain '2' } end end end # symlink context 'directory' do context 'should not succeed' do before(:all) do pp = <<-EOS file { '#{basedir}': ensure => directory, } file { '#{basedir}/file': ensure => directory, } EOS apply_manifest(pp) end pp = <<-EOS concat { '#{basedir}/file': } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with stderr for changing to file' do expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) end describe file("#{basedir}/file") do it { should be_directory } end end # XXX concat's force param currently enables the creation of empty files # when there are no fragments, and the replace param will only replace # files and symlinks, not directories. The semantics either need to be # changed, extended, or a new param introduced to control directory # replacement. context 'should succeed', :pending => 'not yet implemented' do pp = <<-EOS concat { '#{basedir}/file': force => true, } concat::fragment { '1': target => '#{basedir}/file', content => '1', } concat::fragment { '2': target => '#{basedir}/file', content => '2', } EOS it 'applies the manifest twice with no stderr' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("#{basedir}/file") do it { should be_file } it { should contain '1' } end end end # directory end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index e93a9f9..b34a188 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,40 +1,47 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' # This will install the latest available package on el and deb based # systems fail on windows and osx, and install via gem on other *nixes foss_opts = { :default_action => 'gem_install' } if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end hosts.each do |host| on hosts, "mkdir -p #{host['distmoduledir']}" end end RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'concat') hosts.each do |host| + on host, "mkdir -p #{host['distmoduledir']}/concat" + result = on host, "echo #{host['distmoduledir']}/concat" + target = result.raw_output.chomp + + %w(files lib manifests metadata.json).each do |file| + scp_to host, "#{proj_root}/#{file}", target + end + #copy_module_to(host, :source => proj_root, :module_name => 'concat') on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } end end c.before(:all) do shell('mkdir -p /tmp/concat') end c.after(:all) do shell('rm -rf /tmp/concat /var/lib/puppet/concat') end c.treat_symbols_as_metadata_keys_with_true_values = true end