Port over acceptance tests from master.

This commit is contained in:
Ashley Penney 2014-02-12 16:41:41 -05:00
parent ad57847f80
commit 596cec14be
23 changed files with 1126 additions and 4 deletions

View file

@ -1,13 +1,13 @@
source 'https://rubygems.org' source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do group :development, :test do
gem 'rake', :require => false gem 'rake', :require => false
gem 'rspec-puppet', :require => false gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system-puppet', :require => false gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'puppet-lint', :require => false gem 'puppet-lint', :require => false
gem 'serverspec', :require => false gem 'serverspec', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'pry', :require => false gem 'pry', :require => false
end end

View file

@ -1,2 +1,5 @@
require 'puppetlabs_spec_helper/rake_tasks' require 'puppetlabs_spec_helper/rake_tasks'
require 'rspec-system/rake_task' require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_quoted_booleans')

View file

@ -0,0 +1,110 @@
require 'spec_helper_acceptance'
describe 'concat backup parameter' do
context '=> puppet' do
before :all do
shell('mkdir -p /tmp/concat')
shell("/bin/echo 'old contents' > /tmp/concat/file")
end
after :all do
shell('rm -rf /tmp/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
backup => 'puppet',
}
concat::fragment { 'new file':
target => '/tmp/concat/file',
content => 'new contents',
}
EOS
it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).to eq("")
expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents'
end
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new contents' }
end
end
context '=> .backup' do
before :all do
shell('mkdir -p /tmp/concat')
shell("/bin/echo 'old contents' > /tmp/concat/file")
end
after :all do
shell('rm -rf /tmp/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
backup => '.backup',
}
concat::fragment { 'new file':
target => '/tmp/concat/file',
content => 'new contents',
}
EOS
# XXX Puppet doesn't mention anything about filebucketing with a given
# extension like .backup
it 'applies the manifest twice no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new contents' }
end
describe file('/tmp/concat/file.backup') do
it { should be_file }
it { should contain 'old contents' }
end
end
# XXX The backup parameter uses validate_string() and thus can't be the
# boolean false value, but the string 'false' has the same effect in Puppet 3
context "=> 'false'" do
before :all do
shell('mkdir -p /tmp/concat')
shell("/bin/echo 'old contents' > /tmp/concat/file")
end
after :all do
shell('rm -rf /tmp/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
backup => '.backup',
}
concat::fragment { 'new file':
target => '/tmp/concat/file',
content => 'new contents',
}
EOS
it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).to eq("")
expect(r.stdout).to_not match(/Filebucketed/)
end
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new contents' }
end
end
end

View file

@ -0,0 +1,12 @@
require 'spec_helper_acceptance'
# Here we put the more basic fundamental tests, ultra obvious stuff.
describe "basic tests:" do
it 'copies the module across' do
# No point diagnosing any more if the module wasn't copied properly
shell "ls #{default['distmoduledir']}/concat" do |r|
expect(r.stdout).to match(/Modulefile/)
expect(r.stderr).to be_empty
end
end
end

View file

@ -0,0 +1,112 @@
require 'spec_helper_acceptance'
describe 'basic concat test' do
shared_examples 'successfully_applied' do |pp|
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
end
context 'owner/group root' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
owner => 'root',
group => 'root',
mode => '0644',
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
EOS
it_behaves_like 'successfully_applied', pp
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
end
end
context 'owner/group non-root' do
before(:all) do
shell "groupadd -g 42 bob"
shell "useradd -u 42 -g 42 bob"
end
after(:all) do
shell "userdel bob"
end
pp="
concat { '/tmp/concat/file':
owner => 'bob',
group => 'bob',
mode => '0644',
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
"
it_behaves_like 'successfully_applied', pp
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'bob' }
it { should be_grouped_into 'bob' }
it { should be_mode 644 }
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '1' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '2' }
end
end
end

View file

@ -0,0 +1,24 @@
require 'spec_helper_acceptance'
describe 'concat force empty parameter' do
context 'should run successfully' do
pp = <<-EOS
concat { '/tmp/concat/file':
owner => root,
group => root,
mode => '0644',
force => true,
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should_not contain '1\n2' }
end
end
end

View file

@ -0,0 +1,137 @@
require 'spec_helper_acceptance'
describe 'concat::fragment source' do
context 'should read file fragments from local system' do
before(:all) do
shell("/bin/echo 'file1 contents' > /tmp/concat/file1")
shell("/bin/echo 'file2 contents' > /tmp/concat/file2")
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
source => '/tmp/concat/file1',
}
concat::fragment { '2':
target => '/tmp/concat/foo',
content => 'string1 contents',
}
concat::fragment { '3':
target => '/tmp/concat/foo',
source => '/tmp/concat/file2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/foo') do
it { should be_file }
it { should contain 'file1 contents' }
it { should contain 'string1 contents' }
it { should contain 'file2 contents' }
end
end # should read file fragments from local system
context 'should create files containing first match only.' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir -p /tmp/concat')
shell("/bin/echo 'file1 contents' > /tmp/concat/file1")
shell("/bin/echo 'file2 contents' > /tmp/concat/file2")
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/result_file1':
owner => root,
group => root,
mode => '0644',
}
concat { '/tmp/concat/result_file2':
owner => root,
group => root,
mode => '0644',
}
concat { '/tmp/concat/result_file3':
owner => root,
group => root,
mode => '0644',
}
concat::fragment { '1':
target => '/tmp/concat/result_file1',
source => [ '/tmp/concat/file1', '/tmp/concat/file2' ],
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/result_file2',
source => [ '/tmp/concat/file2', '/tmp/concat/file1' ],
order => '01',
}
concat::fragment { '3':
target => '/tmp/concat/result_file3',
source => [ '/tmp/concat/file1', '/tmp/concat/file2' ],
order => '01',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/result_file1') do
it { should be_file }
it { should contain 'file1 contents' }
it { should_not contain 'file2 contents' }
end
describe file('/tmp/concat/result_file2') do
it { should be_file }
it { should contain 'file2 contents' }
it { should_not contain 'file1 contents' }
end
describe file('/tmp/concat/result_file3') do
it { should be_file }
it { should contain 'file1 contents' }
it { should_not contain 'file2 contents' }
end
end
context 'should fail if no match on source.' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir -p /tmp/concat')
shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/fail_no_source':
owner => root,
group => root,
mode => '0644',
}
concat::fragment { '1':
target => '/tmp/concat/fail_no_source',
source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ],
order => '01',
}
EOS
it 'applies the manifest with resource failures' do
apply_manifest(pp, :expect_failures => true)
end
describe file('/tmp/concat/fail_no_source') do
#FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack.
it { should_not be_file }
it { should_not be_directory }
end
end
end

View file

@ -0,0 +1,59 @@
require 'spec_helper_acceptance'
describe 'concat ensure_newline parameter' do
context '=> false' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
ensure_newline => false,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain '12' }
end
end
context '=> true' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
ensure_newline => true,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :expect_changes => true).stderr).to eq("")
#XXX ensure_newline => true causes changes on every run because the files
#are modified in place.
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain "1\n2\n" }
end
end
end

View file

@ -0,0 +1,10 @@
HOSTS:
centos-59-x64:
roles:
- master
platform: el-5-x86_64
box : centos-59-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,12 @@
HOSTS:
centos-64-x64:
roles:
- master
- database
- dashboard
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: pe

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
debian-607-x64:
roles:
- master
platform: debian-6-amd64
box : debian-607-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
debian-70rc1-x64:
roles:
- master
platform: debian-7-amd64
box : debian-70rc1-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
fedora-18-x64:
roles:
- master
platform: fedora-18-x86_64
box : fedora-18-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
sles-11sp1-x64:
roles:
- master
platform: sles-11-x86_64
box : sles-11sp1-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-10044-x64:
roles:
- master
platform: ubuntu-10.04-amd64
box : ubuntu-server-10044-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-12.04-amd64
box : ubuntu-server-12042-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: git

View file

@ -0,0 +1,141 @@
require 'spec_helper_acceptance'
describe 'concat order' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir -p /tmp/concat')
end
context '=> alpha' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/foo':
order => 'alpha'
}
concat::fragment { '1':
target => '/tmp/concat/foo',
content => 'string1',
}
concat::fragment { '2':
target => '/tmp/concat/foo',
content => 'string2',
}
concat::fragment { '10':
target => '/tmp/concat/foo',
content => 'string10',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/foo') do
it { should be_file }
it { should contain "string10\nstring1\nsring2" }
end
end
context '=> numeric' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/foo':
order => 'numeric'
}
concat::fragment { '1':
target => '/tmp/concat/foo',
content => 'string1',
}
concat::fragment { '2':
target => '/tmp/concat/foo',
content => 'string2',
}
concat::fragment { '10':
target => '/tmp/concat/foo',
content => 'string10',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/foo') do
it { should be_file }
it { should contain "string1\nstring2\nsring10" }
end
end
end # concat order
describe 'concat::fragment order' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir -p /tmp/concat')
end
context '=> reverse order' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
content => 'string1',
order => '15',
}
concat::fragment { '2':
target => '/tmp/concat/foo',
content => 'string2',
# default order 10
}
concat::fragment { '3':
target => '/tmp/concat/foo',
content => 'string3',
order => '1',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/foo') do
it { should be_file }
it { should contain "string3\nstring2\nsring1" }
end
end
context '=> normal order' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
content => 'string1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/foo',
content => 'string2',
order => '02'
}
concat::fragment { '3':
target => '/tmp/concat/foo',
content => 'string3',
order => '03',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/foo') do
it { should be_file }
it { should contain "string1\nstring2\nsring3" }
end
end
end # concat::fragment order

View file

@ -0,0 +1,247 @@
require 'spec_helper_acceptance'
describe 'replacement of' do
context 'file' do
context 'should not succeed' do
before(:all) do
shell('mkdir -p /tmp/concat')
shell('echo "file exists" > /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
replace => false,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/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
shell('mkdir -p /tmp/concat')
shell('echo "file exists" > /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
replace => true,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/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 '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
shell('mkdir -p /tmp/concat')
shell('ln -s /tmp/concat/dangling /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
replace => false,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_linked_to '/tmp/concat/dangling' }
end
describe file('/tmp/concat/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
shell('mkdir -p /tmp/concat')
shell('ln -s /tmp/concat/dangling /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
replace => true,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/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
shell('mkdir -p /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file': }
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/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('/tmp/concat/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
before(:all) do
shell('mkdir -p /tmp/concat/file')
end
after(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
end
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
force => true,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain '1' }
end
end
end # directory
end

View file

@ -0,0 +1,33 @@
require 'spec_helper_acceptance'
describe 'symbolic name' do
pp = <<-EOS
include concat::setup
concat { 'not_abs_path':
path => '/tmp/concat/file',
}
concat::fragment { '1':
target => 'not_abs_path',
content => '1',
order => '01',
}
concat::fragment { '2':
target => 'not_abs_path',
content => '2',
order => '02',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain '1' }
it { should contain '2' }
end
end

View file

@ -0,0 +1,100 @@
require 'spec_helper_acceptance'
describe 'concat warn =>' do
context 'true should enable default warning message' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
warn => true,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain '1' }
it { should contain '2' }
end
end
context 'false should not enable default warning message' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
warn => false,
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain '1' }
it { should contain '2' }
end
end
context '# foo should overide default warning message' do
pp = <<-EOS
include concat::setup
concat { '/tmp/concat/file':
warn => '# foo',
}
concat::fragment { '1':
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '/tmp/concat/file',
content => '2',
order => '02',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain '# foo' }
it { should contain '1' }
it { should contain '2' }
end
end
end

View file

@ -0,0 +1,42 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
hosts.each do |host|
if host['platform'] =~ /debian/
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
end
if host.is_pe?
install_pe
else
# Install Puppet
install_package host, 'rubygems'
on host, 'gem install puppet --no-ri --no-rdoc'
on host, "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, 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