Skip to content

Commit

Permalink
Merge pull request #377 from 3flex/modernize-travis
Browse files Browse the repository at this point in the history
Improve test suite (Travis updates, librarian-puppet removal, better utilize puppet-lint)
  • Loading branch information
James Fryman committed Aug 22, 2014
2 parents 82398b2 + 88d8984 commit a2dd6cd
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
fixtures:
symlinks:
nginx: "#{source_dir}"
forge_modules:
apt: "puppetlabs/apt"
concat: "puppetlabs/concat"
stdlib: "puppetlabs/stdlib"
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
files/server_test.crt
files/server_test.pem
pkg/
.librarian/
.tmp/
pkg/
Gemfile.lock
spec/fixtures/
Expand Down
4 changes: 4 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--fail-on-warnings
--relative
--no-80chars-check
--no-class_inherits_from_params_class-check
29 changes: 16 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ branches:
- refactor
- gh-pages
language: ruby
script: "bundle exec rake --rakefile $PWD/.travis/Rakefile spec SPEC_OPTS='--format documentation'"
rvm:
- 1.9.3
- 2.0.0
gemfile: .travis/Gemfile
env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0"
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
bundler_args: --without rake
matrix:
exclude:
- rvm: 1.9.3
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0"
gemfile: .travis/Gemfile
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.0"
allow_failures:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0"
gemfile: .travis/Gemfile
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
notifications:
email: false
14 changes: 0 additions & 14 deletions .travis/Gemfile

This file was deleted.

8 changes: 0 additions & 8 deletions .travis/Rakefile

This file was deleted.

21 changes: 16 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
source 'https://rubygems.org'

group :test do
gem 'rest-client', '~> 1.6.8', :require => false, :platforms => :ruby_18
end

group :rake, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-blacksmith', :require => false
gem 'rspec-system-puppet', :require => false
end

group :rake do
gem 'puppet', '>=3.0.1'
gem 'rspec-puppet', '>=1.0.1'
gem 'rake', '>=0.9.2.2'
gem 'puppet-lint', '>=0.1.12'
gem 'puppetlabs_spec_helper'
gem 'puppet-blacksmith'
gem 'librarian-puppet', '<1.1.0'
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
5 changes: 0 additions & 5 deletions Puppetfile

This file was deleted.

13 changes: 0 additions & 13 deletions Puppetfile.lock

This file was deleted.

7 changes: 0 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,4 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet_blacksmith/rake_tasks'
require 'rspec-system/rake_task'

# use librarian-puppet to manage fixtures instead of .fixtures.yml
# offers more possibilities like explicit version management, forge downloads,...
task :librarian_spec_prep do
sh "librarian-puppet install --path=spec/fixtures/modules/"
end
task :spec_prep => :librarian_spec_prep

task :default => [:clean, :spec]
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@
}

file { "${conf_dir}/sites-available":
ensure => directory,
owner => $sites_available_owner,
group => $sites_available_group,
mode => $sites_available_mode,
ensure => directory,
}

if $vhost_purge == true {
Expand Down
2 changes: 1 addition & 1 deletion manifests/package/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

apt::source { 'nginx':
location => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
repos => "main",
repos => 'main',
key => '561F9B9CAC40B2F7',
key_source => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt',
notify => Exec['apt_get_update_for_nginx'],
Expand Down
10 changes: 6 additions & 4 deletions manifests/resource/geo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@
include nginx::params
$root_group = $nginx::params::root_group

$ensure_real = $ensure ? {
'absent' => 'absent',
default => 'file',
}

File {
owner => 'root',
group => $root_group,
mode => '0644',
}

file { "${nginx::config::conf_dir}/conf.d/${name}-geo.conf":
ensure => $ensure ? {
'absent' => absent,
default => 'file',
},
ensure => $ensure_real,
content => template('nginx/conf.d/geo.erb'),
notify => Class['nginx::service'],
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
$config_file = "${nginx::config::conf_dir}/sites-available/${vhost_sanitized}.conf"

$location_sanitized_tmp = regsubst($location, '\/', '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, "\\\\", '_', 'G')
$location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G')

## Check for various error conditions
if ($vhost == undef) {
Expand Down Expand Up @@ -336,15 +336,15 @@
if ($ssl_only != true) {
$tmpFile=md5("${vhost_sanitized}-${priority}-${location_sanitized}")

concat::fragment { "${tmpFile}":
concat::fragment { $tmpFile:
ensure => present,
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb')
], ''),
order => "${priority}",
order => "${priority}", #lint:ignore:only_variable_string waiting on https://github.com/puppetlabs/puppetlabs-concat/commit/f70881fbfd01c404616e9e4139d98dad78d5a918
}
}

Expand All @@ -353,15 +353,15 @@
$ssl_priority = $priority + 300

$sslTmpFile=md5("${vhost_sanitized}-${ssl_priority}-${location_sanitized}-ssl")
concat::fragment {"${sslTmpFile}":
concat::fragment { $sslTmpFile:
ensure => present,
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb')
], ''),
order => "${ssl_priority}",
order => "${ssl_priority}", #lint:ignore:only_variable_string waiting on https://github.com/puppetlabs/puppetlabs-concat/commit/f70881fbfd01c404616e9e4139d98dad78d5a918
}
}

Expand Down
10 changes: 6 additions & 4 deletions manifests/resource/map.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@
include nginx::params
$root_group = $nginx::params::root_group

$ensure_real = $ensure ? {
'absent' => absent,
default => 'file',
}

File {
owner => 'root',
group => $root_group,
mode => '0644',
}

file { "${nginx::config::conf_dir}/conf.d/${name}-map.conf":
ensure => $ensure ? {
'absent' => absent,
default => 'file',
},
ensure => $ensure_real,
content => template('nginx/conf.d/map.erb'),
notify => Class['nginx::service'],
}
Expand Down
13 changes: 7 additions & 6 deletions manifests/resource/upstream.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,20 @@
include nginx::params
$root_group = $nginx::params::root_group

$ensure_real = $ensure ? {
'absent' => absent,
default => present,
}

Concat {
owner => 'root',
group => $root_group,
mode => '0644',
}

concat { "${nginx::config::conf_dir}/conf.d/${name}-upstream.conf":
ensure => $ensure ? {
'absent' => absent,
'file' => present,
default => present,
},
notify => Class['nginx::service'],
ensure => $ensure_real,
notify => Class['nginx::service'],
}

# Uses: $name, $upstream_cfg_prepend
Expand Down
2 changes: 1 addition & 1 deletion manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@

# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
# and support does not exist for it in the kernel.
if ($ipv6_enable == true) and (!$ipaddress6) {
if ($ipv6_enable == true) and (!$::ipaddress6) {
warning('nginx: IPv6 support is not enabled or configured properly')
}

Expand Down
1 change: 1 addition & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:lsbdistcodename => 'precise',
:lsbdistid => 'Debian',
}
end
end
Expand Down
13 changes: 9 additions & 4 deletions spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@
end
end

shared_examples 'debian' do |operatingsystem, lsbdistcodename|
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'Debian', :lsbdistcodename => lsbdistcodename }}
shared_examples 'debian' do |operatingsystem, lsbdistcodename, lsbdistid|
let(:facts) {{
:operatingsystem => operatingsystem,
:osfamily => 'Debian',
:lsbdistcodename => lsbdistcodename,
:lsbdistid => lsbdistid
}}

context "using defaults" do
it { should contain_package('nginx') }
Expand Down Expand Up @@ -105,8 +110,8 @@
end

context 'debian' do
it_behaves_like 'debian', 'debian', 'wheezy'
it_behaves_like 'debian', 'ubuntu', 'precise'
it_behaves_like 'debian', 'debian', 'wheezy', 'debian'
it_behaves_like 'debian', 'ubuntu', 'precise', 'ubuntu'
end

context 'suse' do
Expand Down
14 changes: 7 additions & 7 deletions tests/location_params.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include nginx

nginx::resource::location { 'www.test.com-params':
ensure => present,
location => '/some/url',
vhost => 'www.test.com',
fastcgi_param => {
'APP_ENV' => 'production',
'APP_VERSION' => '0.1.10',
'APP_SECRET' => 'hisfaihicasagfkjsa',
ensure => present,
location => '/some/url',
vhost => 'www.test.com',
fastcgi_param => {
'APP_ENV' => 'production',
'APP_VERSION' => '0.1.10',
'APP_SECRET' => 'hisfaihicasagfkjsa',
},
}
16 changes: 8 additions & 8 deletions tests/vhost.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
include nginx

nginx::resource::vhost { 'test.local test':
ensure => present,
ipv6_enable => true,
proxy => 'http://proxypass',
ensure => present,
ipv6_enable => true,
proxy => 'http://proxypass',
}

nginx::resource::vhost { 'test.local:8080':
ensure => present,
listen_port => 8080,
server_name => ['test.local test'],
ipv6_enable => true,
proxy => 'http://proxypass',
ensure => present,
listen_port => 8080,
server_name => ['test.local test'],
ipv6_enable => true,
proxy => 'http://proxypass',
}

0 comments on commit a2dd6cd

Please sign in to comment.