-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* correct descriptions and crit and warn options * handle required options * update changelog * set critical as default severity * use integration testing framework
- Loading branch information
1 parent
3e1e8ea
commit 22d5673
Showing
18 changed files
with
210 additions
and
29 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 |
---|---|---|
|
@@ -16,3 +16,7 @@ mkmf.log | |
.DS_Store | ||
.idea/* | ||
*.gem | ||
|
||
# test-kitchen | ||
.kitchen/ | ||
.kitchen.list.yml |
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,29 @@ | ||
--- | ||
driver: | ||
name: docker | ||
use_sudo: false | ||
|
||
provisioner: | ||
name: shell | ||
data_path: . | ||
script: test/fixtures/bootstrap.sh | ||
|
||
verifier: | ||
ruby_bindir: /usr/local/bin | ||
|
||
platforms: | ||
- name: debian-8 | ||
|
||
suites: | ||
- name: ruby-21 | ||
driver: | ||
image: ruby:2.1-slim | ||
- name: ruby-22 | ||
driver: | ||
image: ruby:2.2-slim | ||
- name: ruby-230 | ||
driver: | ||
image: ruby:2.3.0-slim | ||
- name: ruby-241 | ||
driver: | ||
image: ruby:2.4.1-slim |
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
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
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
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
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
require 'date' | ||
require_relative 'lib/sensu-plugins-logs' | ||
|
||
Gem::Specification.new do |s| | ||
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength | ||
s.authors = ['Sensu-Plugins and contributors'] | ||
# s.cert_chain = ['certs/sensu-plugins.pem'] | ||
s.date = Date.today.to_s | ||
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s| | |
regex matching. Includes various log handlers.' | ||
s.email = '<[email protected]>' | ||
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) } | ||
s.files = Dir.glob('{bin,lib}/**/*') + %w(LICENSE README.md CHANGELOG.md) | ||
s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md] | ||
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-logs' | ||
s.license = 'MIT' | ||
s.metadata = { 'maintainer' => 'sensu-plugin', | ||
|
@@ -32,13 +32,19 @@ Gem::Specification.new do |s| | |
|
||
s.add_runtime_dependency 'sensu-plugin', '~> 1.2' | ||
|
||
s.add_development_dependency 'bundler', '~> 1.7' | ||
s.add_development_dependency 'bundler', '~> 1.15' | ||
s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4' | ||
s.add_development_dependency 'github-markup', '~> 1.3' | ||
s.add_development_dependency 'kitchen-docker', '~> 2.6' | ||
s.add_development_dependency 'kitchen-localhost', '~> 0.3' | ||
# locked to keep ruby 2.1 support, this is pulled in by test-kitchen | ||
s.add_development_dependency 'mixlib-shellout', ['< 2.3.0', '~> 2.2'] | ||
s.add_development_dependency 'pry', '~> 0.10' | ||
s.add_development_dependency 'rubocop', '~> 0.40.0' | ||
s.add_development_dependency 'rspec', '~> 3.1' | ||
s.add_development_dependency 'rake', '~> 10.0' | ||
s.add_development_dependency 'rake', '~> 12.0' | ||
s.add_development_dependency 'redcarpet', '~> 3.2' | ||
s.add_development_dependency 'yard', '~> 0.8' | ||
s.add_development_dependency 'rspec', '~> 3.4' | ||
s.add_development_dependency 'rubocop', '~> 0.49.0' | ||
s.add_development_dependency 'serverspec', '~> 2.36.1' | ||
s.add_development_dependency 'test-kitchen', '~> 1.6' | ||
s.add_development_dependency 'yard', '~> 0.9.11' | ||
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,28 @@ | ||
#!/bin/bash | ||
# | ||
# Set up a super simple web server and make it accept GET and POST requests | ||
# for Sensu plugin testing. | ||
# | ||
|
||
set -e | ||
|
||
# base utilities that need to exist to start bootatraping | ||
apt-get update | ||
apt-get install -y build-essential | ||
|
||
# setup the rubies | ||
source /etc/profile | ||
DATA_DIR=/tmp/kitchen/data | ||
RUBY_HOME=${MY_RUBY_HOME} | ||
|
||
# Start bootatraping | ||
|
||
## install some required deps for pg_gem to install | ||
|
||
|
||
# End of Actual bootatrap | ||
|
||
# Install gems | ||
cd $DATA_DIR | ||
SIGN_GEM=false gem build sensu-plugins-logs.gemspec | ||
gem install sensu-plugins-logs-*.gem |
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,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'shared_spec' | ||
|
||
gem_path = '/usr/local/bin' | ||
check_name = 'check-log.rb' | ||
check = "#{gem_path}/#{check_name}" | ||
log_file = "#{File.dirname(__FILE__)}/test.log" | ||
|
||
describe 'ruby environment' do | ||
it_behaves_like 'ruby checks', check | ||
end | ||
|
||
describe command(check.to_s) do | ||
it 'fails due to missing required parameters' do | ||
expect(subject.exit_status).to eq 2 | ||
expect(subject.stdout).to match(/You must supply -q PAT!/) | ||
end | ||
end | ||
|
||
describe command("#{check} -q anything -f /dev/null") do | ||
it 'returns ok' do | ||
expect(subject.exit_status).to eq 0 | ||
expect(subject.stdout).to match(/CheckLog OK: 0 warnings, 0 criticals for pattern anything./) | ||
end | ||
end | ||
|
||
describe command("#{check} -q error -f #{log_file}") do | ||
it 'returns critical' do | ||
expect(subject.exit_status).to eq 2 | ||
expect(subject.stdout).to match(/CheckLog CRITICAL: 0 warnings, 1 criticals for pattern error./) | ||
end | ||
end | ||
|
||
describe command("#{check} --warn-only --warn 1 -q error -f #{log_file}") do | ||
before do | ||
`rm -rf /var/cache/check-log/` | ||
end | ||
it 'returns warning' do | ||
expect(subject.exit_status).to eq 1 | ||
expect(subject.stdout).to match(/CheckLog WARNING: 1 warnings, 0 criticals for pattern error./) | ||
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
shared_examples_for 'ruby checks' do |check| | ||
describe command('which ruby') do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match(/\/usr\/local\/bin\/ruby/) } | ||
end | ||
|
||
describe command('which gem') do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match(/\/usr\/local\/bin\/gem/) } | ||
end | ||
|
||
describe command("which #{check}") do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match(Regexp.new(Regexp.escape(check))) } | ||
end | ||
|
||
describe file(check) do | ||
it { should be_file } | ||
it { should be_executable } | ||
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'serverspec' | ||
|
||
set :backend, :exec |
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,5 @@ | ||
debug | ||
info | ||
warn | ||
error | ||
fatal |
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 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'shared_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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'shared_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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'shared_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,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'shared_spec' |
This file was deleted.
Oops, something went wrong.