fluent-plugin-notifier 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/helper.rb
CHANGED
@@ -1,28 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
1
|
+
require 'bundler/setup'
|
10
2
|
require 'test/unit'
|
11
3
|
|
12
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
6
|
require 'fluent/test'
|
15
|
-
|
16
|
-
nulllogger = Object.new
|
17
|
-
nulllogger.instance_eval {|obj|
|
18
|
-
def method_missing(method, *args)
|
19
|
-
# pass
|
20
|
-
end
|
21
|
-
}
|
22
|
-
$log = nulllogger
|
23
|
-
end
|
7
|
+
require 'fluent/test/driver/output'
|
24
8
|
|
25
9
|
require 'fluent/plugin/out_notifier'
|
26
|
-
|
27
|
-
class Test::Unit::TestCase
|
28
|
-
end
|
data/test/plugin/test_def.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/helpers'
|
2
3
|
|
3
4
|
class NotifierOutputDefinitionTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
include Fluent::Test::Helpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
Fluent::Test.setup
|
9
|
+
@i = Fluent::Plugin::NotifierOutput.new
|
10
|
+
@i.configure(config_element())
|
11
|
+
end
|
12
|
+
|
13
|
+
def gen_conf(hash)
|
14
|
+
root = @i.configured_section_create(nil, config_element('root', '', {}, [config_element('def', '', hash)]))
|
15
|
+
root.def_configs.first
|
16
|
+
end
|
10
17
|
|
11
18
|
TEST_CONF1 = {
|
12
19
|
'tag' => 'notify',
|
@@ -24,41 +31,41 @@ class NotifierOutputDefinitionTest < Test::Unit::TestCase
|
|
24
31
|
}
|
25
32
|
|
26
33
|
def test_init
|
27
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF1,
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
31
|
-
assert_equal
|
32
|
-
assert_equal
|
33
|
-
assert_equal
|
34
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF1), @i)
|
35
|
+
assert_equal('name1', d.pattern)
|
36
|
+
assert_equal(['field1','field2'], d.target_keys)
|
37
|
+
assert_equal(:upward, d.instance_eval{ @check })
|
38
|
+
assert_equal(2.0, d.crit_threshold)
|
39
|
+
assert_equal(1.0, d.warn_threshold)
|
40
|
+
assert_equal('notify', d.tag)
|
34
41
|
assert_nil d.tag_warn
|
35
42
|
assert_nil d.tag_crit
|
36
|
-
assert_equal
|
37
|
-
assert_equal
|
38
|
-
|
39
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF2,
|
40
|
-
assert_equal
|
41
|
-
assert_equal
|
42
|
-
assert_equal
|
43
|
-
assert_equal
|
44
|
-
assert_equal
|
45
|
-
assert_equal
|
46
|
-
assert_equal
|
47
|
-
assert_equal
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
50
|
-
assert_equal
|
43
|
+
assert_equal([60, 300, 1800], d.intervals)
|
44
|
+
assert_equal([5, 5], d.repetitions)
|
45
|
+
|
46
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF2), @i)
|
47
|
+
assert_equal('name2', d.pattern)
|
48
|
+
assert_equal(/^field\d$/, d.target_key_pattern)
|
49
|
+
assert_equal(/^$/, d.exclude_key_pattern)
|
50
|
+
assert_equal(:find, d.instance_eval{ @check })
|
51
|
+
assert_equal(/WARN/, d.warn_regexp)
|
52
|
+
assert_equal(/CRIT/, d.crit_regexp)
|
53
|
+
assert_equal('notification', d.tag)
|
54
|
+
assert_equal('warn', d.tag_warn)
|
55
|
+
assert_equal('crit', d.tag_crit)
|
56
|
+
assert_equal([5, 6, 7], d.intervals)
|
57
|
+
assert_equal([1, 2], d.repetitions)
|
51
58
|
end
|
52
59
|
|
53
60
|
def test_match
|
54
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF1,
|
55
|
-
assert_equal
|
56
|
-
assert_equal
|
61
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF1), @i)
|
62
|
+
assert_equal(true, d.match?('field1'))
|
63
|
+
assert_equal(true, d.match?('field2'))
|
57
64
|
assert ! d.match?('field0')
|
58
65
|
assert ! d.match?('field')
|
59
66
|
assert ! d.match?('')
|
60
67
|
|
61
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF2,
|
68
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF2), @i)
|
62
69
|
assert_equal true, d.match?('field0')
|
63
70
|
assert_equal true, d.match?('field1')
|
64
71
|
assert_equal true, d.match?('field9')
|
@@ -67,7 +74,7 @@ class NotifierOutputDefinitionTest < Test::Unit::TestCase
|
|
67
74
|
assert ! d.match?(' field0')
|
68
75
|
assert ! d.match?('field0 ')
|
69
76
|
|
70
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF2.merge({'exclude_key_pattern' => '^field[7-9]$'}),
|
77
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF2.merge({'exclude_key_pattern' => '^field[7-9]$'})), @i)
|
71
78
|
assert_equal true, d.match?('field0')
|
72
79
|
assert_equal true, d.match?('field1')
|
73
80
|
assert ! d.match?('field7')
|
@@ -77,67 +84,67 @@ class NotifierOutputDefinitionTest < Test::Unit::TestCase
|
|
77
84
|
|
78
85
|
def test_check_numeric
|
79
86
|
t = Time.strptime('2012-07-19 14:40:30', '%Y-%m-%d %T')
|
80
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF1,
|
87
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF1), @i)
|
81
88
|
r = d.check('test.tag', t.to_i, {'field1' => '0.8', 'field2' => '1.5'}, 'field1')
|
82
89
|
assert_nil r
|
83
90
|
|
84
91
|
r = d.check('test.tag', t.to_i, {'field1' => '0.8', 'field2' => '1.5'}, 'field2')
|
85
|
-
assert_equal
|
86
|
-
assert_equal
|
87
|
-
assert_equal
|
88
|
-
assert_equal
|
89
|
-
assert_equal
|
90
|
-
assert_equal
|
91
|
-
assert_equal
|
92
|
-
assert_equal
|
93
|
-
assert_equal
|
94
|
-
assert_equal
|
95
|
-
assert_equal
|
92
|
+
assert_equal("name1\ttest.tag\tfield2", r[:hashkey])
|
93
|
+
assert_equal(d, r[:match_def])
|
94
|
+
assert_equal('notify', r[:emit_tag])
|
95
|
+
assert_equal('name1', r['pattern'])
|
96
|
+
assert_equal('test.tag', r['target_tag'])
|
97
|
+
assert_equal('field2', r['target_key'])
|
98
|
+
assert_equal('numeric_upward', r['check_type'])
|
99
|
+
assert_equal('warn', r['level'])
|
100
|
+
assert_equal(1.0, r['threshold'])
|
101
|
+
assert_equal(1.5, r['value'])
|
102
|
+
assert_equal(t.to_s, r['message_time'])
|
96
103
|
|
97
104
|
r = d.check('test.tag', t.to_i, {'field1' => '200', 'field2' => '1.5'}, 'field1')
|
98
|
-
assert_equal
|
99
|
-
assert_equal
|
100
|
-
assert_equal
|
101
|
-
assert_equal
|
102
|
-
assert_equal
|
103
|
-
assert_equal
|
104
|
-
assert_equal
|
105
|
-
assert_equal
|
106
|
-
assert_equal
|
107
|
-
assert_equal
|
108
|
-
assert_equal
|
105
|
+
assert_equal("name1\ttest.tag\tfield1", r[:hashkey])
|
106
|
+
assert_equal(d, r[:match_def])
|
107
|
+
assert_equal('notify', r[:emit_tag])
|
108
|
+
assert_equal('name1', r['pattern'])
|
109
|
+
assert_equal('test.tag', r['target_tag'])
|
110
|
+
assert_equal('field1', r['target_key'])
|
111
|
+
assert_equal('numeric_upward', r['check_type'])
|
112
|
+
assert_equal('crit', r['level'])
|
113
|
+
assert_equal(2.0, r['threshold'])
|
114
|
+
assert_equal(200.0, r['value'])
|
115
|
+
assert_equal(t.to_s, r['message_time'])
|
109
116
|
end
|
110
117
|
|
111
118
|
def test_check_string
|
112
119
|
t = Time.strptime('2012-07-19 14:40:30', '%Y-%m-%d %T')
|
113
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_CONF2,
|
120
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_CONF2), @i)
|
114
121
|
r = d.check('test.tag', t.to_i, {'field0' => 'hoge pos', 'field1' => 'CRIT fooooooo baaaaarrrrrrr'}, 'field0')
|
115
122
|
assert_nil r
|
116
123
|
|
117
124
|
r = d.check('test.tag', t.to_i, {'field0' => 'hoge pos', 'field1' => 'CRIT fooooooo baaaaarrrrrrr'}, 'field1')
|
118
|
-
assert_equal
|
119
|
-
assert_equal
|
120
|
-
assert_equal
|
121
|
-
assert_equal
|
122
|
-
assert_equal
|
123
|
-
assert_equal
|
124
|
-
assert_equal
|
125
|
-
assert_equal
|
126
|
-
assert_equal
|
127
|
-
assert_equal
|
128
|
-
assert_equal
|
125
|
+
assert_equal("name2\ttest.tag\tfield1", r[:hashkey])
|
126
|
+
assert_equal(d, r[:match_def])
|
127
|
+
assert_equal('crit', r[:emit_tag])
|
128
|
+
assert_equal('name2', r['pattern'])
|
129
|
+
assert_equal('test.tag', r['target_tag'])
|
130
|
+
assert_equal('field1', r['target_key'])
|
131
|
+
assert_equal('string_find', r['check_type'])
|
132
|
+
assert_equal('crit', r['level'])
|
133
|
+
assert_equal('/CRIT/', r['regexp'])
|
134
|
+
assert_equal('CRIT fooooooo baaaaarrrrrrr', r['value'])
|
135
|
+
assert_equal(t.to_s, r['message_time'])
|
129
136
|
|
130
137
|
r = d.check('test.tag', t.to_i, {'field0' => 'hoge pos (WARN) check!', 'field1' => 'CRIT fooooooo baaaaarrrrrrr'}, 'field0')
|
131
|
-
assert_equal
|
132
|
-
assert_equal
|
133
|
-
assert_equal
|
134
|
-
assert_equal
|
135
|
-
assert_equal
|
136
|
-
assert_equal
|
137
|
-
assert_equal
|
138
|
-
assert_equal
|
139
|
-
assert_equal
|
140
|
-
assert_equal
|
141
|
-
assert_equal
|
138
|
+
assert_equal("name2\ttest.tag\tfield0", r[:hashkey])
|
139
|
+
assert_equal(d, r[:match_def])
|
140
|
+
assert_equal('warn', r[:emit_tag])
|
141
|
+
assert_equal('name2', r['pattern'])
|
142
|
+
assert_equal('test.tag', r['target_tag'])
|
143
|
+
assert_equal('field0', r['target_key'])
|
144
|
+
assert_equal('string_find', r['check_type'])
|
145
|
+
assert_equal('warn', r['level'])
|
146
|
+
assert_equal('/WARN/', r['regexp'])
|
147
|
+
assert_equal('hoge pos (WARN) check!', r['value'])
|
148
|
+
assert_equal(t.to_s, r['message_time'])
|
142
149
|
end
|
143
150
|
end
|
@@ -39,87 +39,100 @@ class NotifierOutputTest < Test::Unit::TestCase
|
|
39
39
|
</def>
|
40
40
|
]
|
41
41
|
|
42
|
-
def create_driver(conf=CONFIG
|
43
|
-
Fluent::Test::
|
42
|
+
def create_driver(conf = CONFIG)
|
43
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::NotifierOutput).configure(conf)
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_configure
|
47
|
-
|
48
|
-
|
47
|
+
assert_nothing_raised do
|
48
|
+
create_driver
|
49
|
+
end
|
49
50
|
end
|
50
51
|
|
51
|
-
|
52
|
+
test "notify 0 events when num1 < warn_threshold and no test conditions" do
|
52
53
|
d = create_driver
|
53
|
-
d.run do
|
54
|
-
d.
|
54
|
+
d.run(default_tag: "test") do
|
55
|
+
d.feed({'num1' => 20, 'message' => 'INFO'})
|
55
56
|
end
|
56
|
-
assert_equal
|
57
|
+
assert_equal(0, d.events.size)
|
58
|
+
end
|
57
59
|
|
60
|
+
test "notify 0 events when num1 > warn_threshold but no test conditions are satisfied" do
|
58
61
|
d = create_driver
|
59
|
-
d.run do
|
60
|
-
d.
|
62
|
+
d.run(default_tag: "test") do
|
63
|
+
d.feed({'num1' => 30, 'message' => 'INFO'})
|
61
64
|
end
|
62
|
-
assert_equal
|
65
|
+
assert_equal(0, d.events.size)
|
66
|
+
end
|
63
67
|
|
64
|
-
|
65
|
-
d
|
66
|
-
|
68
|
+
test "notify 1 event when num1 > warn_threshold and satisfy test conditions" do
|
69
|
+
d = create_driver
|
70
|
+
d.run(default_tag: "test.input") do
|
71
|
+
d.feed({'num1' => 30, 'message' => 'INFO', 'numfield' => '30', 'textfield' => 'TargetX'})
|
67
72
|
end
|
68
|
-
assert_equal
|
69
|
-
assert_equal
|
70
|
-
assert_equal
|
71
|
-
assert_equal
|
72
|
-
assert_equal
|
73
|
-
assert_equal
|
74
|
-
assert_equal
|
75
|
-
assert_equal
|
73
|
+
assert_equal(1, d.events.size)
|
74
|
+
assert_equal('alert.warn', d.events[0][0])
|
75
|
+
assert_equal('pattern1', d.events[0][2]['pattern'])
|
76
|
+
assert_equal('input', d.events[0][2]['target_tag'])
|
77
|
+
assert_equal('numeric_upward', d.events[0][2]['check_type'])
|
78
|
+
assert_equal('warn', d.events[0][2]['level'])
|
79
|
+
assert_equal(25.0, d.events[0][2]['threshold'])
|
80
|
+
assert_equal(30.0, d.events[0][2]['value'])
|
81
|
+
end
|
76
82
|
|
83
|
+
test "notify 2 events when num1 > crit_threshold and message match warn_regexp" do
|
77
84
|
d = create_driver
|
78
|
-
d.run do
|
79
|
-
d.
|
85
|
+
d.run(default_tag: "test") do
|
86
|
+
d.feed({'num1' => 60, 'message' => 'foo bar WARNING xxxxx', 'numfield' => '30', 'textfield' => 'TargetX'})
|
80
87
|
end
|
81
|
-
assert_equal
|
82
|
-
assert_equal
|
83
|
-
assert_equal
|
84
|
-
assert_equal
|
85
|
-
assert_equal
|
86
|
-
assert_equal
|
87
|
-
assert_equal
|
88
|
-
assert_equal
|
89
|
-
assert_equal
|
90
|
-
assert_equal
|
91
|
-
assert_equal
|
92
|
-
assert_equal
|
93
|
-
assert_equal
|
94
|
-
assert_equal
|
95
|
-
assert_equal
|
88
|
+
assert_equal(2, d.events.size)
|
89
|
+
assert_equal('alert.crit', d.events[0][0])
|
90
|
+
assert_equal('pattern1', d.events[0][2]['pattern'])
|
91
|
+
assert_equal('test', d.events[0][2]['target_tag'])
|
92
|
+
assert_equal('numeric_upward', d.events[0][2]['check_type'])
|
93
|
+
assert_equal('crit', d.events[0][2]['level'])
|
94
|
+
assert_equal(50.0, d.events[0][2]['threshold'])
|
95
|
+
assert_equal(60.0, d.events[0][2]['value'])
|
96
|
+
assert_equal('alert', d.events[1][0])
|
97
|
+
assert_equal('pattern2', d.events[1][2]['pattern'])
|
98
|
+
assert_equal('test', d.events[1][2]['target_tag'])
|
99
|
+
assert_equal('string_find', d.events[1][2]['check_type'])
|
100
|
+
assert_equal('warn', d.events[1][2]['level'])
|
101
|
+
assert_equal('/WARNING/', d.events[1][2]['regexp'])
|
102
|
+
assert_equal('foo bar WARNING xxxxx', d.events[1][2]['value'])
|
103
|
+
end
|
96
104
|
|
105
|
+
test "notify 0 events when test conditions are not satisfied numfield < lower_threshold" do
|
97
106
|
d = create_driver
|
98
|
-
d.run do
|
99
|
-
d.
|
107
|
+
d.run(default_tag: "test") do
|
108
|
+
d.feed({'num1' => 60, 'message' => 'foo bar WARNING xxxxx', 'numfield' => '2.4', 'textfield' => 'TargetX'})
|
100
109
|
end
|
101
|
-
assert_equal
|
110
|
+
assert_equal(0, d.events.size)
|
111
|
+
end
|
102
112
|
|
113
|
+
test "notify 0 events when test conditions are not satisfied textfield matches exclude_pattern" do
|
103
114
|
d = create_driver
|
104
|
-
d.run do
|
105
|
-
d.
|
115
|
+
d.run(default_tag: "test") do
|
116
|
+
d.feed({'num1' => 60, 'message' => 'foo bar WARNING xxxxx', 'numfield' => '20', 'textfield' => 'TargetC'})
|
106
117
|
end
|
107
|
-
assert_equal
|
118
|
+
assert_equal(0, d.events.size)
|
119
|
+
end
|
108
120
|
|
121
|
+
test "notify 0 events when test conditions are not satisfied textfield is missing" do
|
109
122
|
d = create_driver
|
110
|
-
d.run do
|
111
|
-
d.
|
123
|
+
d.run(default_tag: "test") do
|
124
|
+
d.feed({'num1' => 60, 'message' => 'foo bar WARNING xxxxx', 'numfield' => '20'})
|
112
125
|
end
|
113
|
-
assert_equal
|
126
|
+
assert_equal(0, d.events.size)
|
114
127
|
end
|
115
128
|
|
116
129
|
def test_emit_invalid_byte
|
117
130
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
118
131
|
d = create_driver
|
119
|
-
assert_nothing_raised
|
120
|
-
d.run do
|
121
|
-
d.
|
132
|
+
assert_nothing_raised do
|
133
|
+
d.run(default_tag: "test") do
|
134
|
+
d.feed({'num1' => 60, 'message' => "foo bar WARNING #{invalid_utf8}", 'numfield' => '30', 'textfield' => 'TargetX'})
|
122
135
|
end
|
123
|
-
|
136
|
+
end
|
124
137
|
end
|
125
138
|
end
|
data/test/plugin/test_state.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/helpers'
|
2
3
|
|
3
4
|
class NotifierOutputStateTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
include Fluent::Test::Helpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
Fluent::Test.setup
|
9
|
+
@i = Fluent::Plugin::NotifierOutput.new
|
10
|
+
@i.configure(config_element())
|
11
|
+
end
|
12
|
+
|
13
|
+
def gen_conf(hash)
|
14
|
+
root = @i.configured_section_create(nil, config_element('root', '', {}, [config_element('def', '', hash)]))
|
15
|
+
root.def_configs.first
|
16
|
+
end
|
17
|
+
|
10
18
|
TEST_DEF_CONF1 = {
|
11
19
|
'tag' => 'notify',
|
12
20
|
'pattern' => 'name1', 'target_keys' => 'field1,field2',
|
@@ -22,55 +30,55 @@ class NotifierOutputStateTest < Test::Unit::TestCase
|
|
22
30
|
}
|
23
31
|
|
24
32
|
def test_init
|
25
|
-
s = Fluent::NotifierOutput::State.new({
|
33
|
+
s = Fluent::Plugin::NotifierOutput::State.new({
|
26
34
|
:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'
|
27
35
|
})
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
31
|
-
assert_equal
|
32
|
-
assert_equal
|
33
|
-
assert_equal
|
34
|
-
assert
|
35
|
-
assert
|
36
|
+
assert_equal('name1', s.pattern)
|
37
|
+
assert_equal('test.tag', s.target_tag)
|
38
|
+
assert_equal('field1', s.target_key)
|
39
|
+
assert_equal('warn', s.level)
|
40
|
+
assert_equal(0, s.stage)
|
41
|
+
assert_equal(1, s.counter)
|
42
|
+
assert { s.first_notified <= Fluent::Engine.now }
|
43
|
+
assert { s.last_notified <= Fluent::Engine.now }
|
36
44
|
end
|
37
45
|
|
38
46
|
def test_suppress?
|
39
|
-
s = Fluent::NotifierOutput::State.new({
|
47
|
+
s = Fluent::Plugin::NotifierOutput::State.new({
|
40
48
|
:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'
|
41
49
|
})
|
42
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_DEF_CONF1,
|
43
|
-
s.last_notified = Fluent::Engine.now -
|
44
|
-
assert_equal
|
45
|
-
s.last_notified = Fluent::Engine.now -
|
46
|
-
assert_equal
|
50
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_DEF_CONF1), @i)
|
51
|
+
s.last_notified = Fluent::Engine.now - @i.default_intervals[0] + 5
|
52
|
+
assert_equal(true, s.suppress?(d, {:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'}))
|
53
|
+
s.last_notified = Fluent::Engine.now - @i.default_intervals[0] - 5
|
54
|
+
assert_equal(false, s.suppress?(d, {:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'}))
|
47
55
|
|
48
|
-
s = Fluent::NotifierOutput::State.new({
|
56
|
+
s = Fluent::Plugin::NotifierOutput::State.new({
|
49
57
|
:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'
|
50
58
|
})
|
51
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_DEF_CONF1,
|
52
|
-
assert_equal
|
59
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_DEF_CONF1), @i)
|
60
|
+
assert_equal(true, s.suppress?(d, {:pattern => 'name1', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'crit'}))
|
53
61
|
end
|
54
62
|
|
55
63
|
def test_update_notified
|
56
|
-
s = Fluent::NotifierOutput::State.new({
|
64
|
+
s = Fluent::Plugin::NotifierOutput::State.new({
|
57
65
|
:pattern => 'name2', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'
|
58
66
|
})
|
59
|
-
d = Fluent::NotifierOutput::Definition.new(TEST_DEF_CONF2,
|
67
|
+
d = Fluent::Plugin::NotifierOutput::Definition.new(gen_conf(TEST_DEF_CONF2), @i)
|
60
68
|
|
61
|
-
assert_equal
|
62
|
-
assert_equal
|
69
|
+
assert_equal(0, s.stage)
|
70
|
+
assert_equal(1, s.counter)
|
63
71
|
|
64
72
|
s.update_notified(d, {:pattern => 'name2', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'})
|
65
|
-
assert_equal
|
66
|
-
assert_equal
|
67
|
-
|
73
|
+
assert_equal(1, s.stage)
|
74
|
+
assert_equal(0, s.counter)
|
75
|
+
|
68
76
|
s.update_notified(d, {:pattern => 'name2', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'warn'})
|
69
|
-
assert_equal
|
70
|
-
assert_equal
|
77
|
+
assert_equal(1, s.stage)
|
78
|
+
assert_equal(1, s.counter)
|
71
79
|
|
72
80
|
s.update_notified(d, {:pattern => 'name2', :target_tag => 'test.tag', :target_key => 'field1', 'level' => 'crit'})
|
73
|
-
assert_equal
|
74
|
-
assert_equal
|
81
|
+
assert_equal(0, s.stage)
|
82
|
+
assert_equal(1, s.counter)
|
75
83
|
end
|
76
84
|
end
|