fluentd 0.12.0.pre.2 → 0.12.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/example/v0_12_filter.conf +78 -0
- data/fluentd.gemspec +2 -1
- data/lib/fluent/agent.rb +2 -1
- data/lib/fluent/buffer.rb +9 -5
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/config/basic_parser.rb +1 -0
- data/lib/fluent/config/configure_proxy.rb +7 -7
- data/lib/fluent/config/types.rb +1 -0
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/engine.rb +0 -25
- data/lib/fluent/env.rb +1 -0
- data/lib/fluent/event_router.rb +6 -2
- data/lib/fluent/filter.rb +12 -1
- data/lib/fluent/formatter.rb +85 -16
- data/lib/fluent/label.rb +4 -0
- data/lib/fluent/output.rb +1 -0
- data/lib/fluent/parser.rb +25 -23
- data/lib/fluent/plugin.rb +18 -0
- data/lib/fluent/plugin/buf_file.rb +1 -1
- data/lib/fluent/plugin/in_dummy.rb +103 -0
- data/lib/fluent/plugin/in_http.rb +30 -10
- data/lib/fluent/plugin/in_syslog.rb +4 -4
- data/lib/fluent/plugin/in_tail.rb +6 -6
- data/lib/fluent/plugin/out_file.rb +3 -3
- data/lib/fluent/plugin/socket_util.rb +2 -2
- data/lib/fluent/registry.rb +9 -27
- data/lib/fluent/root_agent.rb +26 -7
- data/lib/fluent/supervisor.rb +40 -27
- data/lib/fluent/test.rb +1 -0
- data/lib/fluent/test/base.rb +14 -0
- data/lib/fluent/test/filter_test.rb +33 -0
- data/lib/fluent/test/output_test.rb +7 -1
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_config_parser.rb +6 -2
- data/test/config/test_configurable.rb +1 -1
- data/test/config/test_configure_proxy.rb +1 -1
- data/test/config/test_dsl.rb +1 -1
- data/test/config/test_literal_parser.rb +2 -2
- data/test/config/test_section.rb +1 -1
- data/test/config/test_system_config.rb +65 -15
- data/test/config/test_types.rb +63 -0
- data/test/helper.rb +2 -1
- data/test/plugin/test_buf_file.rb +1 -1
- data/test/plugin/test_buf_memory.rb +1 -1
- data/test/plugin/test_filter_grep.rb +17 -23
- data/test/plugin/test_filter_record_transformer.rb +18 -21
- data/test/plugin/test_in_dummy.rb +95 -0
- data/test/plugin/test_in_exec.rb +1 -1
- data/test/plugin/test_in_forward.rb +1 -1
- data/test/plugin/test_in_gc_stat.rb +1 -1
- data/test/plugin/test_in_http.rb +1 -1
- data/test/plugin/test_in_object_space.rb +1 -1
- data/test/plugin/test_in_status.rb +1 -1
- data/test/plugin/test_in_stream.rb +1 -1
- data/test/plugin/test_in_syslog.rb +1 -1
- data/test/plugin/test_in_tail.rb +1 -1
- data/test/plugin/test_in_tcp.rb +1 -1
- data/test/plugin/test_in_udp.rb +1 -1
- data/test/plugin/test_out_copy.rb +12 -1
- data/test/plugin/test_out_exec.rb +1 -1
- data/test/plugin/test_out_exec_filter.rb +1 -1
- data/test/plugin/test_out_file.rb +61 -8
- data/test/plugin/test_out_forward.rb +1 -1
- data/test/plugin/test_out_roundrobin.rb +12 -1
- data/test/plugin/test_out_stdout.rb +1 -1
- data/test/plugin/test_out_stream.rb +1 -1
- data/test/scripts/fluent/plugin/formatter_known.rb +4 -1
- data/{lib → test/scripts}/fluent/plugin/out_test.rb +0 -0
- data/test/scripts/fluent/plugin/parser_known.rb +2 -1
- data/test/test_buffer.rb +1 -1
- data/test/test_config.rb +1 -1
- data/test/test_configdsl.rb +1 -1
- data/test/test_event_router.rb +233 -0
- data/test/test_formatter.rb +160 -3
- data/test/test_input.rb +30 -0
- data/test/test_match.rb +100 -77
- data/test/test_mixin.rb +1 -1
- data/test/test_output.rb +1 -1
- data/test/test_parser.rb +5 -3
- data/test/test_plugin_classes.rb +60 -0
- metadata +32 -4
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/config/types'
|
3
|
+
|
4
|
+
class TestConfigTypes < ::Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
|
+
sub_test_case 'Config.size_value' do
|
8
|
+
test 'normal case' do
|
9
|
+
assert_equal(2048, Config.size_value("2k"))
|
10
|
+
assert_equal(2048, Config.size_value("2K"))
|
11
|
+
assert_equal(3145728, Config.size_value("3m"))
|
12
|
+
assert_equal(3145728, Config.size_value("3M"))
|
13
|
+
assert_equal(4294967296, Config.size_value("4g"))
|
14
|
+
assert_equal(4294967296, Config.size_value("4G"))
|
15
|
+
assert_equal(5497558138880, Config.size_value("5t"))
|
16
|
+
assert_equal(5497558138880, Config.size_value("5T"))
|
17
|
+
assert_equal(6, Config.size_value("6"))
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'not assumed case' do
|
21
|
+
assert_equal(6, Config.size_value(6))
|
22
|
+
assert_equal(0, Config.size_value("hoge"))
|
23
|
+
assert_equal(0, Config.size_value(""))
|
24
|
+
assert_equal(0, Config.size_value(nil))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
sub_test_case 'Config.time_value' do
|
29
|
+
test 'normal case' do
|
30
|
+
assert_equal(10, Config.time_value("10s"))
|
31
|
+
assert_equal(10, Config.time_value("10sec"))
|
32
|
+
assert_equal(120, Config.time_value("2m"))
|
33
|
+
assert_equal(10800, Config.time_value("3h"))
|
34
|
+
assert_equal(345600, Config.time_value("4d"))
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'not assumed case' do
|
38
|
+
assert_equal(4.0, Config.time_value(4))
|
39
|
+
assert_equal(0.4, Config.time_value(0.4))
|
40
|
+
assert_equal(0.0, Config.time_value("hoge"))
|
41
|
+
assert_equal(0.0, Config.time_value(""))
|
42
|
+
assert_equal(0.0, Config.time_value(nil))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
sub_test_case 'Config.bool_value' do
|
47
|
+
test 'normal case' do
|
48
|
+
assert_true Config.bool_value("true")
|
49
|
+
assert_true Config.bool_value("yes")
|
50
|
+
assert_true Config.bool_value("")
|
51
|
+
assert_false Config.bool_value("false")
|
52
|
+
assert_false Config.bool_value("no")
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'not assumed case' do
|
56
|
+
assert_true Config.bool_value(true)
|
57
|
+
assert_false Config.bool_value(false)
|
58
|
+
assert_nil Config.bool_value("hoge")
|
59
|
+
assert_nil Config.bool_value(nil)
|
60
|
+
assert_nil Config.bool_value(10)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/test/helper.rb
CHANGED
@@ -23,11 +23,12 @@ if ENV['SIMPLE_COV']
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
require 'rr'
|
26
27
|
require 'test/unit'
|
28
|
+
require 'test/unit/rr'
|
27
29
|
require 'fileutils'
|
28
30
|
require 'fluent/log'
|
29
31
|
require 'fluent/test'
|
30
|
-
require 'rr'
|
31
32
|
|
32
33
|
unless defined?(Test::Unit::AssertionFailedError)
|
33
34
|
class Test::Unit::AssertionFailedError < StandardError
|
@@ -1,39 +1,33 @@
|
|
1
|
-
|
2
|
-
require 'fluent/test'
|
1
|
+
require_relative '../helper'
|
3
2
|
require 'fluent/plugin/filter_grep'
|
4
3
|
|
5
|
-
# TODO: Replace with FilterTestDriver
|
6
4
|
class GrepFilterTest < Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
7
|
setup do
|
8
|
-
|
8
|
+
Fluent::Test.setup
|
9
9
|
@time = Fluent::Engine.now
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
str
|
15
|
-
else
|
16
|
-
Fluent::Config.parse(conf, "(test)", "(test_dir)", use_v1)
|
17
|
-
end
|
18
|
-
instance.configure(config)
|
19
|
-
instance
|
12
|
+
def create_driver(conf = '')
|
13
|
+
Test::FilterTestDriver.new(GrepFilter).configure(conf, true)
|
20
14
|
end
|
21
15
|
|
22
16
|
sub_test_case 'configure' do
|
23
17
|
test 'check default' do
|
24
|
-
|
25
|
-
assert_empty(
|
26
|
-
assert_empty(
|
18
|
+
d = create_driver
|
19
|
+
assert_empty(d.instance.regexps)
|
20
|
+
assert_empty(d.instance.excludes)
|
27
21
|
end
|
28
22
|
|
29
23
|
test "regexpN can contain a space" do
|
30
|
-
|
31
|
-
assert_equal(Regexp.compile(/ foo/),
|
24
|
+
d = create_driver(%[regexp1 message foo])
|
25
|
+
assert_equal(Regexp.compile(/ foo/), d.instance.regexps['message'])
|
32
26
|
end
|
33
27
|
|
34
28
|
test "excludeN can contain a space" do
|
35
|
-
|
36
|
-
assert_equal(Regexp.compile(/ foo/),
|
29
|
+
d = create_driver(%[exclude1 message foo])
|
30
|
+
assert_equal(Regexp.compile(/ foo/), d.instance.excludes['message'])
|
37
31
|
end
|
38
32
|
end
|
39
33
|
|
@@ -53,8 +47,8 @@ class GrepFilterTest < Test::Unit::TestCase
|
|
53
47
|
es.add(@time, {'foo' => 'bar', 'message' => msg})
|
54
48
|
}
|
55
49
|
|
56
|
-
|
57
|
-
|
50
|
+
d = create_driver(config)
|
51
|
+
d.filter_stream('filter.test', es);
|
58
52
|
end
|
59
53
|
|
60
54
|
test 'empty config' do
|
@@ -102,8 +96,8 @@ class GrepFilterTest < Test::Unit::TestCase
|
|
102
96
|
es = Fluent::MultiEventStream.new
|
103
97
|
es.add(@time, {'foo' => 'bar', 'message' => msg})
|
104
98
|
|
105
|
-
|
106
|
-
|
99
|
+
d = create_driver(config)
|
100
|
+
d.filter_stream('filter.test', es);
|
107
101
|
end
|
108
102
|
|
109
103
|
data(
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require_relative '../helper'
|
2
2
|
require 'timecop'
|
3
|
-
require 'fluent/test'
|
4
3
|
require 'fluent/plugin/filter_record_transformer'
|
5
4
|
|
6
|
-
# TODO: Replace with FilterTestDriver
|
7
5
|
class RecordTransformerFilterTest < Test::Unit::TestCase
|
6
|
+
include Fluent
|
7
|
+
|
8
8
|
setup do
|
9
|
-
|
9
|
+
Test.setup
|
10
10
|
@hostname = Socket.gethostname.chomp
|
11
11
|
@tag = 'test.tag'
|
12
12
|
@tag_parts = @tag.split('.')
|
@@ -18,26 +18,20 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
|
|
18
18
|
Timecop.return
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
str
|
24
|
-
else
|
25
|
-
Fluent::Config.parse(conf, "(test)", "(test_dir)", use_v1)
|
26
|
-
end
|
27
|
-
instance.configure(config)
|
28
|
-
instance
|
21
|
+
def create_driver(conf = '')
|
22
|
+
Test::FilterTestDriver.new(RecordTransformerFilter).configure(conf, true)
|
29
23
|
end
|
30
24
|
|
31
25
|
sub_test_case 'configure' do
|
32
26
|
test 'check default' do
|
33
27
|
assert_nothing_raised do
|
34
|
-
|
28
|
+
create_driver
|
35
29
|
end
|
36
30
|
end
|
37
31
|
|
38
32
|
test "keep_keys must be specified together with renew_record true" do
|
39
33
|
assert_raise(Fluent::ConfigError) do
|
40
|
-
|
34
|
+
create_driver(%[keep_keys a])
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -49,8 +43,8 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
|
|
49
43
|
es.add(@time, {'foo' => 'bar', 'message' => msg})
|
50
44
|
end
|
51
45
|
|
52
|
-
|
53
|
-
|
46
|
+
d = create_driver(config)
|
47
|
+
d.filter_stream(@tag, es)
|
54
48
|
end
|
55
49
|
|
56
50
|
CONFIG = %[
|
@@ -131,8 +125,9 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
|
|
131
125
|
es.add(@time, {'eventType0' => 'bar', 'message' => msg})
|
132
126
|
end
|
133
127
|
|
134
|
-
|
135
|
-
|
128
|
+
d = create_driver(config)
|
129
|
+
yield d if block_given?
|
130
|
+
d.filter_stream(@tag, es)
|
136
131
|
end
|
137
132
|
|
138
133
|
%w[yes no].each do |enable_ruby|
|
@@ -230,8 +225,9 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
|
|
230
225
|
message ${unknown}
|
231
226
|
</record>
|
232
227
|
]
|
233
|
-
|
234
|
-
|
228
|
+
emit(config) { |d|
|
229
|
+
mock(d.instance.log).warn("unknown placeholder `${unknown}` found")
|
230
|
+
}
|
235
231
|
end
|
236
232
|
|
237
233
|
test 'failed to expand (enable_ruby yes)' do
|
@@ -241,8 +237,9 @@ class RecordTransformerFilterTest < Test::Unit::TestCase
|
|
241
237
|
message ${unknown['bar']}
|
242
238
|
</record>
|
243
239
|
]
|
244
|
-
|
245
|
-
|
240
|
+
es = emit(config) { |d|
|
241
|
+
mock(d.instance.log).warn("failed to expand `${unknown['bar']}`", anything)
|
242
|
+
}
|
246
243
|
es.each do |t, r|
|
247
244
|
assert_nil(r['message'])
|
248
245
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
|
4
|
+
class DummyTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_driver(conf)
|
10
|
+
Fluent::Test::InputTestDriver.new(Fluent::DummyInput).configure(conf)
|
11
|
+
end
|
12
|
+
|
13
|
+
sub_test_case 'configure' do
|
14
|
+
test 'required parameters' do
|
15
|
+
assert_raise_message("'tag' parameter is required") do
|
16
|
+
create_driver('')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'tag' do
|
21
|
+
d = create_driver(%[
|
22
|
+
tag dummy
|
23
|
+
])
|
24
|
+
assert_equal "dummy", d.instance.tag
|
25
|
+
end
|
26
|
+
|
27
|
+
config = %[
|
28
|
+
tag dummy
|
29
|
+
]
|
30
|
+
|
31
|
+
test 'auto_increment_key' do
|
32
|
+
d = create_driver(config + %[
|
33
|
+
auto_increment_key id
|
34
|
+
])
|
35
|
+
assert_equal "id", d.instance.auto_increment_key
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'rate' do
|
39
|
+
d = create_driver(config + %[
|
40
|
+
rate 10
|
41
|
+
])
|
42
|
+
assert_equal 10, d.instance.rate
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'dummy' do
|
46
|
+
# hash is okay
|
47
|
+
d = create_driver(config + %[dummy {"foo":"bar"}])
|
48
|
+
assert_equal [{"foo"=>"bar"}], d.instance.dummy
|
49
|
+
|
50
|
+
# array of hash is okay
|
51
|
+
d = create_driver(config + %[dummy [{"foo":"bar"}]])
|
52
|
+
assert_equal [{"foo"=>"bar"}], d.instance.dummy
|
53
|
+
|
54
|
+
assert_raise_message(/JSON::ParserError|got incomplete JSON/) do
|
55
|
+
create_driver(config + %[dummy "foo"])
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_raise_message(/is not a hash/) do
|
59
|
+
create_driver(config + %[dummy ["foo"]])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
sub_test_case "emit" do
|
65
|
+
config = %[
|
66
|
+
tag dummy
|
67
|
+
rate 10
|
68
|
+
dummy {"foo":"bar"}
|
69
|
+
]
|
70
|
+
|
71
|
+
test 'simple' do
|
72
|
+
d = create_driver(config)
|
73
|
+
d.run {
|
74
|
+
# d.run sleeps 0.5 sec
|
75
|
+
}
|
76
|
+
emits = d.emits
|
77
|
+
emits.each do |tag, time, record|
|
78
|
+
assert_equal("dummy", tag)
|
79
|
+
assert_equal({"foo"=>"bar"}, record)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
test 'with auto_increment_key' do
|
84
|
+
d = create_driver(config + %[auto_increment_key id])
|
85
|
+
d.run {
|
86
|
+
# d.run sleeps 0.5 sec
|
87
|
+
}
|
88
|
+
emits = d.emits
|
89
|
+
emits.each_with_index do |(tag, time, record), i|
|
90
|
+
assert_equal("dummy", tag)
|
91
|
+
assert_equal({"foo"=>"bar", "id"=>i}, record)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/test/plugin/test_in_exec.rb
CHANGED
data/test/plugin/test_in_http.rb
CHANGED
data/test/plugin/test_in_tail.rb
CHANGED
data/test/plugin/test_in_tcp.rb
CHANGED
data/test/plugin/test_in_udp.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
-
|
1
|
+
require_relative '../helper'
|
2
2
|
require 'fluent/test'
|
3
3
|
|
4
4
|
class CopyOutputTest < Test::Unit::TestCase
|
5
|
+
class << self
|
6
|
+
def startup
|
7
|
+
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts'))
|
8
|
+
require 'fluent/plugin/out_test'
|
9
|
+
end
|
10
|
+
|
11
|
+
def shutdown
|
12
|
+
$LOAD_PATH.shift
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
5
16
|
def setup
|
6
17
|
Fluent::Test.setup
|
7
18
|
end
|