sensu-extensions 0.0.5 → 1.0.0
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 +1 -1
- data/spec/extensions_spec.rb +19 -19
- data/spec/handlers/debug_spec.rb +2 -2
- data/spec/loader_spec.rb +38 -38
- data/spec/mutators/json_spec.rb +2 -2
- data/spec/mutators/only_check_output_spec.rb +2 -2
- data/spec/mutators/ruby_hash_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f57126991763e89e26528b447af7a360ef8dc68
|
4
|
+
data.tar.gz: 0544fed9f3a43312082531cf59db8ddae44f2fc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12db8e2e16ac764b716d58f2745c067c8b7550f66dbd7de5397ca76be5855c7de2f0140cccff865ddcf2a657d0f539778dca3a3721485f9b8a350ab48018303d
|
7
|
+
data.tar.gz: 330bff41a52ef0283f81fc47623d7b2c5b746e702132f4a97dd9aa7c00f55ef400d2326feca48c8d512a55ab8313aebc2fd8fd4c9963f5c06a1f8dfd97151bb7
|
data/sensu-extensions.gemspec
CHANGED
data/spec/extensions_spec.rb
CHANGED
@@ -11,52 +11,52 @@ describe "Sensu::Extensions" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can provide the extensions API" do
|
14
|
-
Sensu::Extensions.
|
14
|
+
expect(Sensu::Extensions).to respond_to(:load)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "can provide an instance of Loader" do
|
18
18
|
extensions = Sensu::Extensions.load
|
19
|
-
extensions.
|
20
|
-
extensions.loaded_files.
|
19
|
+
expect(extensions).to be_instance_of(Sensu::Extensions::Loader)
|
20
|
+
expect(extensions.loaded_files).to be_empty
|
21
21
|
end
|
22
22
|
|
23
23
|
it "can retrive the current loaded loader" do
|
24
24
|
extensions = Sensu::Extensions.load
|
25
|
-
Sensu::Extensions.get.
|
26
|
-
Sensu::Extensions.get.
|
25
|
+
expect(Sensu::Extensions.get).to eq(extensions)
|
26
|
+
expect(Sensu::Extensions.get).to eq(extensions)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "can load up a loader if one doesn't exist" do
|
30
30
|
extensions = Sensu::Extensions.get
|
31
|
-
extensions.
|
32
|
-
Sensu::Extensions.get.
|
31
|
+
expect(extensions).to be_an_instance_of(Sensu::Extensions::Loader)
|
32
|
+
expect(Sensu::Extensions.get).to eq(extensions)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "can load an extension from a file" do
|
36
36
|
extensions = Sensu::Extensions.load(:extension_file => @extension_file)
|
37
|
-
extensions.loaded_files.size.
|
38
|
-
extensions.handler_exists?("test").
|
37
|
+
expect(extensions.loaded_files.size).to eq(1)
|
38
|
+
expect(extensions.handler_exists?("test")).to be(true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "can load extensions from a directory" do
|
42
42
|
extensions = Sensu::Extensions.load(:extension_dir => @extension_dir)
|
43
|
-
extensions.loaded_files.size.
|
44
|
-
extensions.handler_exists?("test").
|
45
|
-
extensions.check_exists?("mock_check").
|
43
|
+
expect(extensions.loaded_files.size).to eq(2)
|
44
|
+
expect(extensions.handler_exists?("test")).to be(true)
|
45
|
+
expect(extensions.check_exists?("mock_check")).to be(true)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "can load extensions from one or more directories" do
|
49
49
|
extensions = Sensu::Extensions.load(:extension_dirs => [@extension_dir])
|
50
|
-
extensions.loaded_files.size.
|
51
|
-
extensions.handler_exists?("test").
|
52
|
-
extensions.check_exists?("mock_check").
|
50
|
+
expect(extensions.loaded_files.size).to eq(2)
|
51
|
+
expect(extensions.handler_exists?("test")).to be(true)
|
52
|
+
expect(extensions.check_exists?("mock_check")).to be(true)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "can load the built-in extensions" do
|
56
56
|
extensions = Sensu::Extensions.load
|
57
|
-
extensions.mutator_exists?("json").
|
58
|
-
extensions.mutator_exists?("ruby_hash").
|
59
|
-
extensions.mutator_exists?("only_check_output").
|
60
|
-
extensions.handler_exists?("debug").
|
57
|
+
expect(extensions.mutator_exists?("json")).to be(true)
|
58
|
+
expect(extensions.mutator_exists?("ruby_hash")).to be(true)
|
59
|
+
expect(extensions.mutator_exists?("only_check_output")).to be(true)
|
60
|
+
expect(extensions.handler_exists?("debug")).to be(true)
|
61
61
|
end
|
62
62
|
end
|
data/spec/handlers/debug_spec.rb
CHANGED
data/spec/loader_spec.rb
CHANGED
@@ -12,86 +12,86 @@ describe "Sensu::Extensions::Loader" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "can provide the extensions loader API" do
|
15
|
-
@loader.
|
16
|
-
|
17
|
-
|
15
|
+
expect(@loader).to respond_to(:load_file, :load_directory, :load_instances,
|
16
|
+
:warnings, :loaded_files, :[], :all,
|
17
|
+
:bridges, :checks, :mutators, :handlers)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "can load an extension from a file" do
|
21
21
|
@loader.load_file(@extension_file)
|
22
|
-
@loader.warnings.size.
|
23
|
-
@loader.loaded_files.size.
|
24
|
-
@loader.loaded_files.first.
|
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
25
|
extension = Sensu::Extension::Test.new
|
26
|
-
extension.
|
26
|
+
expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
27
27
|
end
|
28
28
|
|
29
29
|
it "can attempt to load an extension with a script error" do
|
30
30
|
script = File.join(@extension_dir, "error.rb")
|
31
31
|
@loader.load_file(script)
|
32
32
|
warnings = @loader.warnings
|
33
|
-
warnings.size.
|
33
|
+
expect(warnings.size).to eq(3)
|
34
34
|
messages = warnings.map do |warning|
|
35
35
|
warning[:message]
|
36
36
|
end
|
37
|
-
messages.
|
38
|
-
messages.
|
39
|
-
@loader.loaded_files.
|
37
|
+
expect(messages).to include("loading extension file")
|
38
|
+
expect(messages).to include("ignoring extension")
|
39
|
+
expect(@loader.loaded_files).to be_empty
|
40
40
|
end
|
41
41
|
|
42
42
|
it "can load extensions from a directory" do
|
43
43
|
@loader.load_directory(@extension_dir)
|
44
|
-
@loader.warnings.size.
|
45
|
-
@loader.loaded_files.size.
|
44
|
+
expect(@loader.warnings.size).to eq(6)
|
45
|
+
expect(@loader.loaded_files.size).to eq(2)
|
46
46
|
extension = Sensu::Extension::Test.new
|
47
|
-
extension.
|
47
|
+
expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
48
48
|
extension = Sensu::Extension::MockCheck.new
|
49
|
-
extension.
|
49
|
+
expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
50
50
|
end
|
51
51
|
|
52
52
|
it "can attempt to load extensions from a nonexistent directory" do
|
53
53
|
@loader.load_directory("/tmp/bananaphone")
|
54
|
-
@loader.warnings.size.
|
55
|
-
@loader.loaded_files.
|
54
|
+
expect(@loader.warnings.size).to eq(1)
|
55
|
+
expect(@loader.loaded_files).to be_empty
|
56
56
|
end
|
57
57
|
|
58
58
|
it "can load instances of the built-in extensions and provide accessors" do
|
59
59
|
@loader.load_instances
|
60
|
-
@loader.handler_exists?("debug").
|
60
|
+
expect(@loader.handler_exists?("debug")).to be(true)
|
61
61
|
extension = @loader[:handlers]["debug"]
|
62
|
-
extension.
|
63
|
-
extension.
|
64
|
-
@loader.handlers.
|
65
|
-
@loader.all.
|
66
|
-
@loader.mutator_exists?("json").
|
67
|
-
@loader.mutator_exists?("ruby_hash").
|
68
|
-
@loader.mutator_exists?("only_check_output").
|
62
|
+
expect(extension).to be_instance_of(Sensu::Extension::Debug)
|
63
|
+
expect(extension).to respond_to(:name, :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.mutator_exists?("json")).to be(true)
|
67
|
+
expect(@loader.mutator_exists?("ruby_hash")).to be(true)
|
68
|
+
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "can load instances of the built-in and loaded extensions" do
|
72
72
|
@loader.load_file(@extension_file)
|
73
73
|
@loader.load_instances
|
74
|
-
@loader.handler_exists?("test").
|
74
|
+
expect(@loader.handler_exists?("test")).to be(true)
|
75
75
|
extension = @loader[:handlers]["test"]
|
76
|
-
extension.
|
77
|
-
extension.
|
78
|
-
@loader.handlers.
|
79
|
-
@loader.all.
|
80
|
-
@loader.handler_exists?("debug").
|
81
|
-
@loader.mutator_exists?("only_check_output").
|
76
|
+
expect(extension).to be_instance_of(Sensu::Extension::Test)
|
77
|
+
expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
|
78
|
+
expect(@loader.handlers).to include(extension.definition)
|
79
|
+
expect(@loader.all).to include(extension)
|
80
|
+
expect(@loader.handler_exists?("debug")).to be(true)
|
81
|
+
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "can load specific extension categories for a sensu client" do
|
85
85
|
@loader.load_instances("client")
|
86
|
-
@loader.handler_exists?("debug").
|
87
|
-
@loader.mutator_exists?("only_check_output").
|
88
|
-
@loader.check_exists?("mock_check").
|
86
|
+
expect(@loader.handler_exists?("debug")).to be(false)
|
87
|
+
expect(@loader.mutator_exists?("only_check_output")).to be(false)
|
88
|
+
expect(@loader.check_exists?("mock_check")).to be(true)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "can load specific extension categories for a sensu server" do
|
92
92
|
@loader.load_instances("server")
|
93
|
-
@loader.handler_exists?("debug").
|
94
|
-
@loader.mutator_exists?("only_check_output").
|
95
|
-
@loader.check_exists?("mock_check").
|
93
|
+
expect(@loader.handler_exists?("debug")).to be(true)
|
94
|
+
expect(@loader.mutator_exists?("only_check_output")).to be(true)
|
95
|
+
expect(@loader.check_exists?("mock_check")).to be(false)
|
96
96
|
end
|
97
97
|
end
|
data/spec/mutators/json_spec.rb
CHANGED
@@ -17,8 +17,8 @@ describe "Sensu::Extension::Json" do
|
|
17
17
|
}
|
18
18
|
}
|
19
19
|
@extension.safe_run(event) do |output, status|
|
20
|
-
output.
|
21
|
-
status.
|
20
|
+
expect(output).to eq(MultiJson.dump(event))
|
21
|
+
expect(status).to eq(0)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
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: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-em
|