Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several Rubocop issues #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :development, :test do
gem 'rake', :require => false
gem 'rspec','< 3.2.0', :require => false
gem 'rspec-puppet','~> 2.2', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'simplecov', :require => false
gem 'puppet_facts', :require => false
gem 'json_pure','~> 1.8', :require => false
gem 'json', :require => false
gem 'metadata-json-lint', :require => false
gem 'rake', require: false
gem 'rspec', '< 3.2.0', require: false
gem 'rspec-puppet', '~> 2.2', require: false
gem 'puppetlabs_spec_helper', require: false
gem 'puppet-lint', require: false
gem 'simplecov', require: false
gem 'puppet_facts', require: false
gem 'json_pure', '~> 1.8', require: false
gem 'json', require: false
gem 'metadata-json-lint', require: false
gem 'rspec-puppet-facts', '~> 0.10'
end

group :system_tests do
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
gem 'beaker-rspec', require: false
gem 'serverspec', require: false
end

if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
gem 'facter', facterversion, require: false
else
gem 'facter', :require => false
gem 'facter', require: false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
gem 'puppet', puppetversion, require: false
else
gem 'puppet', :require => false
gem 'puppet', require: false
end

# vim:ft=ruby
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'

PuppetLint.configuration.send('relative')
PuppetLint.configuration.send("disable_80chars")
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.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.ignore_paths = ["pkg/**/*", "vendor/**/*", "spec/**/*"]
PuppetLint.configuration.ignore_paths = ['pkg/**/*', 'vendor/**/*', 'spec/**/*']

desc "Run syntax, lint, and beaker/rspec tests."
task :test => [:validate, :lint, :spec]
desc 'Run syntax, lint, and beaker/rspec tests.'
task test: [:validate, :lint, :spec]
20 changes: 8 additions & 12 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
require 'spec_helper_acceptance'

describe 'influxdb class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do

describe 'influxdb class', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
context 'default parameters' do

pp = <<-EOS
class { 'influxdb::server': }
EOS

it 'should work with no errors' do
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, catch_failures: true)
# wait because influxdb takes few seconds to start
shell("/bin/sleep 10")
shell('/bin/sleep 10')
end

describe package('influxdb') do
Expand All @@ -23,8 +21,8 @@ class { 'influxdb::server': }
it { should be_listening }
end

describe process("influxdb") do
its(:user) { should eq "influxdb" }
describe process('influxdb') do
its(:user) { should eq 'influxdb' }
end

describe port('8089') do
Expand All @@ -33,19 +31,17 @@ class { 'influxdb::server': }
end

context 'change some ports' do

it 'should change API port to 8089' do
pp = <<-EOS
class { 'influxdb::server': api_port => 8089}
EOS

apply_manifest(pp, :catch_failures => true)
shell("/bin/sleep 10")
apply_manifest(pp, catch_failures: true)
shell('/bin/sleep 10')
end

describe port('8089') do
it { should be_listening }
end
end

end
end
25 changes: 12 additions & 13 deletions spec/classes/config_template_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper'

describe 'influxdb::server', :type => :class do

describe 'influxdb::server', type: :class do
default = {
'meta_bind_address' => ':8088',
'meta_http_bind_address' => ':8091',
Expand All @@ -11,7 +10,7 @@
'leader_lease_timeout' => '500ms',
'commit_timeout' => '50ms',
'data_dir' => '/var/opt/influxdb/data',
'max_wal_size' => 104857600,
'max_wal_size' => 104_857_600,
'wal_flush_interval' => '10m',
'wal_partition_flush_delay' => '2s',
'shard_writer_timeout' => '5s',
Expand All @@ -36,7 +35,7 @@
'continuous_queries_enabled' => true,
'hinted_handoff_enabled' => true,
'hinted_handoff_dir' => '/var/opt/influxdb/hh',
'hinted_handoff_max_size' => 1073741824,
'hinted_handoff_max_size' => 1_073_741_824,
'hinted_handoff_max_age' => '168h',
'hinted_handoff_retry_rate_limit' => 0,
'hinted_handoff_retry_interval' => '1s',
Expand All @@ -62,22 +61,22 @@

case facts[:osfamily]
when 'Debian'
let (:params) {{
:retention_check_interval => '20m',
:collectd_options => {
'enabled' => true,
'batch-size' => 5000,
let(:params) do
{
retention_check_interval: '20m',
collectd_options: {
'enabled' => true,
'batch-size' => 5000
}
}
}}
end

it { is_expected.to contain_file('/etc/influxdb/influxdb.conf') }
it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/bind-address = ":8088"/) }
it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/check-interval = "20m"/) }
it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/wal-dir = "\/var\/lib\/influxdb\/wal"/) }
it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(%r{wal-dir = "/var/lib/influxdb/wal"}) }
it { is_expected.to contain_file('/etc/influxdb/influxdb.conf').with_content(/batch-size = 5000/) }
end

end
end

end
6 changes: 3 additions & 3 deletions spec/classes/default_influxdb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'spec_helper'

describe 'influxdb::server', :type => :class do
describe 'influxdb::server', type: :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let (:params) {{ :influxd_opts => 'OPTIONS' }}
let(:params) { { influxd_opts: 'OPTIONS' } }
let(:facts) do
facts
end
it { is_expected.to contain_file('/etc/default/influxdb') }
it { is_expected.to contain_file('/etc/default/influxdb').with_content(/INFLUXD_OPTS="OPTIONS"/) }
it { is_expected.to contain_file('/etc/default/influxdb').with_content(/STDERR=\/var\/log\/influxdb\/influxd\.log/) }
it { is_expected.to contain_file('/etc/default/influxdb').with_content(%r{STDERR=/var/log/influxdb/influxd.log}) }
end
end
end
38 changes: 18 additions & 20 deletions spec/classes/influxdb_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
require 'spec_helper'

describe 'influxdb::server', :type => :class do

describe 'influxdb::server', type: :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
it { should contain_class('influxdb::server::install') }
it { should contain_class('influxdb::repo') }
it { should contain_class('influxdb::server::config') }
it { should contain_class('influxdb::server::service') }
case facts[:osfamily]
when 'Debian'
it { should contain_class('influxdb::repo::apt') }
context "with $manage_repos => false" do
let (:params) {{ :manage_repos => false }}
it { should_not contain_class('influxdb::repo::apt') }
end
when 'RedHat'
it { should contain_class('influxdb::repo::yum') }
context "with $manage_repos => false" do
let (:params) {{ :manage_repos => false }}
it { should_not contain_class('influxdb::repo::yum') }
it { should contain_class('influxdb::server::install') }
it { should contain_class('influxdb::repo') }
it { should contain_class('influxdb::server::config') }
it { should contain_class('influxdb::server::service') }
case facts[:osfamily]
when 'Debian'
it { should contain_class('influxdb::repo::apt') }
context 'with $manage_repos => false' do
let(:params) { { manage_repos: false } }
it { should_not contain_class('influxdb::repo::apt') }
end
when 'RedHat'
it { should contain_class('influxdb::repo::yum') }
context 'with $manage_repos => false' do
let(:params) { { manage_repos: false } }
it { should_not contain_class('influxdb::repo::yum') }
end
end
end
end
end

end
17 changes: 8 additions & 9 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper'

describe 'influxdb' do

on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
it { should contain_class('influxdb') }
it { is_expected.to compile.with_all_deps }
end
end
it { should contain_class('influxdb') }
it { is_expected.to compile.with_all_deps }
end
end
end
14 changes: 7 additions & 7 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'spec_helper'

describe 'influxdb::params', :type => :class do
describe 'influxdb::params', type: :class do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
:lsbdistcodename => 'precice',
osfamily: 'Debian',
operatingsystem: 'Ubuntu',
operatingsystemrelease: '12.04',
lsbdistcodename: 'precice'
}
end
it { is_expected.to contain_class("influxdb::params") }
end
it { is_expected.to contain_class('influxdb::params') }
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts
include RspecPuppetFacts
11 changes: 5 additions & 6 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'


unless ENV['RS_PROVISION'] == 'no'
# This will install the latest available package on el and deb based
# systems fail on windows and osx, and install via gem on other *nixes
foss_opts = { :default_action => 'gem_install' }
if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
foss_opts = { default_action: 'gem_install' }
default.is_pe? ? install_pe : install_puppet(foss_opts)

hosts.each do |host|
if host['platform'] =~ /debian/
Expand All @@ -17,7 +16,7 @@
end
end

UNSUPPORTED_PLATFORMS = ['Suse','windows','AIX','Solaris']
UNSUPPORTED_PLATFORMS = %w(Suse windows AIX Solaris).freeze

RSpec.configure do |c|
# Project root
Expand All @@ -31,8 +30,8 @@
# Install module and dependencies
hosts.each do |host|
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
on host, puppet('module install puppetlabs-stdlib --version 3.2.0'), { :acceptable_exit_codes => [0,1] }
copy_module_to(host, :source => proj_root, :module_name => 'influxdb')
on host, puppet('module install puppetlabs-stdlib --version 3.2.0'), acceptable_exit_codes: [0, 1]
copy_module_to(host, source: proj_root, module_name: 'influxdb')
end
end
end