fluent-plugin-notifier 0.3.0 → 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/.travis.yml +5 -2
- data/Appraisals +3 -0
- data/README.md +13 -8
- data/fluent-plugin-notifier.gemspec +3 -3
- data/gemfiles/fluentd_v0.14.gemfile +7 -0
- data/lib/fluent/plugin/out_notifier.rb +222 -198
- data/test/helper.rb +2 -21
- data/test/plugin/test_def.rb +86 -79
- data/test/plugin/test_out_notifier.rb +65 -52
- data/test/plugin/test_state.rb +43 -35
- data/test/plugin/test_test.rb +103 -91
- metadata +18 -16
data/test/plugin/test_test.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/helpers'
|
2
3
|
|
3
4
|
class NotifierOutputTestTest < Test::Unit::TestCase
|
5
|
+
include Fluent::Test::Helpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@i = Fluent::Plugin::NotifierOutput.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def gen_conf(hash)
|
12
|
+
root = @i.configured_section_create(nil, config_element('root', '', {}, [config_element('test', '', hash)]))
|
13
|
+
root.test_configs.first
|
14
|
+
end
|
15
|
+
|
4
16
|
TEST_CONF1 = {
|
5
17
|
'check' => 'numeric', 'target_key' => 'field1',
|
6
18
|
'lower_threshold' => '1', 'upper_threshold' => '2',
|
@@ -40,139 +52,139 @@ class NotifierOutputTestTest < Test::Unit::TestCase
|
|
40
52
|
}
|
41
53
|
|
42
54
|
def test_init
|
43
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF1)
|
44
|
-
assert_equal
|
45
|
-
assert_equal
|
46
|
-
assert_equal
|
47
|
-
assert_equal
|
48
|
-
|
49
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF4)
|
50
|
-
assert_equal
|
51
|
-
assert_equal
|
52
|
-
assert_equal
|
53
|
-
assert_equal
|
54
|
-
|
55
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF7)
|
56
|
-
assert_equal
|
55
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF1))
|
56
|
+
assert_equal(:numeric, t.check)
|
57
|
+
assert_equal('field1', t.target_key)
|
58
|
+
assert_equal(1.0, t.lower_threshold)
|
59
|
+
assert_equal(2.0, t.upper_threshold)
|
60
|
+
|
61
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF4))
|
62
|
+
assert_equal(:regexp, t.check)
|
63
|
+
assert_equal('field2', t.target_key)
|
64
|
+
assert_equal(/hoge/, t.include_pattern)
|
65
|
+
assert_equal(/pos/, t.exclude_pattern)
|
66
|
+
|
67
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF7))
|
68
|
+
assert_equal(:tag, t.check)
|
57
69
|
assert_nil t.target_key
|
58
|
-
assert_equal
|
59
|
-
assert_equal
|
70
|
+
assert_equal(/hoge/, t.include_pattern)
|
71
|
+
assert_equal(/pos/, t.exclude_pattern)
|
60
72
|
end
|
61
73
|
|
62
74
|
def test_numeric
|
63
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF1)
|
64
|
-
assert_equal
|
65
|
-
assert_equal
|
66
|
-
assert_equal
|
67
|
-
assert_equal
|
68
|
-
|
69
|
-
assert_equal
|
70
|
-
assert_equal
|
71
|
-
assert_equal
|
72
|
-
assert_equal
|
73
|
-
assert_equal
|
74
|
-
assert_equal
|
75
|
-
|
76
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF2)
|
75
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF1))
|
76
|
+
assert_equal(:numeric, t.check)
|
77
|
+
assert_equal('field1', t.target_key)
|
78
|
+
assert_equal(1.0, t.lower_threshold)
|
79
|
+
assert_equal(2.0, t.upper_threshold)
|
80
|
+
|
81
|
+
assert_equal(false, t.test('test', {'field2' => '0.5'}))
|
82
|
+
assert_equal(false, t.test('test', {'field1' => '0.5'}))
|
83
|
+
assert_equal(true, t.test('test', {'field1' => 1}))
|
84
|
+
assert_equal(true, t.test('test', {'field1' => 1.999999999999999999999999999999}))
|
85
|
+
assert_equal(true, t.test('test', {'field1' => 2.0}))
|
86
|
+
assert_equal(false, t.test('test', {'field1' => '2.0000001'}))
|
87
|
+
|
88
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF2))
|
77
89
|
# TEST_CONF2 = {
|
78
90
|
# 'check' => 'numeric', 'target_key' => 'field1',
|
79
91
|
# 'lower_threshold' => '1',
|
80
92
|
# }
|
81
|
-
assert_equal
|
82
|
-
assert_equal
|
83
|
-
assert_equal
|
84
|
-
assert_equal
|
85
|
-
assert_equal
|
86
|
-
assert_equal
|
87
|
-
assert_equal
|
93
|
+
assert_equal(false, t.test('test', {'field2' => '0.5'}))
|
94
|
+
assert_equal(false, t.test('test', {'field1' => '0.5'}))
|
95
|
+
assert_equal(true, t.test('test', {'field1' => 1}))
|
96
|
+
assert_equal(true, t.test('test', {'field1' => 1.999999999999999999999999999999}))
|
97
|
+
assert_equal(true, t.test('test', {'field1' => 2.0}))
|
98
|
+
assert_equal(true, t.test('test', {'field1' => '2.0000001'}))
|
99
|
+
assert_equal(true, t.test('test', {'field1' => 10000.32}))
|
88
100
|
|
89
101
|
|
90
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF3)
|
102
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF3))
|
91
103
|
# TEST_CONF3 = {
|
92
104
|
# 'check' => 'numeric', 'target_key' => 'field1',
|
93
105
|
# 'upper_threshold' => '2',
|
94
106
|
# }
|
95
|
-
assert_equal
|
96
|
-
assert_equal
|
97
|
-
assert_equal
|
98
|
-
assert_equal
|
99
|
-
assert_equal
|
100
|
-
assert_equal
|
101
|
-
assert_equal
|
102
|
-
|
103
|
-
assert_equal
|
104
|
-
assert_equal
|
107
|
+
assert_equal(false, t.test('test', {'field2' => '0.5'}))
|
108
|
+
assert_equal(true, t.test('test', {'field1' => '0.5'}))
|
109
|
+
assert_equal(true, t.test('test', {'field1' => 1}))
|
110
|
+
assert_equal(true, t.test('test', {'field1' => 1.999999999999999999999999999999}))
|
111
|
+
assert_equal(true, t.test('test', {'field1' => 2.0}))
|
112
|
+
assert_equal(false, t.test('test', {'field1' => '2.0000001'}))
|
113
|
+
assert_equal(false, t.test('test', {'field1' => 10000.32}))
|
114
|
+
|
115
|
+
assert_equal(true, t.test('test', {'field1' => 0.0}))
|
116
|
+
assert_equal(true, t.test('test', {'field1' => '-1'}))
|
105
117
|
end
|
106
118
|
|
107
119
|
def test_regexp
|
108
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF4)
|
109
|
-
assert_equal
|
110
|
-
assert_equal
|
111
|
-
assert_equal
|
112
|
-
assert_equal
|
113
|
-
|
114
|
-
assert_equal
|
115
|
-
assert_equal
|
116
|
-
assert_equal
|
117
|
-
assert_equal
|
118
|
-
assert_equal
|
119
|
-
assert_equal
|
120
|
-
assert_equal
|
121
|
-
|
122
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF5)
|
120
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF4))
|
121
|
+
assert_equal(:regexp, t.check)
|
122
|
+
assert_equal('field2', t.target_key)
|
123
|
+
assert_equal(/hoge/, t.include_pattern)
|
124
|
+
assert_equal(/pos/, t.exclude_pattern)
|
125
|
+
|
126
|
+
assert_equal(false, t.test('test', {'field1' => 'hoge foo bar'}))
|
127
|
+
assert_equal(false, t.test('test', {'field2' => ''}))
|
128
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar'}))
|
129
|
+
assert_equal(false, t.test('test', {'field2' => 'hoge pos foo bar'}))
|
130
|
+
assert_equal(false, t.test('test', {'field2' => 'pos foo bar'}))
|
131
|
+
assert_equal(false, t.test('test', {'field2' => 'pos hoge foo bar'}))
|
132
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar hoge'}))
|
133
|
+
|
134
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF5))
|
123
135
|
# TEST_CONF5 = {
|
124
136
|
# 'check' => 'regexp', 'target_key' => 'field2',
|
125
137
|
# 'include_pattern' => 'hoge',
|
126
138
|
# }
|
127
|
-
assert_equal
|
128
|
-
assert_equal
|
129
|
-
assert_equal
|
130
|
-
assert_equal
|
131
|
-
assert_equal
|
132
|
-
assert_equal
|
133
|
-
assert_equal
|
134
|
-
|
135
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF6)
|
139
|
+
assert_equal(false, t.test('test', {'field1' => 'hoge foo bar'}))
|
140
|
+
assert_equal(false, t.test('test', {'field2' => ''}))
|
141
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar'}))
|
142
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge pos foo bar'}))
|
143
|
+
assert_equal(false, t.test('test', {'field2' => 'pos foo bar'}))
|
144
|
+
assert_equal(true, t.test('test', {'field2' => 'pos hoge foo bar'}))
|
145
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar hoge'}))
|
146
|
+
|
147
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF6))
|
136
148
|
# TEST_CONF6 = {
|
137
149
|
# 'check' => 'regexp', 'target_key' => 'field2',
|
138
150
|
# 'exclude_pattern' => 'pos',
|
139
151
|
# }
|
140
|
-
assert_equal
|
141
|
-
assert_equal
|
142
|
-
assert_equal
|
143
|
-
assert_equal
|
144
|
-
assert_equal
|
145
|
-
assert_equal
|
146
|
-
assert_equal
|
152
|
+
assert_equal(false, t.test('test', {'field1' => 'hoge foo bar'}))
|
153
|
+
assert_equal(true, t.test('test', {'field2' => ''}))
|
154
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar'}))
|
155
|
+
assert_equal(false, t.test('test', {'field2' => 'hoge pos foo bar'}))
|
156
|
+
assert_equal(false, t.test('test', {'field2' => 'pos foo bar'}))
|
157
|
+
assert_equal(false, t.test('test', {'field2' => 'pos hoge foo bar'}))
|
158
|
+
assert_equal(true, t.test('test', {'field2' => 'hoge foo bar hoge'}))
|
147
159
|
end
|
148
160
|
|
149
161
|
def test_tag
|
150
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF7)
|
162
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF7))
|
151
163
|
# TEST_CONF7 = {
|
152
164
|
# 'check' => 'tag',
|
153
165
|
# 'include_pattern' => 'hoge',
|
154
166
|
# 'exclude_pattern' => 'pos',
|
155
167
|
# }
|
156
|
-
assert_equal
|
157
|
-
assert_equal
|
158
|
-
assert_equal
|
168
|
+
assert_equal(false, t.test('test', {'field1' => 'hoge foo bar'}))
|
169
|
+
assert_equal(true, t.test('test.hoge', {'field1' => 'hoge foo bar'}))
|
170
|
+
assert_equal(false, t.test('test.hoge.pos', {'field1' => 'hoge foo bar'}))
|
159
171
|
|
160
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF8)
|
172
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF8))
|
161
173
|
# TEST_CONF8 = {
|
162
174
|
# 'check' => 'tag',
|
163
175
|
# 'include_pattern' => 'hoge',
|
164
176
|
# }
|
165
|
-
assert_equal
|
166
|
-
assert_equal
|
167
|
-
assert_equal
|
177
|
+
assert_equal(false, t.test('test', {'field1' => 'hoge foo bar'}))
|
178
|
+
assert_equal(true, t.test('test.hoge', {'field1' => 'hoge foo bar'}))
|
179
|
+
assert_equal(true, t.test('test.hoge.pos', {'field1' => 'hoge foo bar'}))
|
168
180
|
|
169
|
-
t = Fluent::NotifierOutput::Test.new(TEST_CONF9)
|
181
|
+
t = Fluent::Plugin::NotifierOutput::Test.new(gen_conf(TEST_CONF9))
|
170
182
|
# TEST_CONF9 = {
|
171
183
|
# 'check' => 'tag',
|
172
184
|
# 'exclude_pattern' => 'pos',
|
173
185
|
# }
|
174
|
-
assert_equal
|
175
|
-
assert_equal
|
176
|
-
assert_equal
|
186
|
+
assert_equal(true, t.test('test', {'field1' => 'hoge foo bar'}))
|
187
|
+
assert_equal(true, t.test('test.hoge', {'field1' => 'hoge foo bar'}))
|
188
|
+
assert_equal(false, t.test('test.hoge.pos', {'field1' => 'hoge foo bar'}))
|
177
189
|
end
|
178
190
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
@@ -11,47 +11,47 @@ cert_chain: []
|
|
11
11
|
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 0.14.0
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.14.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: test-unit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '3.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
48
|
-
type: :
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
description: check matched messages and emit alert message with throttling by conditions...
|
56
56
|
email:
|
57
57
|
- tagomoris@gmail.com
|
@@ -61,11 +61,13 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".travis.yml"
|
64
|
+
- Appraisals
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- fluent-plugin-notifier.gemspec
|
70
|
+
- gemfiles/fluentd_v0.14.gemfile
|
69
71
|
- lib/fluent/plugin/out_notifier.rb
|
70
72
|
- test/helper.rb
|
71
73
|
- test/plugin/test_def.rb
|