Skip to content

Commit d25fcd6

Browse files
committed
Merge pull request #3 from mwhahaha/spec_tests
Fixing minor logic issues, adding spec tests, updating README for testing
2 parents 885feb9 + c6e0577 commit d25fcd6

36 files changed

+1546
-11
lines changed

.fixtures.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fixtures:
2+
repositories:
3+
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
4+
symlinks:
5+
repose: "#{source_dir}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ spec/reports
1212
test/tmp
1313
test/version_tmp
1414
tmp
15+
Gemfile.lock
1516

1617
# YARD artifacts
1718
.yardoc

Gemfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2+
3+
group :development, :test do
4+
gem 'mime-types', '<2.0', :require => false
5+
gem 'rake', '10.1.1', :require => false
6+
gem 'rspec-puppet', :require => false
7+
gem 'puppetlabs_spec_helper', :require => false
8+
gem 'serverspec', :require => false
9+
gem 'puppet-lint', :require => false
10+
gem 'pry', :require => false
11+
gem 'simplecov', :require => false
12+
gem 'beaker', :require => false
13+
gem 'beaker-rspec', :require => false
14+
end
15+
16+
if puppetversion = ENV['PUPPET_GEM_VERSION']
17+
gem 'puppet', puppetversion, :require => false
18+
else
19+
gem 'puppet', :require => false
20+
end
21+
22+
# vim:ft=ruby

ModuleFile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name 'citops-repose'
2-
version '1.0.5'
2+
version '1.0.6'
33
description "Repose is an api middleware that provides authentication,
44
filtering, ratelimitting and several other features, this deploys it."
5+
project_page 'https://github.com/rackerlabs/puppet-repose'
6+
7+
dependency 'puppetlabs/stdlib', '>= 2.0.0'

README.rdoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ This module provides a re-usable and environment agnostic control of Repose Powe
7575
=== via GIT
7676
git clone http://github.com/rackerlabs/puppet-repose.git /etc/puppet/modules/repose
7777

78+
---
79+
== Running tests with bundler
80+
git clone http://github.com/rackerlabs/puppet-repose.git
81+
cd puppet-repose
82+
bundle install
83+
bundle exec rake validate
84+
bundle exec rake spec
85+
86+
== Running tests
87+
git clone http://github.com/rackerlabs/puppet-repose.git
88+
cd puppet-repose
89+
gem install rspec-puppet rspec-puppet-utils puppet puppetlabs_spec_helper --no-ri --no-rdoc
90+
rake validate
91+
rake spec
92+
7893
---
7994
==Authors
8095
[Alex Schultz] mailto:[email protected]

Rakefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
require 'rake'
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
require 'puppet-lint/tasks/puppet-lint'
4+
PuppetLint.configuration.send('disable_80chars')
5+
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
26

3-
require 'rspec/core/rake_task'
4-
5-
RSpec::Core::RakeTask.new(:spec) do |t|
6-
t.pattern = 'spec/*/*_spec.rb'
7+
desc "Validate manifests, templates, and ruby files"
8+
task :validate do
9+
Dir['manifests/**/*.pp'].each do |manifest|
10+
sh "puppet parser validate --noop #{manifest}"
11+
end
12+
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
13+
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
14+
end
15+
Dir['templates/**/*.erb'].each do |template|
16+
sh "erb -P -x -T '-' #{template} | ruby -c"
17+
end
718
end

puppet-module-repose.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%define base_name repose
22

33
Name: puppet-module-%{base_name}
4-
Version: 1.0.5
4+
Version: 1.0.6
55
Release: 1
66
BuildArch: noarch
77
Summary: Puppet module to configure %{base_name}
@@ -29,6 +29,8 @@ cp -pr * %{buildroot}%{module_dir}/
2929
%{module_dir}
3030

3131
%changelog
32+
* Tue Jun 03 2014 Alex Schultz <[email protected]> - 1.0.6-1
33+
- Fixing minor logic issues, adding spec tests
3234
* Mon May 19 2014 Alex Schultz <[email protected]> - 1.0.5-1
3335
- slf4j http logging filter support
3436
* Thu Jan 09 2014 Alex Schultz <[email protected]> - 1.0.4-1
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
require 'spec_helper'
2+
describe 'repose::filter::container' do
3+
context 'on RedHat' do
4+
let :facts do
5+
{
6+
:osfamily => 'RedHat',
7+
:operationsystemrelease => '6',
8+
}
9+
end
10+
11+
context 'with defaults for all parameters' do
12+
it {
13+
expect {
14+
should compile
15+
}.to raise_error(Puppet::Error, /app_name is a required parameter/)
16+
}
17+
end
18+
19+
context 'with defaults with app_name' do
20+
let(:params) { {
21+
:app_name => 'app'
22+
} }
23+
it {
24+
should contain_file('/etc/repose/log4j.properties').
25+
with_content(/log4j\.rootLogger=WARN/).
26+
with_content(/log4j\.appender\.defaultFile\.File=\/var\/log\/repose\/app\.log/)
27+
should contain_file('/etc/repose/container.cfg.xml')
28+
}
29+
end
30+
31+
context 'configure logging' do
32+
let(:params) { {
33+
:app_name => 'app',
34+
:log_dir => '/mypath',
35+
:log_level => 'DEBUG',
36+
:syslog_server => 'syslog.example.com',
37+
:syslog_port => 515,
38+
:syslog_protocol => 'tcp'
39+
} }
40+
it {
41+
should contain_file('/etc/repose/log4j.properties').
42+
with_content(/log4j\.appender\.defaultFile\.File=\/mypath\/app\.log/).
43+
with_content(/log4j\.rootLogger=DEBUG, syslog, defaultFile/).
44+
with_content(/log4j.logger.http=INFO, httpSyslog/).
45+
with_content(/syslog.syslogHost=syslog.example.com/).
46+
with_content(/syslog.port=515/).
47+
with_content(/syslog.protocol=tcp/).
48+
with_content(/httpSyslog.syslogHost=syslog.example.com/).
49+
with_content(/httpSyslog.port=515/).
50+
with_content(/httpSyslog.protocol=tcp/)
51+
should contain_file('/etc/repose/container.cfg.xml')
52+
}
53+
end
54+
55+
context 'configure container' do
56+
let(:params) { {
57+
:app_name => 'app',
58+
:via => 'my app',
59+
:deployment_directory => '/deployment_dir',
60+
:deployment_directory_auto_clean => 'false',
61+
:artifact_directory => '/artifact_dir',
62+
:artifact_directory_check_interval => '10000',
63+
:logging_configuration => 'mylog4j.properties',
64+
:ssl_enabled => true,
65+
:ssl_keystore_filename => 'keystore.name',
66+
:ssl_keystore_password => 'mypassword',
67+
:ssl_key_password => 'keypassword',
68+
:content_body_read_limit => '10240000',
69+
:jmx_reset_time => '3600000',
70+
:client_request_logging => 'false',
71+
:http_port => '10000',
72+
:https_port => '10001',
73+
:connection_timeout => '40000',
74+
:read_timeout => '1000',
75+
:proxy_thread_pool => 'my-pool'
76+
} }
77+
it {
78+
should contain_file('/etc/repose/mylog4j.properties')
79+
should contain_file('/etc/repose/container.cfg.xml').
80+
with_content(/http-port="10000"/).
81+
with_content(/https-port="10001"/).
82+
with_content(/via="my app"/).
83+
with_content(/content-body-read-limit="10240000"/).
84+
with_content(/connection-timeout="40000"/).
85+
with_content(/read-timeout="1000"/).
86+
with_content(/proxy-thread-pool="my-pool"/).
87+
with_content(/client-request-logging="false"/).
88+
with_content(/jmx-reset-time="3600000"/).
89+
with_content(/<deployment-directory auto-clean=\"false\">\/deployment_dir<\/deployment-directory>/).
90+
with_content(/<artifact-directory check-interval="10000">\/artifact_dir<\/artifact-directory>/).
91+
with_content(/<logging-configuration href="mylog4j.properties"\/>/).
92+
with_content(/<ssl-configuration>/).
93+
with_content(/<keystore-filename>keystore.name<\/keystore-filename>/).
94+
with_content(/<keystore-password>mypassword<\/keystore-password>/).
95+
with_content(/<key-password>keypassword<\/key-password>/).
96+
with_content(/<\/ssl-configuration>/)
97+
}
98+
end
99+
100+
end
101+
end
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
require 'spec_helper'
2+
describe 'repose::filter::http_connection_pool', :type => :class do
3+
let :pre_condition do
4+
'include repose'
5+
end
6+
7+
context 'on RedHat' do
8+
let :facts do
9+
{
10+
:osfamily => 'RedHat',
11+
:operationsystemrelease => '6',
12+
}
13+
end
14+
15+
context 'with defaults for all parameters' do
16+
it {
17+
should contain_file('/etc/repose/http-connection-pool.cfg.xml').
18+
with_content(/id="default"/).
19+
with_content(/default="true"/).
20+
with_content(/http.conn-manager.max-total="200"/).
21+
with_content(/http.conn-manager.max-per-route="20"/).
22+
with_content(/http.socket.timeout="30000"/).
23+
with_content(/http.socket.buffer-size="8192"/).
24+
with_content(/http.connection.timeout="30000"/).
25+
with_content(/http.connection.max-line-length="8192"/).
26+
with_content(/http.connection.max-header-count="100"/).
27+
with_content(/http.connection.max-status-line-garbage="100"/).
28+
with_content(/http.tcp.nodelay="true"/).
29+
with_content(/keepalive.timeout="0"/)
30+
}
31+
end
32+
33+
context 'with additional pool' do
34+
let(:params) { {
35+
:additional_pools => [ {
36+
"id" => 'client-auth-pool',
37+
"is_default" => false,
38+
"conn_manager_max_total" => 201,
39+
"conn_manager_max_per_route" => 101,
40+
"socket_timeout" => 30001,
41+
"socket_buffer_size" => 8193,
42+
"conn_timeout" => 30001,
43+
"conn_max_line_length" => 8193,
44+
"conn_max_header_count" => 101,
45+
"conn_max_status_line_garbage" => 101,
46+
"tcp_nodelay" => false,
47+
"keepalive_timeout" => 10000, }, ]
48+
} }
49+
it {
50+
should contain_file('/etc/repose/http-connection-pool.cfg.xml').
51+
with_content(/id="default"/).
52+
with_content(/default="true"/).
53+
with_content(/http.conn-manager.max-total="200"/).
54+
with_content(/http.conn-manager.max-per-route="20"/).
55+
with_content(/http.socket.timeout="30000"/).
56+
with_content(/http.socket.buffer-size="8192"/).
57+
with_content(/http.connection.timeout="30000"/).
58+
with_content(/http.connection.max-line-length="8192"/).
59+
with_content(/http.connection.max-header-count="100"/).
60+
with_content(/http.connection.max-status-line-garbage="100"/).
61+
with_content(/http.tcp.nodelay="true"/).
62+
with_content(/keepalive.timeout="0"/).
63+
with_content(/id="client-auth-pool"/).
64+
with_content(/default="false"/).
65+
with_content(/http.conn-manager.max-total="201"/).
66+
with_content(/http.conn-manager.max-per-route="101"/).
67+
with_content(/http.socket.timeout="30001"/).
68+
with_content(/http.socket.buffer-size="8193"/).
69+
with_content(/http.connection.timeout="30001"/).
70+
with_content(/http.connection.max-line-length="8193"/).
71+
with_content(/http.connection.max-header-count="101"/).
72+
with_content(/http.connection.max-status-line-garbage="101"/).
73+
with_content(/http.tcp.nodelay="false"/).
74+
with_content(/keepalive.timeout="10000"/
75+
)
76+
}
77+
end
78+
end
79+
end

spec/classes/filter_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
describe 'repose::filter' do
3+
4+
context 'with defaults for all parameters' do
5+
it do
6+
expect {
7+
should compile
8+
}.to raise_error(Puppet::Error, /This class should not be used directly/)
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)