-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
194 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fixtures: | ||
repositories: | ||
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
concat: "git://github.com/puppetlabs/puppetlabs-concat.git" | ||
apt: "git://github.com/puppetlabs/puppetlabs-apt.git" | ||
symlinks: | ||
varnish: "#{source_dir}" |
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,9 @@ | ||
.pkg | ||
Gemfile.lock | ||
vendor | ||
spec/fixtures | ||
.rspec_system | ||
.bundle | ||
.vagrant | ||
.*sw* | ||
|
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,16 @@ | ||
source ENV['GEM_SOURCE'] || 'https://rubygems.org' | ||
|
||
group :development, :test do | ||
gem 'rake', :require => false | ||
gem 'rspec-puppet', :require => false | ||
gem 'puppetlabs_spec_helper', :require => false | ||
gem 'puppet-lint', :require => false | ||
gem 'pry', :require => false | ||
gem 'simplecov', :require => false | ||
end | ||
|
||
if puppetversion = ENV['PUPPET_GEM_VERSION'] | ||
gem 'puppet', puppetversion, :require => false | ||
else | ||
gem 'puppet', :require => false | ||
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,22 @@ | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
|
||
PuppetLint.configuration.send("disable_80chars") | ||
PuppetLint.configuration.send('disable_class_parameter_defaults') | ||
PuppetLint.configuration.send('disable_class_inherits_from_params_class') | ||
PuppetLint.configuration.send('disable_documentation') | ||
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" | ||
PuppetLint.configuration.fail_on_warnings = true | ||
|
||
exclude_paths = [ | ||
"pkg/**/*", | ||
"spec/**/*", | ||
] | ||
|
||
PuppetLint.configuration.ignore_paths = exclude_paths | ||
|
||
desc "Run syntax, lint, and spec tests." | ||
task :test => [ | ||
:lint, | ||
:spec, | ||
] |
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,103 @@ | ||
require 'spec_helper' | ||
|
||
describe 'varnish', :type => :class do | ||
context "on a Debian OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
:lsbdistid => 'Debian', | ||
:lsbdistcodename => 'precise' | ||
} | ||
end | ||
|
||
it { should compile } | ||
it { should contain_class('varnish::install').with('add_repo' => 'true') } | ||
it { should contain_class('varnish::service').with('start' => 'yes') } | ||
it { should contain_class('varnish::shmlog') } | ||
it { should contain_file('varnish-conf').with( | ||
'ensure' => 'present', | ||
'path' => '/etc/default/varnish', | ||
'owner' => 'root', | ||
'group' => 'root', | ||
'mode' => '0644', | ||
'require' => 'Package[varnish]', | ||
'notify' => 'Service[varnish]' | ||
) | ||
} | ||
it { should contain_file('storage-dir').with( | ||
'ensure' => 'directory', | ||
'path' => '/var/lib/varnish-storage', | ||
'require' => 'Package[varnish]' | ||
) | ||
} | ||
|
||
context "without shmlog_tempfs" do | ||
let :params do | ||
{ :shmlog_tempfs => false } | ||
end | ||
|
||
it { should_not contain_class('varnish::shmlog') } | ||
end | ||
|
||
context "default varnish-conf values" do | ||
it { should contain_file('varnish-conf').with_content(/START=yes/) } | ||
it { should contain_file('varnish-conf').with_content(/NFILES=131072/) } | ||
it { should contain_file('varnish-conf').with_content(/MEMLOCK=82000/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_VCL_CONF=\/etc\/varnish\/default\.vcl/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_LISTEN_ADDRESS=/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_LISTEN_PORT=6081/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_ADMIN_LISTEN_PORT=6082/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_MIN_THREADS=5/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_MAX_THREADS=500/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_THREAD_TIMEOUT=300/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_STORAGE_FILE=\/var\/lib\/varnish-storage\/varnish_storage\.bin/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_STORAGE_SIZE=1G/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_SECRET_FILE=\/etc\/varnish\/secret/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_STORAGE=\"malloc,\${VARNISH_STORAGE_SIZE}\"/) } | ||
it { should contain_file('varnish-conf').with_content(/VARNISH_TTL=120/) } | ||
it { should contain_file('varnish-conf').with_content(/DAEMON_OPTS=\"-a \${VARNISH_LISTEN_ADDRESS}:\${VARNISH_LISTEN_PORT}/) } | ||
|
||
end | ||
end | ||
|
||
context "on a RedHat" do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:concat_basedir => '/dne', | ||
:operatingsystem => 'RedHat' | ||
} | ||
end | ||
|
||
it { should compile } | ||
it { should contain_class('varnish::install').with('add_repo' => 'true') } | ||
it { should contain_class('varnish::service').with('start' => 'yes') } | ||
it { should contain_class('varnish::shmlog') } | ||
it { should contain_file('varnish-conf').with( | ||
'ensure' => 'present', | ||
'path' => '/etc/sysconfig/varnish', | ||
'owner' => 'root', | ||
'group' => 'root', | ||
'mode' => '0644', | ||
'require' => 'Package[varnish]', | ||
'notify' => 'Service[varnish]' | ||
) | ||
} | ||
it { should contain_file('storage-dir').with( | ||
'ensure' => 'directory', | ||
'path' => '/var/lib/varnish-storage', | ||
'require' => 'Package[varnish]' | ||
) | ||
} | ||
context "without shmlog_tempfs" do | ||
let :params do | ||
{ :shmlog_tempfs => false } | ||
end | ||
|
||
it { should_not contain_class('varnish::shmlog') } | ||
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,6 @@ | ||
require 'spec_helper' | ||
|
||
describe 'varnish::vcl', :type => :class do | ||
|
||
|
||
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,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'varnish::acl', :type => :define do | ||
let :pre_condition do | ||
'class { "::varnish::vcl": }' | ||
end | ||
|
||
let(:title) { 'foo' } | ||
let(:facts) { { :concat_basedir => '/dne' } } | ||
|
||
context("expected behaviour") do | ||
let(:params) { { :hosts => ['192.168.10.14'] } } | ||
it { should contain_file('/etc/varnish/includes/acls.vcl') } | ||
it { should contain_concat__fragment('foo-acl') } | ||
end | ||
|
||
context("invalid acl title") do | ||
let(:title) { '-wrong_title' } | ||
|
||
it 'should cause a failure' do | ||
expect {should raise_error(Puppet::Error, 'Invalid characters in ACL name _wrong-title. Only letters, numbers and underscore are allowed.') } | ||
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,4 @@ | ||
--format s | ||
--colour | ||
--loadby mtime | ||
--backtrace |
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,2 @@ | ||
require 'puppetlabs_spec_helper/module_spec_helper' | ||
|