Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the rspec-system tests over to beaker.
This converts over the spec tests to be beaker tests. It adds tests for all parameters that were untested previously.
- Loading branch information
Ashley Penney
committed
Dec 10, 2013
1 parent
eb02ba2
commit ff91686
Showing
21 changed files
with
381 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'rspec-system/rake_task' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'basic tests' do | ||
it 'copied the module' do | ||
shell('ls /etc/puppet/modules/ntp/Modulefile', {:acceptable_exit_codes => 0}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe "ntp class:" do | ||
it 'should run successfully' do | ||
pp = "class { 'ntp': }" | ||
|
||
# Apply twice to ensure no errors the second time. | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to eq("") | ||
end | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to eq("") | ||
expect(r.exit_code).to be_zero | ||
end | ||
end | ||
|
||
context 'service_ensure => stopped:' do | ||
it 'runs successfully' do | ||
pp = "class { 'ntp': service_ensure => stopped }" | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to eq("") | ||
end | ||
end | ||
end | ||
|
||
context 'service_ensure => running:' do | ||
it 'runs successfully' do | ||
pp = "class { 'ntp': service_ensure => running }" | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to eq("") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HOSTS: | ||
centos-64-x64.local: | ||
roles: | ||
- master | ||
platform: el-6-i386 | ||
box : centos-64-x64-vbox4210-nocm | ||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box | ||
hypervisor : vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
centos-64-x64.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HOSTS: | ||
ubuntu-server-12042-x64.local: | ||
roles: | ||
- master | ||
platform: ubuntu-server-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
case fact('osfamily') | ||
when 'FreeBSD' | ||
line = '0.freebsd.pool.ntp.org iburst maxpoll 9' | ||
when 'Debian' | ||
line = '0.debian.pool.ntp.org iburst' | ||
when 'RedHat' | ||
line = '0.centos.pool.ntp.org' | ||
when 'SuSE' | ||
line = '0.opensuse.pool.ntp.org' | ||
when 'Gentoo' | ||
line = '0.gentoo.pool.ntp.org' | ||
when 'Linux' | ||
case fact('operatingsystem') | ||
when 'ArchLinux' | ||
line = '0.pool.ntp.org' | ||
when 'Gentoo' | ||
line = '0.gentoo.pool.ntp.org' | ||
end | ||
end | ||
|
||
describe 'ntp::config class' do | ||
it 'sets up ntp.conf' do | ||
apply_manifest(%{ | ||
class { 'ntp': } | ||
}, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should be_file } | ||
it { should contain line } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
case fact('osfamily') | ||
when 'FreeBSD' | ||
packagename = 'net/ntp' | ||
when 'Gentoo' | ||
packagename = 'net-misc/ntp' | ||
when 'Linux' | ||
case fact('operatingsystem') | ||
when 'ArchLinux' | ||
packagename = 'ntp' | ||
when 'Gentoo' | ||
packagename = 'net-misc/ntp' | ||
end | ||
else | ||
packagename = 'ntp' | ||
end | ||
|
||
describe 'ntp::install class' do | ||
it 'installs the package' do | ||
apply_manifest(%{ | ||
class { 'ntp': } | ||
}, :catch_failures => true) | ||
end | ||
|
||
describe package(packagename) do | ||
it { should be_installed } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe "ntp class:" do | ||
it 'applies successfully' do | ||
pp = "class { 'ntp': }" | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to eq("") | ||
end | ||
end | ||
|
||
describe 'autoconfig' do | ||
it 'raises a deprecation warning' do | ||
pp = "class { 'ntp': autoupdate => true }" | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/autoupdate parameter has been deprecated and replaced with package_ensure/) | ||
end | ||
end | ||
end | ||
|
||
describe 'config' do | ||
it 'sets the ntp.conf location' do | ||
pp = "class { 'ntp': config => '/etc/antp.conf' }" | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/antp.conf') do | ||
it { should be_file } | ||
end | ||
end | ||
|
||
describe 'config_template' do | ||
it 'sets up template' do | ||
shell('mkdir -p /etc/puppet/modules/test/templates') | ||
shell('echo "testcontent" >> /etc/puppet/modules/test/templates/ntp.conf') | ||
end | ||
|
||
it 'sets the ntp.conf location' do | ||
pp = "class { 'ntp': config_template => 'test/ntp.conf' }" | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should be_file } | ||
it { should contain 'testcontent' } | ||
end | ||
end | ||
|
||
describe 'driftfile' do | ||
it 'sets the driftfile location' do | ||
pp = "class { 'ntp': driftfile => '/tmp/driftfile' }" | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should be_file } | ||
it { should contain 'driftfile /tmp/driftfile' } | ||
end | ||
end | ||
|
||
describe 'keys' do | ||
it 'enables the key parameters' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
keys_enable => true, | ||
keys_file => '/etc/ntp/keys', | ||
keys_controlkey => '/etc/ntp/controlkey', | ||
keys_requestkey => '/etc/ntp/requestkey', | ||
keys_trusted => [ '/etc/ntp/key1', '/etc/ntp/key2' ], | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should be_file } | ||
it { should contain 'keys /etc/ntp/keys' } | ||
it { should contain 'controlkey /etc/ntp/controlkey' } | ||
it { should contain 'requestkey /etc/ntp/requestkey' } | ||
it { should contain 'trustedkey /etc/ntp/key1 /etc/ntp/key2' } | ||
end | ||
end | ||
|
||
describe 'package' do | ||
it 'installs the right package' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
package_ensure => present, | ||
package_name => ['ntp'], | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe package('ntp') do | ||
it { should be_installed } | ||
end | ||
end | ||
|
||
describe 'panic => false' do | ||
it 'enables the tinker panic setting' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
panic => false, | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should contain 'tinker panic' } | ||
end | ||
end | ||
|
||
describe 'panic => true' do | ||
it 'disables the tinker panic setting' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
panic => true, | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should_not contain 'tinker panic 0' } | ||
end | ||
end | ||
|
||
describe 'udlc' do | ||
it 'adds a udlc' do | ||
pp = "class { 'ntp': udlc => true }" | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should be_file } | ||
it { should contain '127.127.1.0' } | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
case fact('osfamily') | ||
when 'RedHat', 'FreeBSD', 'Linux', 'Gentoo' | ||
servicename = 'ntpd' | ||
else | ||
servicename = 'ntp' | ||
end | ||
|
||
describe 'ntp::service class' do | ||
it 'sets up the service' do | ||
apply_manifest(%{ | ||
class { 'ntp': } | ||
}, :catch_failures => true) | ||
end | ||
|
||
describe service(servicename) do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
end | ||
|
||
describe 'service parameters' do | ||
it 'starts the service' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
service_enable => true, | ||
service_ensure => running, | ||
service_manage => true, | ||
service_name => '#{servicename}' | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe service(servicename) do | ||
it { should be_running } | ||
it { should be_enabled } | ||
end | ||
end | ||
|
||
describe 'service is unmanaged' do | ||
it 'shouldnt stop the service' do | ||
pp = <<-EOS | ||
class { 'ntp': | ||
service_enable => false, | ||
service_ensure => stopped, | ||
service_manage => false, | ||
service_name => '#{servicename}' | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe service(servicename) do | ||
it { should be_running } | ||
it { should be_enabled } | ||
end | ||
end |
12 changes: 8 additions & 4 deletions
12
spec/system/preferred_servers_spec.rb → spec/acceptance/preferred_servers_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe "ntp class with restrict:" do | ||
context 'should run successfully' do | ||
pp = "class { 'ntp': restrict => ['test restrict']}" | ||
|
||
it 'runs twice' do | ||
2.times do | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stderr).to be_empty | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe file('/etc/ntp.conf') do | ||
it { should contain('test restrict') } | ||
end | ||
|
||
end |
Oops, something went wrong.