Skip to content

Commit

Permalink
Merge pull request redhat-openstack#229 from mhaskel/test
Browse files Browse the repository at this point in the history
merge 1.1.x into master
  • Loading branch information
cmurphy committed Sep 12, 2014
2 parents 84551cc + 1c44ec3 commit fdbeb1b
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 98 deletions.
59 changes: 32 additions & 27 deletions spec/acceptance/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,88 @@

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
}
Expand Down Expand Up @@ -124,18 +131,16 @@
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
}
Expand Down
83 changes: 43 additions & 40 deletions spec/acceptance/deprecation_warnings_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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
Expand All @@ -11,11 +12,11 @@

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
Expand All @@ -28,19 +29,19 @@
['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' }
Expand All @@ -51,19 +52,19 @@
['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' }
Expand All @@ -75,37 +76,39 @@
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
Expand All @@ -115,7 +118,7 @@
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' }
Expand All @@ -125,25 +128,25 @@

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
Expand All @@ -153,7 +156,7 @@
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
Expand All @@ -164,9 +167,9 @@

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',
}
Expand All @@ -178,9 +181,9 @@

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',
}
Expand All @@ -192,9 +195,9 @@

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',
}
Expand All @@ -206,9 +209,9 @@

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',
}
Expand Down
Loading

0 comments on commit fdbeb1b

Please sign in to comment.