sensu-extensions 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/sensu-extensions.gemspec +2 -2
- metadata +3 -25
- data/.gitignore +0 -22
- data/.travis.yml +0 -16
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/spec/assets/config.json +0 -1
- data/spec/assets/extensions/error.rb +0 -17
- data/spec/assets/extensions/extensions_symlinked +0 -1
- data/spec/assets/extensions/mock_check.rb +0 -17
- data/spec/assets/extensions/test.rb +0 -21
- data/spec/assets/extensions_symlinked/symlinked_check.rb +0 -17
- data/spec/extensions_spec.rb +0 -75
- data/spec/helpers.rb +0 -75
- data/spec/loader_spec.rb +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613d8b0f7d1aec78560e2023d0a5bad4409d205f
|
4
|
+
data.tar.gz: b00f9b4f670b6d2a886134735d7b65c16d2f6c65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4588a4111d35514e29af012d1ecd6e359baa3583db8f29a1de01e3176ce61836bf15a689e360cc5e921bd4fa2422f30c3fe02f12ab9e63da4a0db5c0507f9c6d
|
7
|
+
data.tar.gz: f8fa9780a48eef9a716b749dec1555acba4d458898016a6629b226b114879b3ff925eb9d081e0ccb48ab62e255bb013862561fd5636574732985ce0793edb498
|
data/sensu-extensions.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "sensu-extensions"
|
5
|
-
spec.version = "1.7.
|
5
|
+
spec.version = "1.7.1"
|
6
6
|
spec.authors = ["Sean Porter"]
|
7
7
|
spec.email = ["portertech@gmail.com"]
|
8
8
|
spec.summary = "The Sensu extension loader library"
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.homepage = "https://github.com/sensu/sensu-extensions"
|
11
11
|
spec.license = "MIT"
|
12
12
|
|
13
|
-
spec.files =
|
13
|
+
spec.files = Dir.glob("lib/**/*") + %w[sensu-extensions.gemspec README.md LICENSE.txt]
|
14
14
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|
@@ -199,25 +199,12 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
-
- ".gitignore"
|
203
|
-
- ".travis.yml"
|
204
|
-
- Gemfile
|
205
202
|
- LICENSE.txt
|
206
203
|
- README.md
|
207
|
-
- Rakefile
|
208
204
|
- lib/sensu/extensions.rb
|
209
205
|
- lib/sensu/extensions/constants.rb
|
210
206
|
- lib/sensu/extensions/loader.rb
|
211
207
|
- sensu-extensions.gemspec
|
212
|
-
- spec/assets/config.json
|
213
|
-
- spec/assets/extensions/error.rb
|
214
|
-
- spec/assets/extensions/extensions_symlinked
|
215
|
-
- spec/assets/extensions/mock_check.rb
|
216
|
-
- spec/assets/extensions/test.rb
|
217
|
-
- spec/assets/extensions_symlinked/symlinked_check.rb
|
218
|
-
- spec/extensions_spec.rb
|
219
|
-
- spec/helpers.rb
|
220
|
-
- spec/loader_spec.rb
|
221
208
|
homepage: https://github.com/sensu/sensu-extensions
|
222
209
|
licenses:
|
223
210
|
- MIT
|
@@ -242,13 +229,4 @@ rubygems_version: 2.6.3
|
|
242
229
|
signing_key:
|
243
230
|
specification_version: 4
|
244
231
|
summary: The Sensu extension loader library
|
245
|
-
test_files:
|
246
|
-
- spec/assets/config.json
|
247
|
-
- spec/assets/extensions/error.rb
|
248
|
-
- spec/assets/extensions/extensions_symlinked
|
249
|
-
- spec/assets/extensions/mock_check.rb
|
250
|
-
- spec/assets/extensions/test.rb
|
251
|
-
- spec/assets/extensions_symlinked/symlinked_check.rb
|
252
|
-
- spec/extensions_spec.rb
|
253
|
-
- spec/helpers.rb
|
254
|
-
- spec/loader_spec.rb
|
232
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.0.0
|
5
|
-
- 2.1.0
|
6
|
-
- 2.2.0
|
7
|
-
- 2.2.3
|
8
|
-
- 2.3.0
|
9
|
-
- jruby-9.0.5.0
|
10
|
-
before_install:
|
11
|
-
- gem update --system
|
12
|
-
- gem --version
|
13
|
-
- gem install bundler --version 1.11.2
|
14
|
-
notifications:
|
15
|
-
irc:
|
16
|
-
- "irc.freenode.net#sensu"
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/spec/assets/config.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{}
|
@@ -1 +0,0 @@
|
|
1
|
-
../extensions_symlinked
|
data/spec/extensions_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
-
require "sensu/extensions"
|
3
|
-
|
4
|
-
describe "Sensu::Extensions" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@assets_dir = File.join(File.dirname(__FILE__), "assets")
|
9
|
-
@extension_dir = File.join(@assets_dir, "extensions")
|
10
|
-
@extension_file = File.join(@extension_dir, "test.rb")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "can provide the extensions API" do
|
14
|
-
expect(Sensu::Extensions).to respond_to(:load)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "can provide an instance of Loader" do
|
18
|
-
extensions = Sensu::Extensions.load
|
19
|
-
expect(extensions).to be_instance_of(Sensu::Extensions::Loader)
|
20
|
-
expect(extensions.loaded_files).to be_empty
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can retrive the current loaded loader" do
|
24
|
-
extensions = Sensu::Extensions.load
|
25
|
-
expect(Sensu::Extensions.get).to eq(extensions)
|
26
|
-
expect(Sensu::Extensions.get).to eq(extensions)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "can load up a loader if one doesn't exist" do
|
30
|
-
extensions = Sensu::Extensions.get
|
31
|
-
expect(extensions).to be_an_instance_of(Sensu::Extensions::Loader)
|
32
|
-
expect(Sensu::Extensions.get).to eq(extensions)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "can load an extension from a file" do
|
36
|
-
extensions = Sensu::Extensions.load(:extension_file => @extension_file)
|
37
|
-
expect(extensions.loaded_files.size).to eq(1)
|
38
|
-
expect(extensions.handler_exists?("test")).to be(true)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "can load extensions from a directory" do
|
42
|
-
extensions = Sensu::Extensions.load(:extension_dir => @extension_dir)
|
43
|
-
expect(extensions.loaded_files.size).to eq(3)
|
44
|
-
expect(extensions.handler_exists?("test")).to be(true)
|
45
|
-
expect(extensions.check_exists?("mock_check")).to be(true)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "can load extensions from one or more directories" do
|
49
|
-
extensions = Sensu::Extensions.load(:extension_dirs => [@extension_dir])
|
50
|
-
expect(extensions.loaded_files.size).to eq(3)
|
51
|
-
expect(extensions.handler_exists?("test")).to be(true)
|
52
|
-
expect(extensions.check_exists?("mock_check")).to be(true)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "can load the built-in extensions" do
|
56
|
-
extensions = Sensu::Extensions.load
|
57
|
-
expect(extensions.filter_exists?("occurrences")).to be(true)
|
58
|
-
expect(extensions.mutator_exists?("json")).to be(true)
|
59
|
-
expect(extensions.mutator_exists?("ruby_hash")).to be(true)
|
60
|
-
expect(extensions.mutator_exists?("only_check_output")).to be(true)
|
61
|
-
expect(extensions.handler_exists?("debug")).to be(true)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "can load extensions from gems" do
|
65
|
-
options = {
|
66
|
-
:extensions => {
|
67
|
-
"system-profile" => {
|
68
|
-
:version => "1.0.0"
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
extensions = Sensu::Extensions.load(options)
|
73
|
-
expect(extensions.check_exists?("system_profile")).to be(true)
|
74
|
-
end
|
75
|
-
end
|
data/spec/helpers.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require "eventmachine"
|
3
|
-
require "sensu/logger"
|
4
|
-
require "sensu/settings"
|
5
|
-
require "securerandom"
|
6
|
-
|
7
|
-
module Helpers
|
8
|
-
def timer(delay, &callback)
|
9
|
-
periodic_timer = EM::PeriodicTimer.new(delay) do
|
10
|
-
callback.call
|
11
|
-
periodic_timer.cancel
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def async_wrapper(&callback)
|
16
|
-
EM.run do
|
17
|
-
timer(10) do
|
18
|
-
raise "test timed out"
|
19
|
-
end
|
20
|
-
callback.call
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def async_done
|
25
|
-
EM.stop_event_loop
|
26
|
-
end
|
27
|
-
|
28
|
-
def logger
|
29
|
-
Sensu::Logger.get(:log_level => :fatal)
|
30
|
-
end
|
31
|
-
|
32
|
-
def settings
|
33
|
-
asset_dir = File.join(File.dirname(__FILE__), "assets")
|
34
|
-
config_file = File.join(asset_dir, "config.json")
|
35
|
-
Sensu::Settings.get(:config_file => config_file)
|
36
|
-
end
|
37
|
-
|
38
|
-
def epoch
|
39
|
-
Time.now.to_i
|
40
|
-
end
|
41
|
-
|
42
|
-
def client_template
|
43
|
-
{
|
44
|
-
:name => "i-424242",
|
45
|
-
:address => "127.0.0.1",
|
46
|
-
:subscriptions => [
|
47
|
-
"test"
|
48
|
-
]
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def check_template
|
53
|
-
{
|
54
|
-
:name => "test",
|
55
|
-
:command => "echo WARNING && exit 1",
|
56
|
-
:issued => epoch
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
def event_template
|
61
|
-
client = client_template
|
62
|
-
client[:timestamp] = epoch
|
63
|
-
check = check_template
|
64
|
-
check[:output] = "WARNING"
|
65
|
-
check[:status] = 1
|
66
|
-
check[:history] = [1]
|
67
|
-
{
|
68
|
-
:id => SecureRandom.uuid,
|
69
|
-
:client => client,
|
70
|
-
:check => check,
|
71
|
-
:occurrences => 1,
|
72
|
-
:action => :create
|
73
|
-
}
|
74
|
-
end
|
75
|
-
end
|
data/spec/loader_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
-
require "sensu/extensions/loader"
|
3
|
-
|
4
|
-
describe "Sensu::Extensions::Loader" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
before do
|
8
|
-
@loader = Sensu::Extensions::Loader.new
|
9
|
-
@assets_dir = File.join(File.dirname(__FILE__), "assets")
|
10
|
-
@extension_dir = File.join(@assets_dir, "extensions")
|
11
|
-
@extension_file = File.join(@extension_dir, "test.rb")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "can provide the extensions loader API" do
|
15
|
-
expect(@loader).to respond_to(:load_file, :load_directory, :load_instances,
|
16
|
-
:warnings, :loaded_files, :[], :all,
|
17
|
-
:bridges, :checks, :mutators, :handlers)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "can load an extension from a file" do
|
21
|
-
@loader.load_file(@extension_file)
|
22
|
-
expect(@loader.warnings.size).to eq(1)
|
23
|
-
expect(@loader.loaded_files.size).to eq(1)
|
24
|
-
expect(@loader.loaded_files.first).to eq(File.expand_path(@extension_file))
|
25
|
-
extension = Sensu::Extension::Test.new
|
26
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
27
|
-
end
|
28
|
-
|
29
|
-
it "can attempt to load an extension with a script error" do
|
30
|
-
script = File.join(@extension_dir, "error.rb")
|
31
|
-
@loader.load_file(script)
|
32
|
-
warnings = @loader.warnings
|
33
|
-
expect(warnings.size).to eq(3)
|
34
|
-
messages = warnings.map do |warning|
|
35
|
-
warning[:message]
|
36
|
-
end
|
37
|
-
expect(messages).to include("loading extension file")
|
38
|
-
expect(messages).to include("ignoring extension")
|
39
|
-
expect(@loader.loaded_files).to be_empty
|
40
|
-
end
|
41
|
-
|
42
|
-
it "can load extensions from a directory containing directory symlinks" do
|
43
|
-
@loader.load_directory(@extension_dir)
|
44
|
-
expect(@loader.warnings.size).to eq(7)
|
45
|
-
expect(@loader.loaded_files.size).to eq(3)
|
46
|
-
extension = Sensu::Extension::Test.new
|
47
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
48
|
-
extension = Sensu::Extension::MockCheck.new
|
49
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
50
|
-
end
|
51
|
-
|
52
|
-
it "can attempt to load extensions from a nonexistent directory" do
|
53
|
-
@loader.load_directory("/tmp/bananaphone")
|
54
|
-
expect(@loader.warnings.size).to eq(1)
|
55
|
-
expect(@loader.loaded_files).to be_empty
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can load instances of the built-in extensions and provide accessors" do
|
59
|
-
@loader.load_instances
|
60
|
-
expect(@loader.handler_exists?("debug")).to be(true)
|
61
|
-
extension = @loader[:handlers]["debug"]
|
62
|
-
expect(extension).to be_instance_of(Sensu::Extension::Debug)
|
63
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
64
|
-
expect(@loader.handlers).to include(extension.definition)
|
65
|
-
expect(@loader.all).to include(extension)
|
66
|
-
expect(@loader.filter_exists?("occurrences")).to be(true)
|
67
|
-
expect(@loader.mutator_exists?("json")).to be(true)
|
68
|
-
expect(@loader.mutator_exists?("ruby_hash")).to be(true)
|
69
|
-
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "can load instances of the built-in and loaded extensions" do
|
73
|
-
@loader.load_file(@extension_file)
|
74
|
-
@loader.load_instances
|
75
|
-
expect(@loader.handler_exists?("test")).to be(true)
|
76
|
-
extension = @loader[:handlers]["test"]
|
77
|
-
expect(extension).to be_instance_of(Sensu::Extension::Test)
|
78
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
79
|
-
expect(@loader.handlers).to include(extension.definition)
|
80
|
-
expect(@loader.all).to include(extension)
|
81
|
-
extension_alias = @loader[:handlers]["test_alias"]
|
82
|
-
expect(extension_alias).to eq(extension)
|
83
|
-
expect(@loader.handlers).to include(extension_alias.definition)
|
84
|
-
expect(@loader.all).to include(extension_alias)
|
85
|
-
expect(@loader.all.size).to eq(@loader.all.uniq.size)
|
86
|
-
expect(@loader.handler_exists?("debug")).to be(true)
|
87
|
-
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "can load specific extension categories for a sensu client" do
|
91
|
-
@loader.load_instances("client")
|
92
|
-
expect(@loader.handler_exists?("debug")).to be(false)
|
93
|
-
expect(@loader.mutator_exists?("only_check_output")).to be(false)
|
94
|
-
expect(@loader.check_exists?("mock_check")).to be(true)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "can load specific extension categories for a sensu server" do
|
98
|
-
@loader.load_instances("server")
|
99
|
-
expect(@loader.handler_exists?("debug")).to be(true)
|
100
|
-
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
101
|
-
expect(@loader.check_exists?("mock_check")).to be(false)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "can load a specific extension from a gem" do
|
105
|
-
@loader.load_gem("sensu-extensions-system-profile", "1.0.0")
|
106
|
-
@loader.load_instances
|
107
|
-
expect(@loader.loaded_gems).to include("sensu-extensions-system-profile")
|
108
|
-
expect(@loader.check_exists?("system_profile")).to be(true)
|
109
|
-
extension = @loader[:checks]["system_profile"]
|
110
|
-
expect(extension).to be_instance_of(Sensu::Extension::SystemProfile)
|
111
|
-
expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
112
|
-
expect(@loader.checks).to include(extension.definition)
|
113
|
-
expect(@loader.all).to include(extension)
|
114
|
-
end
|
115
|
-
end
|