diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 2b4fc91..e93ce10 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,209 +1,209 @@ require 'spec_helper_acceptance' case fact('osfamily') when 'AIX' username = 'root' groupname = 'system' scriptname = 'concatfragments.sh' when 'Darwin' username = 'root' groupname = 'wheel' scriptname = 'concatfragments.sh' when 'windows' username = 'Administrator' groupname = 'Administrators' scriptname = 'concatfragments.rb' -when 'solaris' +when 'Solaris' username = 'root' groupname = 'root' scriptname = 'concatfragments.rb' else username = 'root' groupname = 'root' scriptname = 'concatfragments.sh' end describe 'basic concat test' do basedir = default.tmpdir('concat') 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 it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/bin") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 755 } end describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } it("should be mode", :unless => (fact('osfamily') == 'AIX')) { should be_mode 750 } end describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } 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 it { should be_file } it { should be_owned_by username } 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 it { should be_file } it { should be_owned_by username } 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 it { should be_file } it { should be_owned_by username } 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/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 028901a..165c153 100644 --- a/spec/acceptance/quoted_paths_spec.rb +++ b/spec/acceptance/quoted_paths_spec.rb @@ -1,42 +1,44 @@ require 'spec_helper_acceptance' describe 'quoted paths' do basedir = default.tmpdir('concat') before(:all) do 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 { '#{basedir}/concat test/foo': } concat::fragment { '1': target => '#{basedir}/concat test/foo', content => 'string1', } concat::fragment { '2': 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("#{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/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 48306ee..b34a188 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,44 +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 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}", "#{host['distmoduledir']}/concat" + 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