Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #271 from echocat/develop
Browse files Browse the repository at this point in the history
backmerge for release 6.0.2
  • Loading branch information
dwerder committed Apr 11, 2016
2 parents 5690e45 + c5ce34f commit 2e81de6
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 163 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2016-04-11 - 6.0.2 (Bugfix release)

#### Bugfixes:

- (debfe5d) remove parameter `gr_pid_dir` and use `gr_storage_dir` instead.
- RedHat init scripts use correct `gr_base_dir` for graphite.

## 2016-04-01 - 6.0.1 (Bugfix release)

#### Features:
Expand Down
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ def location_for(place, version = nil)
end

gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 4')
gem 'facter', '>= 2.0'
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'] || '~> 2')
gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false
gem 'puppet-lint', '>= 0.3.2', :require => false
gem 'rspec-puppet', '>= 2.3.2', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'metadata-json-lint', :require => false
gem 'rake', '< 11.0.0' # rubi <1.9 versus rake 11.0.0 workaround

if ENV['COVERAGE'] == 'yes'
gem 'simplecov', :require => false
gem 'coveralls', :require => false
end

if File.exists? "#{__FILE__}.local"
eval(File.read("#{__FILE__}.local"), binding)
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ Default is '/opt/graphite'. Set base install location of Graphite. This forms th

#####`gr_storage_dir`

Default is '${gr_base_dir}/storage'. Set location of base storage files. When not installing using pip a typical location for this may be '/opt/carbon'.
Default is '${gr_base_dir}/storage'. Set location of base storage files. When not installing using pip a typical location for this may be '/opt/carbon'. This dir is also used as pid dir on RedHat.

#####`gr_local_data_dir`

Expand Down
1 change: 0 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
$::graphite::rrd_dir_REAL,
$::graphite::whitelists_dir_REAL,
$::graphite::graphiteweb_log_dir_REAL,
$::graphite::gr_pid_dir,
"${::graphite::base_dir_REAL}/bin"]:
ensure => directory,
group => $gr_web_group_REAL,
Expand Down
5 changes: 4 additions & 1 deletion manifests/config_apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
hasstatus => true;
}



# Deploy configfiles
file {
"${::graphite::params::apache_dir}/ports.conf":
Expand All @@ -104,14 +106,15 @@
Package[$::graphite::params::apache_wsgi_pkg],
],
notify => Service[$::graphite::params::apache_service_name];

"${::graphite::params::apacheconf_dir}/graphite.conf":
ensure => file,
content => template($::graphite::gr_apache_conf_template),
group => $::graphite::config::gr_web_group_REAL,
mode => '0644',
owner => $::graphite::config::gr_web_user_REAL,
require => [
File[$::graphite::gr_storage_dir],
File[$::graphite::storage_dir_REAL],
File["${::graphite::params::apache_dir}/ports.conf"],
],
notify => Service[$::graphite::params::apache_service_name];
Expand Down
1 change: 0 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@
$gr_graphiteweb_webapp_dir = undef,
$gr_graphiteweb_storage_dir = '/var/lib/graphite-web',
$gr_graphiteweb_install_lib_dir = undef,
$gr_pid_dir = '/var/run',
$gr_apache_logdir = '/var/log/httpd/graphite-web',
$gunicorn_arg_timeout = 30,
$gunicorn_bind = 'unix:/var/run/graphite.sock',
Expand Down
5 changes: 2 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dwerder-graphite",
"version": "6.0.1",
"version": "6.0.2",
"source": "https://github.com/echocat/puppet-graphite.git",
"author": "Daniel Werdermann",
"license": "Apache-2.0",
Expand Down Expand Up @@ -64,6 +64,5 @@
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"description": "Graphite module"
]
}
134 changes: 72 additions & 62 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,6 @@

describe 'graphite::config', :type => 'class' do

shared_context 'Unsupported OS' do
it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )}
end

shared_context 'Debian unsupported platforms' do
it { is_expected.to raise_error(Puppet::Error,/Unsupported Debian release/) }
end

shared_context 'RedHat unsupported platforms' do
it { is_expected.to raise_error(Puppet::Error,/Unsupported RedHat release/) }
end

shared_context 'supported platforms' do
it { is_expected.to contain_class('graphite::params') }
it { is_expected.to contain_exec('Initial django db creation') }
it { is_expected.to contain_class('graphite::config_apache') }

# cron check
it { is_expected.to contain_file('/opt/graphite/bin/carbon-logrotate.sh').with({
'ensure' => 'file', 'mode' => '0544', 'content' => /^CARBON_LOGS_PATH="\/opt\/graphite\/storage\/log"$/ }) }
it { is_expected.to contain_cron('Rotate carbon logs').with({
'command' => '/opt/graphite/bin/carbon-logrotate.sh',
'hour' => '3',
'minute' => '15',
'require' => 'File[/opt/graphite/bin/carbon-logrotate.sh]',
'user' => 'root',}) }
end

shared_context 'RedHat supported platforms' do
it { is_expected.to contain_file('/opt/graphite/storage/whisper').with({
'ensure' => 'directory', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0755', }) }
Expand All @@ -44,13 +16,32 @@
'ensure' => 'file', 'owner' => 'apache', 'group' => 'apache', 'mode' => '0644' }).that_requires('Package[httpd]') }
it { is_expected.to contain_file('/opt/graphite/webapp/graphite/graphite_wsgi.py').with({
'ensure' => 'link', 'target' => '/opt/graphite/conf/graphite_wsgi.py', 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]' }) }
it { is_expected.to contain_service('carbon-cache').with({
'ensure' => 'running',
'enable' => 'true',
'hasrestart' => 'true',
'hasstatus' => 'true',
'provider' => 'redhat',
'require' => 'File[/etc/init.d/carbon-cache]' }) }
end

shared_context 'RedHat 6 platforms' do
it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({
'ensure' => 'file',
'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/,
'mode' => '0750',
'require' => 'File[/opt/graphite/conf/carbon.conf]',
'notify' => [] }) }
end

shared_context 'RedHat 7 platforms' do
it { is_expected.to contain_exec('graphite-reload-systemd') }
it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({
'ensure' => 'file',
'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/,
'mode' => '0750',
'require' => 'File[/opt/graphite/conf/carbon.conf]',
'notify' => /graphite-reload-systemd/ }) }
end

shared_context 'Debian supported platforms' do
Expand All @@ -67,50 +58,69 @@
'ensure' => 'file', 'owner' => 'www-data', 'group' => 'www-data', 'mode' => '0644' }).that_requires('Package[apache2]') }
it { is_expected.to contain_file('/opt/graphite/webapp/graphite/graphite_wsgi.py').with({
'ensure' => 'link', 'target' => '/opt/graphite/conf/graphite_wsgi.py', 'require' => 'File[/opt/graphite/conf/graphite_wsgi.py]' }) }
it { is_expected.to contain_service('carbon-cache').only_with({
'ensure' => 'running',
'enable' => 'true',
'hasrestart' => 'true',
'hasstatus' => 'true',
'provider' => nil,
'require' => 'File[/etc/init.d/carbon-cache]' }) }
it { is_expected.to contain_file('/etc/init.d/carbon-cache').with({
'ensure' => 'file',
'content' => /^GRAPHITE_DIR="\/opt\/graphite"$/,
'mode' => '0750',
'require' => 'File[/opt/graphite/conf/carbon.conf]',
'notify' => [] }) }
end


context 'Unsupported OS' do
let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }}
it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )}
end

# Loop through various contexts
[ { :osfamily => 'Debian', :lsbdistcodename => 'capybara', :operatingsystem => 'Debian' },
{ :osfamily => 'Debian', :lsbdistcodename => 'squeeze', :operatingsystem => 'Debian' },
{ :osfamily => 'Debian', :lsbdistcodename => 'trusty', :operatingsystem => 'Debian' },
{ :osfamily => 'FreeBSD', :operatingsystemrelease => '8.4-RELEASE-p27', :operatingsystem => 'FreeBSD' },
{ :osfamily => 'RedHat', :operatingsystemrelease => '5.0', :operatingsystem => 'CentOS' },
{ :osfamily => 'RedHat', :operatingsystemrelease => '6.6', :operatingsystem => 'CentOS' },
{ :osfamily => 'RedHat', :operatingsystemrelease => '7.1', :operatingsystem => 'CentOS' },
].each do |myfacts|
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
let :pre_condition do
'include ::graphite'
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('graphite::params') }
it { is_expected.to contain_exec('Initial django db creation') }
it { is_expected.to contain_class('graphite::config_apache') }

context 'OS %s %s' % myfacts.values do
let :facts do myfacts end
let :pre_condition do 'include ::graphite' end
# cron check
it { is_expected.to contain_file('/opt/graphite/bin/carbon-logrotate.sh').with({
'ensure' => 'file', 'mode' => '0544', 'content' => /^CARBON_LOGS_PATH="\/opt\/graphite\/storage\/log"$/ }) }
it { is_expected.to contain_cron('Rotate carbon logs').with({
'command' => '/opt/graphite/bin/carbon-logrotate.sh',
'hour' => '3',
'minute' => '15',
'require' => 'File[/opt/graphite/bin/carbon-logrotate.sh]',
'user' => 'root',}) }

case myfacts[:osfamily]
case facts[:osfamily]
when 'Debian' then
case myfacts[:lsbdistcodename]
when 'capybara' then
it_behaves_like 'Debian unsupported platforms'
else
it_behaves_like 'supported platforms'
it_behaves_like 'Debian supported platforms'

end
it_behaves_like 'Debian supported platforms'
when 'RedHat' then
case myfacts[:operatingsystemrelease]
when /^[6-7]/ then
it_behaves_like 'supported platforms'
it_behaves_like 'RedHat supported platforms'
case myfacts[:operatingsystemrelease]
when /^6/ then
it_behaves_like 'RedHat 6 platforms'
when /^7/ then
it_behaves_like 'RedHat 7 platforms'
end

it_behaves_like 'RedHat supported platforms'
case facts[:operatingsystemrelease]
when /^6/ then
it_behaves_like 'RedHat 6 platforms'
when /^7/ then
it_behaves_like 'RedHat 7 platforms'
else
it_behaves_like 'RedHat unsupported platforms'
it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )}
end
else
it_behaves_like 'Unsupported OS'
it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )}
end

end
end

end
51 changes: 10 additions & 41 deletions spec/classes/graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,23 @@

describe 'graphite', :type => 'class' do

shared_context 'supported' do
it { is_expected.to contain_anchor('graphite::begin').that_comes_before(
'Class[graphite::install]') }
it { is_expected.to contain_class('graphite::install').that_notifies(
'Class[graphite::config]') }
it { is_expected.to contain_class('graphite::config').that_comes_before(
'Anchor[graphite::end]') }
it { is_expected.to contain_anchor('graphite::end') }
end

context 'Unsupported OS' do
let(:facts) {{ :osfamily => 'unsupported', :operatingsystem => 'UnknownOS' }}
it { is_expected.to raise_error(Puppet::Error,/unsupported os,.+\./ )}
end

context 'RedHat supported platforms' do
['6.5','7.5'].each do | operatingsystemrelease |
let(:facts) {{ :osfamily => 'RedHat', :operatingsystemrelease => operatingsystemrelease}}
describe "Release #{operatingsystemrelease}" do
it_behaves_like 'supported'
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
end
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_anchor('graphite::begin').that_comes_before('Class[graphite::install]') }
it { is_expected.to contain_class('graphite::install').that_notifies('Class[graphite::config]') }
it { is_expected.to contain_class('graphite::config').that_comes_before('Anchor[graphite::end]') }
it { is_expected.to contain_anchor('graphite::end') }

context 'RedHat unsupported platforms' do
['5.0'].each do | operatingsystemrelease |
let(:facts) {{ :osfamily => 'RedHat', :operatingsystemrelease => operatingsystemrelease}}
describe "Redhat #{operatingsystemrelease} fails" do
it { expect { is_expected.to contain_class('graphite')}.to raise_error(Puppet::Error, /Unsupported RedHat release/) }
end
end
end

context 'Debian supported platforms' do
['trusty','squeeze', 'vivid', 'precise'].each do | lsbdistcodename |
let(:facts) {{ :osfamily => 'Debian', :lsbdistcodename => lsbdistcodename}}
describe "Lsbdistcodename #{lsbdistcodename}" do
it_behaves_like 'supported'
end
end
end

context 'Debian unsupported platforms' do
['capybara'].each do | lsbdistcodename |
let(:facts) {{ :osfamily => 'Debian', :lsbdistcodename => lsbdistcodename}}
describe "Debian #{lsbdistcodename} fails" do
it { expect { is_expected.to contain_class('graphite')}.to raise_error(Puppet::Error, /Unsupported Debian release/) }
end
end
end

Expand Down
24 changes: 6 additions & 18 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
if ENV['COVERAGE'] == 'yes'
require 'simplecov'
require 'coveralls'

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]

#Coveralls.wear!
SimpleCov.start do
add_filter '/spec/'
add_filter '/.vendor/'
end
end

RSpec.configure do |c|
c.after(:suite) do
RSpec::Puppet::Coverage.report!
RSpec.configure do |c|
c.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end
end

require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts
Loading

0 comments on commit 2e81de6

Please sign in to comment.