2014-01-15 20:16:49 +01:00
|
|
|
require 'spec_helper_acceptance'
|
2013-08-08 17:44:31 +02:00
|
|
|
|
2014-06-11 23:25:08 +02:00
|
|
|
case fact('osfamily')
|
|
|
|
when 'AIX'
|
2014-09-11 18:18:05 +02:00
|
|
|
username = 'root'
|
|
|
|
groupname = 'system'
|
|
|
|
scriptname = 'concatfragments.sh'
|
2014-09-11 21:41:41 +02:00
|
|
|
vardir = default['puppetvardir']
|
2014-06-11 23:25:08 +02:00
|
|
|
when 'Darwin'
|
2014-09-11 18:18:05 +02:00
|
|
|
username = 'root'
|
|
|
|
groupname = 'wheel'
|
|
|
|
scriptname = 'concatfragments.sh'
|
2014-09-11 21:41:41 +02:00
|
|
|
vardir = default['puppetvardir']
|
2014-06-11 23:25:08 +02:00
|
|
|
when 'windows'
|
2014-09-11 18:18:05 +02:00
|
|
|
username = 'Administrator'
|
|
|
|
groupname = 'Administrators'
|
|
|
|
scriptname = 'concatfragments.rb'
|
2014-09-11 21:41:41 +02:00
|
|
|
result = on default, "echo #{default['puppetvardir']}"
|
|
|
|
vardir = result.raw_output.chomp
|
2014-09-11 19:56:55 +02:00
|
|
|
when 'Solaris'
|
2014-09-11 18:18:05 +02:00
|
|
|
username = 'root'
|
|
|
|
groupname = 'root'
|
|
|
|
scriptname = 'concatfragments.rb'
|
2014-09-11 21:41:41 +02:00
|
|
|
vardir = default['puppetvardir']
|
2014-06-11 23:25:08 +02:00
|
|
|
else
|
2014-09-11 18:18:05 +02:00
|
|
|
username = 'root'
|
|
|
|
groupname = 'root'
|
|
|
|
scriptname = 'concatfragments.sh'
|
2014-09-11 21:41:41 +02:00
|
|
|
vardir = default['puppetvardir']
|
2014-06-11 23:25:08 +02:00
|
|
|
end
|
|
|
|
|
2014-09-10 18:26:28 +02:00
|
|
|
describe 'basic concat test' do
|
2014-06-11 23:25:08 +02:00
|
|
|
basedir = default.tmpdir('concat')
|
2014-09-11 21:41:41 +02:00
|
|
|
safe_basedir = basedir.gsub(/[\/:]/,'_')
|
2013-08-08 17:44:31 +02:00
|
|
|
|
2013-11-02 02:20:41 +01:00
|
|
|
shared_examples 'successfully_applied' do |pp|
|
2014-01-15 20:16:49 +01:00
|
|
|
it 'applies the manifest twice with no stderr' do
|
2014-09-08 21:01:30 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
apply_manifest(pp, :catch_changes => true)
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
|
|
|
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 755
|
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/bin") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_directory }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 755
|
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/bin/#{scriptname}") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 755
|
|
|
|
}
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 750
|
|
|
|
}
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 750
|
|
|
|
}
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 640
|
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 640
|
|
|
|
}
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2013-10-30 05:44:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'owner/group root' do
|
2014-09-11 01:06:17 +02:00
|
|
|
before(:all) do
|
|
|
|
pp = <<-EOS
|
|
|
|
file { '#{basedir}':
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
apply_manifest(pp)
|
|
|
|
end
|
2013-11-14 04:28:27 +01:00
|
|
|
pp = <<-EOS
|
2014-06-11 23:25:08 +02:00
|
|
|
concat { '#{basedir}/file':
|
|
|
|
owner => '#{username}',
|
|
|
|
group => '#{groupname}',
|
2013-10-30 05:44:14 +01:00
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '1':
|
2014-06-11 23:25:08 +02:00
|
|
|
target => '#{basedir}/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '2':
|
2014-06-11 23:25:08 +02:00
|
|
|
target => '#{basedir}/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '2',
|
|
|
|
order => '02',
|
|
|
|
}
|
2013-11-14 04:28:27 +01:00
|
|
|
EOS
|
2013-10-30 05:44:14 +01:00
|
|
|
|
2013-11-02 02:20:41 +01:00
|
|
|
it_behaves_like 'successfully_applied', pp
|
|
|
|
|
2014-09-11 01:06:17 +02:00
|
|
|
describe file("#{basedir}/file") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-07 21:19:22 +02:00
|
|
|
it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-02-26 23:17:59 +01:00
|
|
|
should be_mode 644
|
2014-02-12 22:41:41 +01:00
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should contain '1' }
|
|
|
|
it { should contain '2' }
|
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 640
|
2014-02-26 23:17:59 +01:00
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
end
|
2014-09-11 21:41:41 +02:00
|
|
|
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
2014-06-11 23:25:08 +02:00
|
|
|
it { should be_owned_by username }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 640
|
2014-02-26 23:17:59 +01:00
|
|
|
}
|
2013-11-02 02:20:41 +01:00
|
|
|
end
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-01-21 22:28:42 +01:00
|
|
|
|
|
|
|
context 'ensure' do
|
|
|
|
context 'works when set to present with path set' do
|
2014-09-11 01:06:17 +02:00
|
|
|
before(:all) do
|
|
|
|
pp = <<-EOS
|
|
|
|
file { '#{basedir}':
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
apply_manifest(pp)
|
|
|
|
end
|
2014-01-21 22:28:42 +01:00
|
|
|
pp="
|
|
|
|
concat { 'file':
|
|
|
|
ensure => present,
|
2014-06-11 23:25:08 +02:00
|
|
|
path => '#{basedir}/file',
|
2014-01-21 22:28:42 +01:00
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
|
|
|
target => 'file',
|
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
it_behaves_like 'successfully_applied', pp
|
|
|
|
|
2014-09-11 01:06:17 +02:00
|
|
|
describe file("#{basedir}/file") do
|
2014-01-21 22:28:42 +01:00
|
|
|
it { should be_file }
|
2014-10-03 21:22:37 +02:00
|
|
|
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
|
2014-09-10 21:03:35 +02:00
|
|
|
should be_mode 644
|
|
|
|
}
|
2014-01-21 22:28:42 +01:00
|
|
|
it { should contain '1' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'works when set to absent with path set' do
|
2014-09-11 01:06:17 +02:00
|
|
|
before(:all) do
|
|
|
|
pp = <<-EOS
|
|
|
|
file { '#{basedir}':
|
|
|
|
ensure => directory,
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
apply_manifest(pp)
|
|
|
|
end
|
2014-01-21 22:28:42 +01:00
|
|
|
pp="
|
|
|
|
concat { 'file':
|
|
|
|
ensure => absent,
|
2014-06-11 23:25:08 +02:00
|
|
|
path => '#{basedir}/file',
|
2014-01-21 22:28:42 +01:00
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
|
|
|
target => 'file',
|
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
it 'applies the manifest twice with no stderr' do
|
2014-09-08 21:01:30 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
2014-06-11 23:25:08 +02:00
|
|
|
apply_manifest(pp, :catch_changes => true)
|
2014-01-21 22:28:42 +01:00
|
|
|
end
|
|
|
|
|
2014-09-11 01:06:17 +02:00
|
|
|
describe file("#{basedir}/file") do
|
2014-01-21 22:28:42 +01:00
|
|
|
it { should_not be_file }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|