fluentd 0.14.1 → 0.14.2
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/ChangeLog +110 -1
- data/Rakefile +5 -1
- data/appveyor.yml +7 -1
- data/example/in_forward.conf +4 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +21 -3
- data/lib/fluent/compat/formatter.rb +4 -2
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +60 -0
- data/lib/fluent/compat/input.rb +1 -3
- data/lib/fluent/compat/output.rb +95 -39
- data/lib/fluent/compat/parser.rb +17 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/{test/driver/owner.rb → compat/structured_format_mixin.rb} +5 -11
- data/lib/fluent/config/element.rb +2 -2
- data/lib/fluent/configurable.rb +2 -1
- data/lib/fluent/event.rb +61 -7
- data/lib/fluent/event_router.rb +1 -1
- data/lib/fluent/plugin.rb +7 -7
- data/lib/fluent/plugin/buf_file.rb +5 -2
- data/lib/fluent/plugin/buffer.rb +194 -64
- data/lib/fluent/plugin/buffer/chunk.rb +28 -3
- data/lib/fluent/plugin/buffer/file_chunk.rb +5 -21
- data/lib/fluent/plugin/buffer/memory_chunk.rb +1 -11
- data/lib/fluent/plugin/exec_util.rb +2 -112
- data/lib/fluent/plugin/file_util.rb +3 -38
- data/lib/fluent/plugin/file_wrapper.rb +1 -1
- data/lib/fluent/plugin/filter_grep.rb +3 -7
- data/lib/fluent/plugin/filter_record_transformer.rb +5 -5
- data/lib/fluent/plugin/filter_stdout.rb +18 -11
- data/lib/fluent/plugin/formatter.rb +0 -48
- data/lib/fluent/plugin/formatter_csv.rb +7 -8
- data/lib/fluent/plugin/formatter_hash.rb +1 -4
- data/lib/fluent/plugin/formatter_json.rb +1 -4
- data/lib/fluent/plugin/formatter_ltsv.rb +5 -6
- data/lib/fluent/plugin/formatter_msgpack.rb +1 -4
- data/lib/fluent/plugin/formatter_out_file.rb +36 -3
- data/lib/fluent/plugin/formatter_stdout.rb +36 -1
- data/lib/fluent/plugin/in_dummy.rb +9 -2
- data/lib/fluent/plugin/in_exec.rb +20 -57
- data/lib/fluent/plugin/in_forward.rb +4 -3
- data/lib/fluent/plugin/in_object_space.rb +8 -44
- data/lib/fluent/plugin/in_syslog.rb +13 -24
- data/lib/fluent/plugin/in_tail.rb +3 -0
- data/lib/fluent/plugin/out_buffered_stdout.rb +14 -4
- data/lib/fluent/plugin/out_exec.rb +7 -5
- data/lib/fluent/plugin/out_exec_filter.rb +10 -10
- data/lib/fluent/plugin/out_file.rb +1 -3
- data/lib/fluent/plugin/out_forward.rb +38 -57
- data/lib/fluent/plugin/out_stdout.rb +14 -5
- data/lib/fluent/plugin/out_stream.rb +3 -0
- data/lib/fluent/plugin/output.rb +31 -14
- data/lib/fluent/plugin/parser.rb +0 -69
- data/lib/fluent/plugin/parser_apache.rb +10 -6
- data/lib/fluent/plugin/parser_apache_error.rb +8 -3
- data/lib/fluent/plugin/parser_csv.rb +3 -1
- data/lib/fluent/plugin/parser_json.rb +1 -1
- data/lib/fluent/plugin/parser_multiline.rb +5 -3
- data/lib/fluent/plugin/parser_nginx.rb +10 -6
- data/lib/fluent/plugin/parser_regexp.rb +73 -0
- data/lib/fluent/plugin/socket_util.rb +2 -148
- data/lib/fluent/plugin/storage_local.rb +1 -1
- data/lib/fluent/plugin/string_util.rb +3 -18
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +166 -41
- data/lib/fluent/plugin_helper/formatter.rb +30 -19
- data/lib/fluent/plugin_helper/inject.rb +25 -12
- data/lib/fluent/plugin_helper/parser.rb +22 -13
- data/lib/fluent/plugin_helper/storage.rb +22 -13
- data/lib/fluent/registry.rb +19 -6
- data/lib/fluent/supervisor.rb +27 -1
- data/lib/fluent/test/driver/base.rb +16 -92
- data/lib/fluent/test/driver/base_owned.rb +17 -53
- data/lib/fluent/test/driver/base_owner.rb +125 -0
- data/lib/fluent/test/driver/filter.rb +24 -2
- data/lib/fluent/test/driver/input.rb +2 -2
- data/lib/fluent/test/driver/multi_output.rb +2 -2
- data/lib/fluent/test/driver/output.rb +3 -5
- data/lib/fluent/test/helpers.rb +25 -0
- data/lib/fluent/test/input_test.rb +4 -4
- data/lib/fluent/test/output_test.rb +3 -3
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_element.rb +135 -6
- data/test/plugin/test_buf_file.rb +71 -3
- data/test/plugin/test_buffer.rb +305 -86
- data/test/plugin/test_buffer_chunk.rb +60 -2
- data/test/plugin/test_buffer_file_chunk.rb +4 -3
- data/test/plugin/test_filter_grep.rb +25 -21
- data/test/plugin/test_filter_record_transformer.rb +75 -67
- data/test/plugin/test_filter_stdout.rb +171 -74
- data/test/plugin/test_formatter_csv.rb +94 -0
- data/test/plugin/test_formatter_json.rb +30 -0
- data/test/plugin/test_formatter_ltsv.rb +52 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_in_dummy.rb +95 -0
- data/test/plugin/test_in_exec.rb +27 -31
- data/test/plugin/test_in_forward.rb +24 -0
- data/test/plugin/test_in_gc_stat.rb +5 -5
- data/test/plugin/test_in_object_space.rb +4 -4
- data/test/plugin/test_in_syslog.rb +60 -35
- data/test/plugin/test_out_buffered_stdout.rb +17 -3
- data/test/plugin/test_out_forward.rb +93 -5
- data/test/plugin/test_out_stdout.rb +14 -3
- data/test/plugin/test_output_as_buffered_retries.rb +20 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +16 -0
- data/test/plugin/test_output_as_standard.rb +22 -22
- data/test/plugin/test_parser_apache.rb +13 -9
- data/test/plugin/test_parser_apache_error.rb +11 -6
- data/test/plugin/test_parser_csv.rb +35 -25
- data/test/plugin/test_parser_nginx.rb +11 -5
- data/test/plugin/test_parser_regexp.rb +235 -68
- data/test/plugin/test_parser_tsv.rb +54 -58
- data/test/plugin_helper/test_compat_parameters.rb +111 -46
- data/test/plugin_helper/test_formatter.rb +40 -0
- data/test/plugin_helper/test_inject.rb +101 -2
- data/test/plugin_helper/test_parser.rb +40 -0
- data/test/plugin_helper/test_storage.rb +43 -0
- data/test/test_event.rb +93 -0
- data/test/test_event_router.rb +13 -4
- data/test/test_event_time.rb +0 -3
- data/test/test_formatter.rb +7 -164
- data/test/test_plugin_classes.rb +28 -1
- metadata +24 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require_relative '../helper'
|
|
2
|
+
require 'fluent/test/driver/formatter'
|
|
3
|
+
require 'fluent/plugin/formatter_msgpack'
|
|
4
|
+
|
|
5
|
+
class MessagePackFormatterTest < ::Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@time = event_time
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create_driver(conf = "")
|
|
11
|
+
Fluent::Test::Driver::Formatter.new(Fluent::Plugin::MessagePackFormatter).configure(conf)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def tag
|
|
15
|
+
"tag"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def record
|
|
19
|
+
{'message' => 'awesome'}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_format
|
|
23
|
+
d = create_driver({})
|
|
24
|
+
formatted = d.instance.format(tag, @time, record)
|
|
25
|
+
|
|
26
|
+
assert_equal(record.to_msgpack, formatted)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
require_relative '../helper'
|
|
2
|
+
require 'fluent/test/driver/formatter'
|
|
3
|
+
require 'fluent/plugin/formatter_out_file'
|
|
4
|
+
|
|
5
|
+
class OutFileFormatterTest < ::Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@time = event_time
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create_driver(conf = {})
|
|
11
|
+
d = Fluent::Test::Driver::Formatter.new(Fluent::Plugin::OutFileFormatter)
|
|
12
|
+
case conf
|
|
13
|
+
when Fluent::Config::Element
|
|
14
|
+
d.configure(conf)
|
|
15
|
+
when Hash
|
|
16
|
+
d.configure({'utc' => true}.merge(conf))
|
|
17
|
+
else
|
|
18
|
+
d.configure(conf)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def tag
|
|
23
|
+
"tag"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def record
|
|
27
|
+
{'message' => 'awesome'}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
data('both true' => 'true', 'both false' => 'false')
|
|
31
|
+
def test_configured_with_both_of_utc_and_localtime(value)
|
|
32
|
+
assert_raise(Fluent::ConfigError.new("both of utc and localtime are specified, use only one of them")) do
|
|
33
|
+
create_driver({'utc' => value, 'localtime' => value})
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
time_i = Time.parse("2016-07-26 21:08:30 -0700").to_i
|
|
38
|
+
data(
|
|
39
|
+
'configured for localtime by localtime' => ['localtime', 'true', time_i, "2016-07-26T21:08:30-07:00"],
|
|
40
|
+
'configured for localtime by utc' => ['utc', 'false', time_i, "2016-07-26T21:08:30-07:00"],
|
|
41
|
+
'configured for utc by localtime' => ['localtime', 'false', time_i, "2016-07-27T04:08:30Z"],
|
|
42
|
+
'configured for utc by utc' => ['utc', 'true', time_i, "2016-07-27T04:08:30Z"],
|
|
43
|
+
)
|
|
44
|
+
def test_configured_with_utc_or_localtime(data)
|
|
45
|
+
key, value, time_i, expected = data
|
|
46
|
+
time = Time.at(time_i)
|
|
47
|
+
begin
|
|
48
|
+
oldtz, ENV['TZ'] = ENV['TZ'], "UTC+07"
|
|
49
|
+
d = create_driver(config_element('ROOT', '', {key => value}))
|
|
50
|
+
tag = 'test'
|
|
51
|
+
assert_equal "#{expected}\t#{tag}\t#{Yajl.dump(record)}\n", d.instance.format(tag, time, record)
|
|
52
|
+
ensure
|
|
53
|
+
ENV['TZ'] = oldtz
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_format
|
|
58
|
+
d = create_driver({})
|
|
59
|
+
formatted = d.instance.format(tag, @time, record)
|
|
60
|
+
|
|
61
|
+
assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}\n", formatted)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_format_without_time
|
|
65
|
+
d = create_driver('output_time' => 'false')
|
|
66
|
+
formatted = d.instance.format(tag, @time, record)
|
|
67
|
+
|
|
68
|
+
assert_equal("#{tag}\t#{Yajl.dump(record)}\n", formatted)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_format_without_tag
|
|
72
|
+
d = create_driver('output_tag' => 'false')
|
|
73
|
+
formatted = d.instance.format(tag, @time, record)
|
|
74
|
+
|
|
75
|
+
assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}\n", formatted)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_format_without_time_and_tag
|
|
79
|
+
d = create_driver('output_tag' => 'false', 'output_time' => 'false')
|
|
80
|
+
formatted = d.instance.format('tag', @time, record)
|
|
81
|
+
|
|
82
|
+
assert_equal("#{Yajl.dump(record)}\n", formatted)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_format_without_time_and_tag_against_string_literal_configure
|
|
86
|
+
d = create_driver(%[
|
|
87
|
+
utc true
|
|
88
|
+
output_tag false
|
|
89
|
+
output_time false
|
|
90
|
+
])
|
|
91
|
+
formatted = d.instance.format('tag', @time, record)
|
|
92
|
+
|
|
93
|
+
assert_equal("#{Yajl.dump(record)}\n", formatted)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_relative '../helper'
|
|
2
|
+
require 'fluent/test/driver/formatter'
|
|
3
|
+
require 'fluent/plugin/formatter_single_value'
|
|
4
|
+
|
|
5
|
+
class SingleValueFormatterTest < ::Test::Unit::TestCase
|
|
6
|
+
def create_driver(conf = "")
|
|
7
|
+
Fluent::Test::Driver::Formatter.new(Fluent::Plugin::SingleValueFormatter).configure(conf)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_config_params
|
|
11
|
+
d = create_driver
|
|
12
|
+
assert_equal "message", d.instance.message_key
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_config_params_message_key
|
|
16
|
+
d = create_driver('message_key' => 'foobar')
|
|
17
|
+
assert_equal "foobar", d.instance.message_key
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_format
|
|
21
|
+
d = create_driver
|
|
22
|
+
formatted = d.instance.format('tag', event_time, {'message' => 'awesome'})
|
|
23
|
+
assert_equal("awesome\n", formatted)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_format_without_newline
|
|
27
|
+
d = create_driver('add_newline' => 'false')
|
|
28
|
+
formatted = d.instance.format('tag', event_time, {'message' => 'awesome'})
|
|
29
|
+
assert_equal("awesome", formatted)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_format_with_message_key
|
|
33
|
+
d = create_driver('message_key' => 'foobar')
|
|
34
|
+
formatted = d.instance.format('tag', event_time, {'foobar' => 'foo'})
|
|
35
|
+
|
|
36
|
+
assert_equal("foo\n", formatted)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require_relative '../helper'
|
|
2
2
|
require 'fluent/test/driver/input'
|
|
3
3
|
require 'fluent/plugin/in_dummy'
|
|
4
|
+
require 'fileutils'
|
|
4
5
|
|
|
5
6
|
class DummyTest < Test::Unit::TestCase
|
|
6
7
|
def setup
|
|
@@ -90,4 +91,98 @@ class DummyTest < Test::Unit::TestCase
|
|
|
90
91
|
end
|
|
91
92
|
end
|
|
92
93
|
end
|
|
94
|
+
|
|
95
|
+
TEST_PLUGIN_STORAGE_PATH = File.join( File.dirname(File.dirname(__FILE__)), 'tmp', 'in_dummy', 'store' )
|
|
96
|
+
FileUtils.mkdir_p TEST_PLUGIN_STORAGE_PATH
|
|
97
|
+
|
|
98
|
+
sub_test_case "doesn't suspend internal counters in default" do
|
|
99
|
+
config1 = {
|
|
100
|
+
'tag' => 'dummy',
|
|
101
|
+
'rate' => '2',
|
|
102
|
+
'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
|
|
103
|
+
'auto_increment_key' => 'id',
|
|
104
|
+
'suspend' => false,
|
|
105
|
+
}
|
|
106
|
+
conf1 = config_element('ROOT', '', config1, [])
|
|
107
|
+
test "value of auto increment key is not suspended after stop-and-start" do
|
|
108
|
+
assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-01.json'))
|
|
109
|
+
|
|
110
|
+
d1 = create_driver(conf1)
|
|
111
|
+
d1.run(timeout: 0.5) do
|
|
112
|
+
d1.instance.emit(4)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
first_id1 = d1.events.first[2]['id']
|
|
116
|
+
assert_equal 0, first_id1
|
|
117
|
+
|
|
118
|
+
last_id1 = d1.events.last[2]['id']
|
|
119
|
+
assert { last_id1 > 0 }
|
|
120
|
+
|
|
121
|
+
assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-01.json'))
|
|
122
|
+
|
|
123
|
+
d2 = create_driver(conf1)
|
|
124
|
+
d2.run(timeout: 0.5) do
|
|
125
|
+
d2.instance.emit(4)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
first_id2 = d2.events.first[2]['id']
|
|
129
|
+
assert_equal 0, first_id2
|
|
130
|
+
|
|
131
|
+
assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-01.json'))
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
sub_test_case "suspend internal counters if suspend is true" do
|
|
136
|
+
setup do
|
|
137
|
+
FileUtils.rm_rf(TEST_PLUGIN_STORAGE_PATH)
|
|
138
|
+
FileUtils.mkdir_p(File.join(TEST_PLUGIN_STORAGE_PATH, 'json'))
|
|
139
|
+
FileUtils.chmod_R(0755, File.join(TEST_PLUGIN_STORAGE_PATH, 'json'))
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
config2 = {
|
|
143
|
+
'@id' => 'test-02',
|
|
144
|
+
'tag' => 'dummy',
|
|
145
|
+
'rate' => '2',
|
|
146
|
+
'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
|
|
147
|
+
'auto_increment_key' => 'id',
|
|
148
|
+
'suspend' => true,
|
|
149
|
+
}
|
|
150
|
+
conf2 = config_element('ROOT', '', config2, [
|
|
151
|
+
config_element(
|
|
152
|
+
'storage', '',
|
|
153
|
+
{'@type' => 'local',
|
|
154
|
+
'@id' => 'test-02',
|
|
155
|
+
'path' => File.join(TEST_PLUGIN_STORAGE_PATH,
|
|
156
|
+
'json', 'test-02.json'),
|
|
157
|
+
'persistent' => true,
|
|
158
|
+
})
|
|
159
|
+
])
|
|
160
|
+
test "value of auto increment key is suspended after stop-and-start" do
|
|
161
|
+
assert !File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
|
|
162
|
+
|
|
163
|
+
d1 = create_driver(conf2)
|
|
164
|
+
d1.run(timeout: 0.5) do
|
|
165
|
+
d1.instance.emit(4)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
first_id1 = d1.events.first[2]['id']
|
|
169
|
+
assert_equal 0, first_id1
|
|
170
|
+
|
|
171
|
+
last_id1 = d1.events.last[2]['id']
|
|
172
|
+
assert { last_id1 > 0 }
|
|
173
|
+
|
|
174
|
+
assert File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
|
|
175
|
+
|
|
176
|
+
d2 = create_driver(conf2)
|
|
177
|
+
d2.run(timeout: 0.5) do
|
|
178
|
+
d2.instance.emit(4)
|
|
179
|
+
end
|
|
180
|
+
d2.events
|
|
181
|
+
|
|
182
|
+
first_id2 = d2.events.first[2]['id']
|
|
183
|
+
assert_equal last_id1 + 1, first_id2
|
|
184
|
+
|
|
185
|
+
assert File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
|
|
186
|
+
end
|
|
187
|
+
end
|
|
93
188
|
end
|
data/test/plugin/test_in_exec.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require_relative '../helper'
|
|
2
|
-
require 'fluent/test'
|
|
2
|
+
require 'fluent/test/driver/input'
|
|
3
3
|
require 'fluent/plugin/in_exec'
|
|
4
4
|
require 'net/http'
|
|
5
5
|
|
|
6
6
|
class ExecInputTest < Test::Unit::TestCase
|
|
7
7
|
def setup
|
|
8
8
|
Fluent::Test.setup
|
|
9
|
-
@test_time =
|
|
9
|
+
@test_time = event_time("2011-01-02 13:14:15")
|
|
10
10
|
@script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts', 'exec_script.rb'))
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def create_driver(conf = tsv_config)
|
|
14
|
-
Fluent::Test::
|
|
14
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::ExecInput).configure(conf)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def tsv_config
|
|
@@ -86,52 +86,48 @@ class ExecInputTest < Test::Unit::TestCase
|
|
|
86
86
|
def test_emit
|
|
87
87
|
d = create_driver
|
|
88
88
|
|
|
89
|
-
d.run
|
|
90
|
-
sleep 2
|
|
91
|
-
end
|
|
89
|
+
d.run(expect_emits: 2)
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
assert_equal true, d.events.length > 0
|
|
92
|
+
d.events.each_with_index {|event, i|
|
|
93
|
+
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
|
|
94
|
+
assert_equal_event_time(@test_time, event[1])
|
|
95
|
+
}
|
|
97
96
|
end
|
|
98
97
|
|
|
99
98
|
def test_emit_json
|
|
100
99
|
d = create_driver json_config
|
|
101
100
|
|
|
102
|
-
d.run
|
|
103
|
-
sleep 2
|
|
104
|
-
end
|
|
101
|
+
d.run(expect_emits: 2)
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
assert_equal true, d.events.length > 0
|
|
104
|
+
d.events.each_with_index {|event, i|
|
|
105
|
+
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
|
|
106
|
+
assert_equal_event_time(@test_time, event[1])
|
|
107
|
+
}
|
|
110
108
|
end
|
|
111
109
|
|
|
112
110
|
def test_emit_msgpack
|
|
113
111
|
d = create_driver msgpack_config
|
|
114
112
|
|
|
115
|
-
d.run
|
|
116
|
-
sleep 2
|
|
117
|
-
end
|
|
113
|
+
d.run(expect_emits: 2)
|
|
118
114
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
assert_equal true, d.events.length > 0
|
|
116
|
+
d.events.each_with_index {|event, i|
|
|
117
|
+
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
|
|
118
|
+
assert_equal_event_time(@test_time, event[1])
|
|
119
|
+
}
|
|
123
120
|
end
|
|
124
121
|
|
|
125
122
|
def test_emit_regexp
|
|
126
123
|
d = create_driver regexp_config
|
|
127
124
|
|
|
128
|
-
d.run
|
|
129
|
-
sleep 2
|
|
130
|
-
end
|
|
125
|
+
d.run(expect_emits: 2)
|
|
131
126
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
assert_equal true, d.events.length > 0
|
|
128
|
+
d.events.each_with_index {|event, i|
|
|
129
|
+
assert_equal ["regex_tag", @test_time, {"message"=>"hello"}], event
|
|
130
|
+
assert_equal_event_time(@test_time, event[1])
|
|
131
|
+
}
|
|
136
132
|
end
|
|
137
133
|
end
|
|
@@ -242,6 +242,30 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
|
242
242
|
end
|
|
243
243
|
end
|
|
244
244
|
|
|
245
|
+
def test_set_size_to_option
|
|
246
|
+
d = create_driver
|
|
247
|
+
|
|
248
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
|
249
|
+
events = [
|
|
250
|
+
["tag1", time, {"a"=>1}],
|
|
251
|
+
["tag1", time, {"a"=>2}]
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
entries = ''
|
|
255
|
+
events.each {|_tag, _time, record|
|
|
256
|
+
[_time, record].to_msgpack(entries)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
chunk = ["tag1", entries, { 'size' => events.length }].to_msgpack
|
|
260
|
+
|
|
261
|
+
d.run do
|
|
262
|
+
Fluent::Engine.msgpack_factory.unpacker.feed_each(chunk) do |obj|
|
|
263
|
+
option = d.instance.send(:on_message, obj, chunk.size, "host: 127.0.0.1, addr: 127.0.0.1, port: 0000")
|
|
264
|
+
assert_equal option['size'], events.length
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
245
269
|
def test_send_large_chunk_warning
|
|
246
270
|
d = create_driver(CONFIG + %[
|
|
247
271
|
chunk_size_warn_limit 16M
|
|
@@ -27,13 +27,13 @@ class GCStatInputTest < Test::Unit::TestCase
|
|
|
27
27
|
stub(GC).stat { stat }
|
|
28
28
|
|
|
29
29
|
d = create_driver
|
|
30
|
-
d.run
|
|
31
|
-
sleep 2
|
|
32
|
-
end
|
|
30
|
+
d.run(expect_emits: 2)
|
|
33
31
|
|
|
34
32
|
events = d.events
|
|
35
33
|
assert(events.length > 0)
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
events.each_index {|i|
|
|
35
|
+
assert_equal(stat, events[i][2])
|
|
36
|
+
assert(events[i][1].is_a?(Fluent::EventTime))
|
|
37
|
+
}
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require_relative '../helper'
|
|
2
|
-
require 'fluent/test'
|
|
2
|
+
require 'fluent/test/driver/input'
|
|
3
3
|
require 'fluent/plugin/in_object_space'
|
|
4
4
|
|
|
5
5
|
require 'timeout'
|
|
@@ -33,7 +33,7 @@ class ObjectSpaceInputTest < Test::Unit::TestCase
|
|
|
33
33
|
]
|
|
34
34
|
|
|
35
35
|
def create_driver(conf=TESTCONFIG)
|
|
36
|
-
Fluent::Test::
|
|
36
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::ObjectSpaceInput).configure(conf)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def test_configure
|
|
@@ -48,11 +48,11 @@ class ObjectSpaceInputTest < Test::Unit::TestCase
|
|
|
48
48
|
|
|
49
49
|
d.run do
|
|
50
50
|
waiting(10, d.instance) do
|
|
51
|
-
sleep 0.5 until d.
|
|
51
|
+
sleep 0.5 until d.events.size > 3
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
emits = d.
|
|
55
|
+
emits = d.events
|
|
56
56
|
assert{ emits.length > 0 }
|
|
57
57
|
|
|
58
58
|
emits.each { |tag, time, record|
|