Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696972
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
23 KB
Subscribers
None
View Options
diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb
index 29231771..bc456e9e 100644
--- a/spec/acceptance/basic_spec.rb
+++ b/spec/acceptance/basic_spec.rb
@@ -1,16 +1,12 @@
require 'spec_helper_acceptance'
-describe 'basic tests:' do
- pp = 'notice("foo")'
- it { expect(apply_manifest(pp).exit_code).to eq(0) }
-end
-
describe 'disable selinux:' do
- pp = <<-EOS
- exec { "setenforce 0":
- path => "/bin:/sbin:/usr/bin:/usr/sbin",
- onlyif => "which setenforce && getenforce | grep Enforcing",
- }
- EOS
- it { expect(apply_manifest(pp).exit_code).to eq(0) }
+ it "because otherwise apache won't work" do
+ apply_manifest(%{
+ exec { "setenforce 0":
+ path => "/bin:/sbin:/usr/bin:/usr/sbin",
+ onlyif => "which setenforce && getenforce | grep Enforcing",
+ }
+ }, :catch_failures => true)
+ end
end
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb
index c22a0f32..62107ed6 100644
--- a/spec/acceptance/class_spec.rb
+++ b/spec/acceptance/class_spec.rb
@@ -1,59 +1,58 @@
require 'spec_helper_acceptance'
describe 'apache class' do
case fact('osfamily')
when 'RedHat'
package_name = 'httpd'
service_name = 'httpd'
when 'Debian'
package_name = 'apache2'
service_name = 'apache2'
when 'FreeBSD'
package_name = 'apache22'
service_name = 'apache22'
end
context 'default parameters' do
- # Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apache': }
EOS
# Run it twice and test for idempotency
- expect(apply_manifest(pp).exit_code).to_not eq(1)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
describe package(package_name) do
it { should be_installed }
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end
context 'custom site/mod dir parameters' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
file { '/apache': ensure => directory, }
class { 'apache':
mod_dir => '/apache/mods',
vhost_dir => '/apache/vhosts',
}
EOS
# Run it twice and test for idempotency
- expect(apply_manifest(pp).exit_code).to_not eq(1)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end
end
diff --git a/spec/acceptance/default_mods_spec.rb b/spec/acceptance/default_mods_spec.rb
index 8b88663b..df6463ec 100644
--- a/spec/acceptance/default_mods_spec.rb
+++ b/spec/acceptance/default_mods_spec.rb
@@ -1,93 +1,97 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'RedHat'
servicename = 'httpd'
when 'Debian'
servicename = 'apache2'
when 'FreeBSD'
servicename = 'apache22'
else
raise "Unconfigured OS for apache service on #{fact('osfamily')}"
end
describe 'apache::default_mods class' do
describe 'no default mods' do
# Using puppet_apply as a helper
it 'should apply with no errors' do
pp = <<-EOS
class { 'apache':
default_mods => false,
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
describe service(servicename) do
it { should be_running }
end
end
describe 'no default mods and failing' do
# Using puppet_apply as a helper
it 'should apply with errors' do
pp = <<-EOS
class { 'apache':
default_mods => false,
}
apache::vhost { 'defaults.example.com':
docroot => '/var/www/defaults',
aliases => {
alias => '/css',
path => '/var/www/css',
},
setenv => 'TEST1 one',
}
EOS
- apply_manifest(pp, { :acceptable_exit_codes => [4,6], :catch_failures => true })
+ apply_manifest(pp, { :expect_failures => true })
end
+ # Are these the same?
+ describe service(servicename) do
+ it { should_not be_running }
+ end
describe "service #{servicename}" do
it 'should not be running' do
shell("pidof #{servicename}", {:acceptable_exit_codes => 1})
end
end
end
describe 'alternative default mods' do
# Using puppet_apply as a helper
it 'should apply with no errors' do
pp = <<-EOS
class { 'apache':
default_mods => [
'info',
'alias',
'mime',
'env',
'expires',
],
}
apache::vhost { 'defaults.example.com':
docroot => '/var/www/defaults',
aliases => {
alias => '/css',
path => '/var/www/css',
},
setenv => 'TEST1 one',
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
shell('sleep 10')
- expect(apply_manifest(pp).exit_code).to eq(0)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
describe service(servicename) do
it { should be_running }
end
end
end
diff --git a/spec/acceptance/itk_spec.rb b/spec/acceptance/itk_spec.rb
index dc779008..cabd71c5 100644
--- a/spec/acceptance/itk_spec.rb
+++ b/spec/acceptance/itk_spec.rb
@@ -1,35 +1,35 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'Debian'
service_name = 'apache2'
when 'FreeBSD'
service_name = 'apache22'
else
# Not implemented yet
service_name = :skip
end
unless service_name.equal? :skip
describe 'apache::mod::itk class' do
describe 'running puppet code' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apache':
mpm_module => 'itk',
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
describe service(service_name) do
it { should be_running }
it { should be_enabled }
end
end
end
diff --git a/spec/acceptance/mod_php_spec.rb b/spec/acceptance/mod_php_spec.rb
index d2222691..f9c6f2c7 100644
--- a/spec/acceptance/mod_php_spec.rb
+++ b/spec/acceptance/mod_php_spec.rb
@@ -1,52 +1,52 @@
require 'spec_helper_acceptance'
describe 'apache::mod::php class' do
case fact('osfamily')
when 'Debian'
mod_dir = '/etc/apache2/mods-available'
service_name = 'apache2'
when 'RedHat'
mod_dir = '/etc/httpd/conf.d'
service_name = 'httpd'
when 'FreeBSD'
mod_dir = '/usr/local/etc/apache22/Modules'
service_name = 'apache22'
end
context "default php config" do
it 'succeeds in puppeting php' do
pp= <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
apache::vhost { 'php.example.com':
port => '80',
docroot => '/var/www/php',
}
host { 'php.example.com': ip => '127.0.0.1', }
file { '/var/www/php/index.php':
ensure => file,
content => "<?php phpinfo(); ?>\\n",
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
describe file("#{mod_dir}/php5.conf") do
it { should contain "DirectoryIndex index.php" }
end
it 'should answer to php.example.com' do
shell("/usr/bin/curl php.example.com:80") do |r|
r.stdout.should =~ /PHP Version/
r.exit_code.should == 0
end
end
end
end
diff --git a/spec/acceptance/mod_suphp_spec.rb b/spec/acceptance/mod_suphp_spec.rb
index 40c8376c..84a641db 100644
--- a/spec/acceptance/mod_suphp_spec.rb
+++ b/spec/acceptance/mod_suphp_spec.rb
@@ -1,44 +1,44 @@
require 'spec_helper_acceptance'
describe 'apache::mod::suphp class' do
case fact('osfamily')
when 'Debian'
context "default suphp config" do
it 'succeeds in puppeting suphp' do
pp = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
class { 'apache::mod::suphp': }
apache::vhost { 'suphp.example.com':
port => '80',
docroot => '/var/www/suphp',
}
host { 'suphp.example.com': ip => '127.0.0.1', }
file { '/var/www/suphp/index.php':
ensure => file,
owner => 'puppet',
group => 'puppet',
content => "<?php echo get_current_user(); ?>\\n",
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service('apache2') do
it { should be_enabled }
it { should be_running }
end
it 'should answer to suphp.example.com' do
shell("/usr/bin/curl suphp.example.com:80") do |r|
r.stdout.should =~ /^puppet$/
r.exit_code.should == 0
end
end
end
when 'RedHat'
# Not implemented yet
end
end
diff --git a/spec/acceptance/prefork_worker_spec.rb b/spec/acceptance/prefork_worker_spec.rb
index 59de6330..8427fd04 100644
--- a/spec/acceptance/prefork_worker_spec.rb
+++ b/spec/acceptance/prefork_worker_spec.rb
@@ -1,81 +1,81 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'RedHat'
servicename = 'httpd'
when 'Debian'
servicename = 'apache2'
when 'FreeBSD'
servicename = 'apache22'
else
raise "Unconfigured OS for apache service on #{fact('osfamily')}"
end
case fact('osfamily')
when 'FreeBSD'
describe 'apache::mod::event class' do
describe 'running puppet code' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apache':
mpm_module => 'event',
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
end
end
describe 'apache::mod::worker class' do
describe 'running puppet code' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apache':
mpm_module => 'worker',
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
end
describe 'apache::mod::prefork class' do
describe 'running puppet code' do
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
end
diff --git a/spec/acceptance/service_spec.rb b/spec/acceptance/service_spec.rb
index e5e7c3bd..c3124c84 100644
--- a/spec/acceptance/service_spec.rb
+++ b/spec/acceptance/service_spec.rb
@@ -1,19 +1,19 @@
require 'spec_helper_acceptance'
describe 'apache::service class' do
describe 'adding dependencies in between the base class and service class' do
it 'should work with no errors' do
pp = <<-EOS
class { 'apache': }
file { '/tmp/test':
require => Class['apache'],
notify => Class['apache::service'],
}
EOS
# Run it twice and test for idempotency
- expect([0,2]).to include (apply_manifest(pp).exit_code)
- expect(apply_manifest(pp).exit_code).to eq(0)
+ apply_manifest(pp, :catch_failures => true)
+ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
end
diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb
index e03badcf..42d98033 100644
--- a/spec/acceptance/vhost_spec.rb
+++ b/spec/acceptance/vhost_spec.rb
@@ -1,290 +1,290 @@
require 'spec_helper_acceptance'
describe 'apache::vhost define' do
case fact('osfamily')
when 'RedHat'
vhost_dir = '/etc/httpd/conf.d'
package_name = 'httpd'
service_name = 'httpd'
when 'FreeBSD'
vhost_dir = '/usr/local/etc/apache22/Vhosts'
package_name = 'apache22'
service_name = 'apache22'
when 'Debian'
vhost_dir = '/etc/apache2/sites-enabled'
package_name = 'apache2'
service_name = 'apache2'
end
context "default vhost without ssl" do
it 'should create a default vhost config' do
pp = <<-EOS
class { 'apache': }
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe file("#{vhost_dir}/15-default.conf") do
it { should contain '<VirtualHost \*:80>' }
end
describe file("#{vhost_dir}/15-default-ssl.conf") do
it { should_not be_file }
end
end
context 'default vhost with ssl' do
it 'should create default vhost configs' do
pp = <<-EOS
class { 'apache':
default_ssl_vhost => true,
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe file("#{vhost_dir}/15-default.conf") do
it { should contain '<VirtualHost \*:80>' }
end
describe file("#{vhost_dir}/15-default-ssl.conf") do
it { should contain '<VirtualHost \*:443>' }
it { should contain "SSLEngine on" }
end
end
context 'new vhost on port 80' do
it 'should configure an apache vhost' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'first.example.com':
port => '80',
docroot => '/var/www/first',
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe file("#{vhost_dir}/25-first.example.com.conf") do
it { should contain '<VirtualHost \*:80>' }
it { should contain "ServerName first.example.com" }
end
end
context 'new proxy vhost on port 80' do
it 'should configure an apache proxy vhost' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'proxy.example.com':
port => '80',
docroot => '/var/www/proxy',
proxy_pass => [
{ 'path' => '/foo', 'url' => 'http://backend-foo/'},
],
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe file("#{vhost_dir}/25-proxy.example.com.conf") do
it { should contain '<VirtualHost \*:80>' }
it { should contain "ServerName proxy.example.com" }
it { should contain "ProxyPass" }
it { should_not contain "<Proxy \*>" }
end
end
context 'new vhost on port 80' do
it 'should configure two apache vhosts' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'first.example.com':
port => '80',
docroot => '/var/www/first',
}
host { 'first.example.com': ip => '127.0.0.1', }
file { '/var/www/first/index.html':
ensure => file,
content => "Hello from first\\n",
}
apache::vhost { 'second.example.com':
port => '80',
docroot => '/var/www/second',
}
host { 'second.example.com': ip => '127.0.0.1', }
file { '/var/www/second/index.html':
ensure => file,
content => "Hello from second\\n",
}
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
it 'should answer to first.example.com' do
shell("/usr/bin/curl first.example.com:80", {:acceptable_exit_codes => 0}) do |r|
r.stdout.should == "Hello from first\n"
end
end
it 'should answer to second.example.com' do
shell("/usr/bin/curl second.example.com:80", {:acceptable_exit_codes => 0}) do |r|
r.stdout.should == "Hello from second\n"
end
end
end
context 'apache_directories readme example, adapted' do
it 'should configure a vhost with Files' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'files.example.net':
docroot => '/var/www/files',
directories => [
{ path => '~ (\.swp|\.bak|~)$', 'provider' => 'files', 'deny' => 'from all' },
],
}
file { '/var/www/files/index.html.bak':
ensure => file,
content => "Hello World\\n",
}
host { 'files.example.net': ip => '127.0.0.1', }
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
it 'should answer to files.example.net' do
shell("/usr/bin/curl -sSf files.example.net:80/index.html.bak", {:acceptable_exit_codes => 22}).stderr.should =~ /curl: \(22\) The requested URL returned error: 403/
end
end
case fact('lsbdistcodename')
when 'precise', 'wheezy'
context 'vhost fallbackresouce example' do
it 'should configure a vhost with Fallbackresource' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'fallback.example.net':
docroot => '/var/www/fallback',
fallbackresource => '/index.html'
}
file { '/var/www/fallback/index.html':
ensure => file,
content => "Hello World\\n",
}
host { 'fallback.example.net': ip => '127.0.0.1', }
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
it 'should answer to fallback.example.net' do
- shell("/usr/bin/curl fallback.example.net:80/Does/Not/Exist", {:acceptable_exit_codes => 0}) do |r|
+ shell("/usr/bin/curl fallback.example.net:80/Does/Not/Exist") do |r|
r.stdout.should == "Hello World\n"
end
end
end
else
# The current stable RHEL release (6.4) comes with Apache httpd 2.2.15
# That was released March 6, 2010.
# FallbackResource was backported to 2.2.16, and released July 25, 2010.
# Ubuntu Lucid (10.04) comes with apache2 2.2.14, released October 3, 2009.
# https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x/STATUS
end
context 'virtual_docroot hosting separate sites' do
it 'should configure a vhost with VirtualDocumentRoot' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'virt.example.com':
vhost_name => '*',
serveraliases => '*virt.example.com',
port => '80',
docroot => '/var/www/virt',
virtual_docroot => '/var/www/virt/%1',
}
host { 'virt.example.com': ip => '127.0.0.1', }
host { 'a.virt.example.com': ip => '127.0.0.1', }
host { 'b.virt.example.com': ip => '127.0.0.1', }
file { [ '/var/www/virt/a', '/var/www/virt/b', ]: ensure => directory, }
file { '/var/www/virt/a/index.html': ensure => file, content => "Hello from a.virt\\n", }
file { '/var/www/virt/b/index.html': ensure => file, content => "Hello from b.virt\\n", }
EOS
- expect([0,2]).to include (apply_manifest(pp).exit_code)
+ apply_manifest(pp, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
it 'should answer to a.virt.example.com' do
shell("/usr/bin/curl a.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r|
r.stdout.should == "Hello from a.virt\n"
end
end
it 'should answer to b.virt.example.com' do
shell("/usr/bin/curl b.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r|
r.stdout.should == "Hello from b.virt\n"
end
end
end
context 'proxy_pass for alternative vhost' do
it 'should configure a local vhost and a proxy vhost' do
- puppet_apply(%{
+ apply_manifest(%{
class { 'apache': default_vhost => false, }
apache::vhost { 'localhost':
docroot => '/var/www/local',
ip => '127.0.0.1',
port => '8888',
}
apache::listen { '*:80': }
apache::vhost { 'proxy.example.com':
docroot => '/var/www',
port => '80',
add_listen => false,
proxy_pass => {
'path' => '/',
'url' => 'http://localhost:8888/subdir/',
},
}
host { 'proxy.example.com': ip => '127.0.0.1', }
file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, }
file { '/var/www/local/subdir/index.html':
ensure => file,
content => "Hello from localhost\\n",
}
- }) { |r| [0,2].should include r.exit_code}
+ }, :catch_failures => true)
end
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
it 'should get a response from the back end' do
shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r|
r.stdout.should == "Hello from localhost\n"
r.exit_code.should == 0
end
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Aug 18, 10:19 PM (4 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3260980
Attached To
rSPAPA puppet-puppetlabs-apache
Event Timeline
Log In to Comment