Convert specs to beaker and increase coverage

This commit is contained in:
Hunter Haugen 2014-01-15 11:16:49 -08:00
parent 650a73244d
commit 20e8d6e4f6
27 changed files with 574 additions and 257 deletions

View file

@ -1,35 +0,0 @@
---
default_set: 'centos-64-x64'
sets:
'centos-59-x64':
nodes:
"main.foo.vm":
prefab: 'centos-59-x64'
'centos-64-x64':
nodes:
"main.foo.vm":
prefab: 'centos-64-x64'
'fedora-18-x64':
nodes:
"main.foo.vm":
prefab: 'fedora-18-x64'
'debian-607-x64':
nodes:
"main.foo.vm":
prefab: 'debian-607-x64'
'debian-70rc1-x64':
nodes:
"main.foo.vm":
prefab: 'debian-70rc1-x64'
'ubuntu-server-10044-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-10044-x64'
'ubuntu-server-12042-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-12042-x64'
'sles-11sp1-x64':
nodes:
"main.foo.vm":
prefab: 'sles-11sp1-x64'

View file

@ -4,10 +4,10 @@ group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :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 'serverspec', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'pry', :require => false
end

View file

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

View file

@ -0,0 +1,107 @@
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
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
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
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

@ -1,53 +1,50 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'basic concat test' do
shared_examples 'successfully_applied' do |pp|
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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('/var/lib/puppet/concat') do
describe file("#{default['puppetvardir']}/concat") do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 755 }
end
describe file('/var/lib/puppet/concat/bin') do
describe file("#{default['puppetvardir']}/concat/bin") do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 755 }
end
describe file('/var/lib/puppet/concat/bin/concatfragments.sh') do
describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do
it { should be_file }
it { should be_owned_by 'root' }
#it { should be_grouped_into 'root' }
it { should be_mode 755 }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file') do
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 750 }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments') do
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 750 }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat') do
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments.concat.out') do
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
@ -86,13 +83,13 @@ describe 'basic concat test' do
it { should contain '1' }
it { should contain '2' }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do
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 640 }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do
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' }
@ -105,6 +102,9 @@ describe 'basic concat test' 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':
@ -136,14 +136,14 @@ describe 'basic concat test' do
it { should contain '1' }
it { should contain '2' }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/01_1') do
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 640 }
it { should contain '1' }
end
describe file('/var/lib/puppet/concat/_tmp_concat_file/fragments/02_2') do
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' }

View file

@ -1,14 +1,11 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'deprecation warnings' do
shared_examples 'has_warning'do |pp, w|
context puppet_apply(pp) do
its(:stderr) { should =~ /#{Regexp.escape(w)}/m }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should =~ /#{Regexp.escape(w)}/m }
its(:exit_code) { should be_zero }
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
@ -104,40 +101,29 @@ describe 'deprecation warnings' do
it { should contain 'file1 contents' }
end
# check that the fragment can be changed from a symlink to a plain file
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
content => 'new content',
}
EOS
pp = <<-EOS
concat { '/tmp/concat/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
content => 'new content',
}
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
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new content' }
it { should_not contain 'file1 contents' }
describe file('/tmp/concat/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
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')
end
pp = <<-EOS
concat { '/tmp/concat/file': }
concat::fragment { 'foo':
@ -153,27 +139,24 @@ describe 'deprecation warnings' do
it { should be_file }
end
# check that the fragment can be changed from a symlink to a plain file
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
content => 'new content',
}
EOS
pp = <<-EOS
concat { '/tmp/concat/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
content => 'new content',
}
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
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new content' }
describe file('/tmp/concat/file') do
it { should be_file }
it { should contain 'new content' }
end
end
end # target file exists

View file

@ -1,6 +1,6 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'basic concat test' do
describe 'concat force empty parameter' do
context 'should run successfully' do
pp = <<-EOS
concat { '/tmp/concat/file':
@ -11,12 +11,9 @@ describe 'basic concat test' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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

View file

@ -1,4 +1,4 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'concat::fragment source' do
context 'should read file fragments from local system' do
@ -24,12 +24,9 @@ describe 'concat::fragment source' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -82,12 +79,9 @@ describe 'concat::fragment source' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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 }
@ -127,16 +121,14 @@ describe 'concat::fragment source' do
}
EOS
context puppet_apply(pp) do
its(:exit_code) { should_not be_zero }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
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 }
#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
end

View file

@ -0,0 +1,57 @@
require 'spec_helper_acceptance'
describe 'concat ensure_newline parameter' do
context '=> false' do
pp = <<-EOS
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
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, :catch_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,137 @@
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
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
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
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
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

@ -1,10 +1,10 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'replacement of' do
context 'file' do
context 'should not succeed' do
before(:all) do
shell('mkdir /tmp/concat')
shell('mkdir -p /tmp/concat')
shell('echo "file exists" > /tmp/concat/file')
end
after(:all) do
@ -27,12 +27,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -45,7 +42,7 @@ describe 'replacement of' do
context 'should succeed' do
before(:all) do
shell('mkdir /tmp/concat')
shell('mkdir -p /tmp/concat')
shell('echo "file exists" > /tmp/concat/file')
end
after(:all) do
@ -68,12 +65,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -91,7 +85,7 @@ describe 'replacement of' do
# 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 /tmp/concat')
shell('mkdir -p /tmp/concat')
shell('ln -s /tmp/concat/dangling /tmp/concat/file')
end
after(:all) do
@ -114,12 +108,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -138,7 +129,7 @@ describe 'replacement of' do
# 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 /tmp/concat')
shell('mkdir -p /tmp/concat')
shell('ln -s /tmp/concat/dangling /tmp/concat/file')
end
after(:all) do
@ -161,12 +152,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -200,12 +188,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should =~ /change from directory to file failed/ }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should =~ /change from directory to file failed/ }
its(:exit_code) { should_not == 1 }
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
@ -213,9 +198,11 @@ describe 'replacement of' do
end
end
# XXX concat's force param currently enables the creation of empty files when
# there are no fragments. The semantics either need to be changed, extended,
# or a new param introduced to control directory replacement.
# 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')
@ -240,12 +227,9 @@ describe 'replacement of' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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

View file

@ -1,4 +1,4 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'symbolic name' do
pp = <<-EOS
@ -19,12 +19,9 @@ describe 'symbolic name' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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

View file

@ -1,4 +1,4 @@
require 'spec_helper_system'
require 'spec_helper_acceptance'
describe 'concat warn =>' do
context 'true should enable default warning message' do
@ -20,12 +20,9 @@ describe 'concat warn =>' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -54,12 +51,9 @@ describe 'concat warn =>' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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
@ -88,12 +82,9 @@ describe 'concat warn =>' do
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
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

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

View file

@ -1,35 +0,0 @@
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
require 'rspec-system-serverspec/helpers'
include Serverspec::Helper::RSpecSystem
include Serverspec::Helper::DetectOS
include RSpecSystemPuppet::Helpers
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour
c.tty = true
c.include RSpecSystemPuppet::Helpers
# This is where we 'setup' the nodes before running our tests
c.before :suite do
# Install puppet
puppet_install
# Install modules and dependencies
puppet_module_install(:source => proj_root, :module_name => 'concat')
shell('puppet module install puppetlabs-stdlib')
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

View file

@ -1,13 +0,0 @@
require 'spec_helper_system'
# Here we put the more basic fundamental tests, ultra obvious stuff.
describe "basic tests:" do
context 'make sure we have copied the module across' do
# No point diagnosing any more if the module wasn't copied properly
context shell 'ls /etc/puppet/modules/concat' do
its(:stdout) { should =~ /Modulefile/ }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
end
end