fluentd 0.10.62 → 0.12.0.pre.1
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/.gitignore +1 -2
- data/.travis.yml +0 -4
- data/ChangeLog +0 -72
- data/Gemfile +0 -6
- data/Rakefile +12 -3
- data/example/in_http.conf +14 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/out_copy.conf +20 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +30 -0
- data/fluent.conf +2 -12
- data/fluentd.gemspec +8 -11
- data/lib/fluent/agent.rb +180 -0
- data/lib/fluent/buffer.rb +6 -12
- data/lib/fluent/command/cat.rb +1 -3
- data/lib/fluent/command/debug.rb +1 -3
- data/lib/fluent/command/fluentd.rb +0 -10
- data/lib/fluent/config.rb +9 -3
- data/lib/fluent/config/basic_parser.rb +1 -6
- data/lib/fluent/config/configure_proxy.rb +25 -61
- data/lib/fluent/config/dsl.rb +16 -0
- data/lib/fluent/config/element.rb +21 -2
- data/lib/fluent/config/error.rb +16 -0
- data/lib/fluent/config/literal_parser.rb +9 -27
- data/lib/fluent/config/parser.rb +16 -0
- data/lib/fluent/config/section.rb +16 -2
- data/lib/fluent/config/types.rb +16 -1
- data/lib/fluent/config/v1_parser.rb +4 -12
- data/lib/fluent/configurable.rb +16 -0
- data/lib/fluent/engine.rb +43 -163
- data/lib/fluent/env.rb +16 -1
- data/lib/fluent/event.rb +20 -48
- data/lib/fluent/event_router.rb +187 -0
- data/lib/fluent/filter.rb +32 -0
- data/lib/fluent/formatter.rb +29 -101
- data/lib/fluent/input.rb +6 -4
- data/lib/fluent/label.rb +18 -0
- data/lib/fluent/load.rb +1 -3
- data/lib/fluent/log.rb +1 -3
- data/lib/fluent/match.rb +12 -19
- data/lib/fluent/mixin.rb +9 -25
- data/lib/fluent/output.rb +27 -45
- data/lib/fluent/parser.rb +93 -99
- data/lib/fluent/plugin.rb +22 -48
- data/lib/fluent/plugin/buf_file.rb +10 -7
- data/lib/fluent/plugin/buf_memory.rb +2 -3
- data/lib/fluent/plugin/buf_zfile.rb +75 -0
- data/lib/fluent/plugin/exec_util.rb +16 -0
- data/lib/fluent/plugin/in_debug_agent.rb +2 -3
- data/lib/fluent/plugin/in_exec.rb +2 -9
- data/lib/fluent/plugin/in_forward.rb +4 -22
- data/lib/fluent/plugin/in_gc_stat.rb +2 -3
- data/lib/fluent/plugin/in_http.rb +19 -59
- data/lib/fluent/plugin/in_monitor_agent.rb +21 -47
- data/lib/fluent/plugin/in_object_space.rb +2 -3
- data/lib/fluent/plugin/in_status.rb +2 -3
- data/lib/fluent/plugin/in_stream.rb +6 -16
- data/lib/fluent/plugin/in_syslog.rb +8 -17
- data/lib/fluent/plugin/in_tail.rb +17 -24
- data/lib/fluent/plugin/in_tcp.rb +16 -0
- data/lib/fluent/plugin/in_udp.rb +16 -0
- data/lib/fluent/plugin/out_copy.rb +3 -4
- data/lib/fluent/plugin/out_exec.rb +2 -4
- data/lib/fluent/plugin/out_exec_filter.rb +2 -13
- data/lib/fluent/plugin/out_file.rb +5 -6
- data/lib/fluent/plugin/out_forward.rb +4 -5
- data/lib/fluent/plugin/out_null.rb +2 -3
- data/lib/fluent/plugin/out_relabel.rb +26 -0
- data/lib/fluent/plugin/out_roundrobin.rb +3 -4
- data/lib/fluent/plugin/out_stdout.rb +2 -3
- data/lib/fluent/plugin/out_stream.rb +2 -3
- data/{test/scripts → lib}/fluent/plugin/out_test.rb +2 -3
- data/lib/fluent/plugin/socket_util.rb +19 -10
- data/lib/fluent/process.rb +4 -6
- data/lib/fluent/registry.rb +16 -0
- data/lib/fluent/root_agent.rb +212 -0
- data/lib/fluent/status.rb +2 -3
- data/lib/fluent/supervisor.rb +33 -54
- data/lib/fluent/test.rb +16 -0
- data/lib/fluent/test/base.rb +3 -17
- data/lib/fluent/test/input_test.rb +52 -7
- data/lib/fluent/test/output_test.rb +4 -20
- data/lib/fluent/version.rb +17 -1
- data/spec/config/config_parser_spec.rb +314 -0
- data/spec/config/configurable_spec.rb +524 -0
- data/spec/config/configure_proxy_spec.rb +96 -0
- data/spec/config/dsl_spec.rb +239 -0
- data/spec/config/helper.rb +49 -0
- data/spec/config/literal_parser_spec.rb +222 -0
- data/spec/config/section_spec.rb +97 -0
- data/spec/config/system_config_spec.rb +49 -0
- data/test/helper.rb +0 -25
- data/test/plugin/test_in_exec.rb +1 -1
- data/test/plugin/test_in_forward.rb +2 -1
- data/test/plugin/test_in_gc_stat.rb +1 -1
- data/test/plugin/test_in_http.rb +3 -78
- 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 +2 -1
- data/test/plugin/test_in_syslog.rb +2 -1
- data/test/plugin/test_in_tail.rb +6 -11
- data/test/plugin/test_in_tcp.rb +2 -1
- data/test/plugin/test_in_udp.rb +2 -1
- data/test/plugin/test_out_copy.rb +1 -12
- 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 +7 -96
- data/test/plugin/test_out_forward.rb +2 -1
- data/test/plugin/test_out_roundrobin.rb +1 -12
- data/test/plugin/test_out_stdout.rb +1 -1
- data/test/plugin/test_out_stream.rb +2 -1
- data/test/scripts/fluent/plugin/formatter_known.rb +1 -4
- data/test/scripts/fluent/plugin/parser_known.rb +1 -2
- data/test/test_config.rb +1 -1
- data/test/test_configdsl.rb +2 -1
- data/test/test_formatter.rb +3 -395
- data/test/test_match.rb +2 -1
- data/test/test_mixin.rb +3 -75
- data/test/test_output.rb +1 -112
- data/test/test_parser.rb +85 -152
- metadata +58 -167
- data/example/v1_literal_example.conf +0 -36
- data/lib/fluent/plugin/in_dummy.rb +0 -103
- data/lib/fluent/timezone.rb +0 -131
- data/test/config/assertions.rb +0 -42
- data/test/config/test_config_parser.rb +0 -389
- data/test/config/test_configurable.rb +0 -652
- data/test/config/test_configure_proxy.rb +0 -99
- data/test/config/test_dsl.rb +0 -237
- data/test/config/test_literal_parser.rb +0 -295
- data/test/config/test_section.rb +0 -112
- data/test/config/test_system_config.rb +0 -99
- data/test/config/test_types.rb +0 -63
- data/test/plugin/test_in_dummy.rb +0 -95
- data/test/test_event.rb +0 -168
- data/test/test_input.rb +0 -21
data/test/config/test_section.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/config/section'
|
3
|
-
|
4
|
-
module Fluent::Config
|
5
|
-
class TestSection < ::Test::Unit::TestCase
|
6
|
-
sub_test_case Fluent::Config::Section do
|
7
|
-
sub_test_case 'class' do
|
8
|
-
sub_test_case '.name' do
|
9
|
-
test 'returns its full module name as String' do
|
10
|
-
assert_equal('Fluent::Config::Section', Fluent::Config::Section.name)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
sub_test_case 'instance object' do
|
16
|
-
sub_test_case '#initialize' do
|
17
|
-
test 'creates blank object without argument' do
|
18
|
-
s = Fluent::Config::Section.new
|
19
|
-
assert_equal({}, s.instance_eval{ @params })
|
20
|
-
end
|
21
|
-
|
22
|
-
test 'creates object which contains specified hash object itself' do
|
23
|
-
hash = {
|
24
|
-
name: 'tagomoris',
|
25
|
-
age: 34,
|
26
|
-
send: 'email',
|
27
|
-
class: 'normal',
|
28
|
-
keys: 5,
|
29
|
-
}
|
30
|
-
s1 = Fluent::Config::Section.new(hash)
|
31
|
-
assert_equal(hash, s1.instance_eval { @params })
|
32
|
-
assert_equal("tagomoris", s1[:name])
|
33
|
-
assert_equal(34, s1[:age])
|
34
|
-
assert_equal("email", s1[:send])
|
35
|
-
assert_equal("normal", s1[:class])
|
36
|
-
assert_equal(5, s1[:keys])
|
37
|
-
|
38
|
-
assert_equal("tagomoris", s1.name)
|
39
|
-
assert_equal(34, s1.age)
|
40
|
-
assert_equal("email", s1.send)
|
41
|
-
assert_equal("normal", s1.class)
|
42
|
-
assert_equal(5, s1.keys)
|
43
|
-
|
44
|
-
assert_raise(NoMethodError) { s1.dup }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
sub_test_case '#object_id' do
|
49
|
-
test 'returns its object id' do
|
50
|
-
s1 = Fluent::Config::Section.new({})
|
51
|
-
assert s1.object_id
|
52
|
-
s2 = Fluent::Config::Section.new({})
|
53
|
-
assert s2.object_id
|
54
|
-
assert_not_equal s1.object_id, s2.object_id
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
sub_test_case '#to_h' do
|
59
|
-
test 'returns internal hash itself' do
|
60
|
-
hash = {
|
61
|
-
name: 'tagomoris',
|
62
|
-
age: 34,
|
63
|
-
send: 'email',
|
64
|
-
class: 'normal',
|
65
|
-
keys: 5,
|
66
|
-
}
|
67
|
-
s = Fluent::Config::Section.new(hash)
|
68
|
-
assert_equal(hash, s.to_h)
|
69
|
-
assert_instance_of(Hash, s.to_h)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
sub_test_case '#instance_of?' do
|
74
|
-
test 'can judge whether it is a Section object or not' do
|
75
|
-
s = Fluent::Config::Section.new
|
76
|
-
assert_true(s.instance_of?(Fluent::Config::Section))
|
77
|
-
assert_false(s.instance_of?(BasicObject))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
sub_test_case '#is_a?' do
|
82
|
-
test 'can judge whether it belongs to or not' do
|
83
|
-
s = Fluent::Config::Section.new
|
84
|
-
assert_true(s.is_a?(Fluent::Config::Section))
|
85
|
-
assert_true(s.kind_of?(Fluent::Config::Section))
|
86
|
-
assert_true(s.is_a?(BasicObject))
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
sub_test_case '#+' do
|
91
|
-
test 'can merge 2 sections: argument side is primary, internal hash is newly created' do
|
92
|
-
h1 = {name: "s1", num: 10, class: "A"}
|
93
|
-
s1 = Fluent::Config::Section.new(h1)
|
94
|
-
|
95
|
-
h2 = {name: "s2", class: "A", num2: "5", num3: "8"}
|
96
|
-
s2 = Fluent::Config::Section.new(h2)
|
97
|
-
s = s1 + s2
|
98
|
-
|
99
|
-
assert_not_equal(h1.object_id, s.to_h.object_id)
|
100
|
-
assert_not_equal(h2.object_id, s.to_h.object_id)
|
101
|
-
|
102
|
-
assert_equal("s2", s.name)
|
103
|
-
assert_equal(10, s.num)
|
104
|
-
assert_equal("A", s.class)
|
105
|
-
assert_equal("5", s.num2)
|
106
|
-
assert_equal("8", s.num3)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
require 'fluent/configurable'
|
3
|
-
require 'fluent/config/element'
|
4
|
-
require 'fluent/config/section'
|
5
|
-
require 'fluent/supervisor'
|
6
|
-
|
7
|
-
module Fluent::Config
|
8
|
-
class FakeLoggerInitializer
|
9
|
-
attr_accessor :level
|
10
|
-
def initalize
|
11
|
-
@level = nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class FakeSupervisor
|
16
|
-
def initialize
|
17
|
-
@log = FakeLoggerInitializer.new
|
18
|
-
@log_level = nil
|
19
|
-
@suppress_interval = nil
|
20
|
-
@suppress_config_dump = nil
|
21
|
-
@suppress_repeated_stacktrace = nil
|
22
|
-
@without_source = nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class TestSystemConfig < ::Test::Unit::TestCase
|
27
|
-
|
28
|
-
def parse_text(text)
|
29
|
-
basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
|
30
|
-
Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'should not override default configurations when no parameters' do
|
34
|
-
conf = parse_text(<<-EOS)
|
35
|
-
<system>
|
36
|
-
</system>
|
37
|
-
EOS
|
38
|
-
s = FakeSupervisor.new
|
39
|
-
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
40
|
-
sc.apply(s)
|
41
|
-
assert_nil(sc.log_level)
|
42
|
-
assert_nil(sc.suppress_repeated_stacktrace)
|
43
|
-
assert_nil(sc.emit_error_log_interval)
|
44
|
-
assert_nil(sc.suppress_config_dump)
|
45
|
-
assert_nil(sc.without_source)
|
46
|
-
assert_nil(s.instance_variable_get(:@log_level))
|
47
|
-
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
48
|
-
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
49
|
-
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
50
|
-
assert_nil(s.instance_variable_get(:@without_source))
|
51
|
-
end
|
52
|
-
|
53
|
-
{'log_level' => 'error',
|
54
|
-
'suppress_repeated_stacktrace' => true,
|
55
|
-
'emit_error_log_interval' => 60,
|
56
|
-
'suppress_config_dump' => true,
|
57
|
-
'without_source' => true,
|
58
|
-
}.each { |k, v|
|
59
|
-
test "accepts #{k} parameter" do
|
60
|
-
conf = parse_text(<<-EOS)
|
61
|
-
<system>
|
62
|
-
#{k} #{v}
|
63
|
-
</system>
|
64
|
-
EOS
|
65
|
-
s = FakeSupervisor.new
|
66
|
-
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
67
|
-
sc.apply(s)
|
68
|
-
assert_not_nil(sc.instance_variable_get("@#{k}"))
|
69
|
-
key = (k == 'emit_error_log_interval' ? 'suppress_interval' : k)
|
70
|
-
assert_not_nil(s.instance_variable_get("@#{key}"))
|
71
|
-
end
|
72
|
-
}
|
73
|
-
|
74
|
-
{'foo' => 'bar', 'hoge' => 'fuga'}.each { |k, v|
|
75
|
-
test "should not affect settable parameters with unknown #{k} parameter" do
|
76
|
-
s = FakeSupervisor.new
|
77
|
-
sc = Fluent::Supervisor::SystemConfig.new({k => v})
|
78
|
-
sc.apply(s)
|
79
|
-
assert_nil(s.instance_variable_get(:@log_level))
|
80
|
-
assert_nil(s.instance_variable_get(:@suppress_repeated_stacktrace))
|
81
|
-
assert_nil(s.instance_variable_get(:@emit_error_log_interval))
|
82
|
-
assert_nil(s.instance_variable_get(:@suppress_config_dump))
|
83
|
-
assert_nil(s.instance_variable_get(:@without_source))
|
84
|
-
end
|
85
|
-
}
|
86
|
-
|
87
|
-
test 'log_level' do
|
88
|
-
conf = parse_text(<<-EOS)
|
89
|
-
<system>
|
90
|
-
log_level warn
|
91
|
-
</system>
|
92
|
-
EOS
|
93
|
-
s = FakeSupervisor.new
|
94
|
-
sc = Fluent::Supervisor::SystemConfig.new(conf)
|
95
|
-
sc.apply(s)
|
96
|
-
assert_equal(Fluent::Log::LEVEL_WARN, s.instance_variable_get("@log").level)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/test/config/test_types.rb
DELETED
@@ -1,63 +0,0 @@
|
|
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
|
@@ -1,95 +0,0 @@
|
|
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/test_event.rb
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'fluent/test'
|
3
|
-
require 'fluent/event'
|
4
|
-
|
5
|
-
module EventTest
|
6
|
-
class OneEventStreamTest < ::Test::Unit::TestCase
|
7
|
-
include Fluent
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@time = Engine.now
|
11
|
-
@record = {'k' => 'v', 'n' => 1}
|
12
|
-
@es = OneEventStream.new(@time, @record)
|
13
|
-
end
|
14
|
-
|
15
|
-
test 'repeatable?' do
|
16
|
-
assert_true @es.repeatable?
|
17
|
-
end
|
18
|
-
|
19
|
-
test 'dup' do
|
20
|
-
dupped = @es.dup
|
21
|
-
assert_kind_of OneEventStream, dupped
|
22
|
-
assert_not_equal @es.object_id, dupped.object_id
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'each' do
|
26
|
-
@es.each { |time, record|
|
27
|
-
assert_equal @time, time
|
28
|
-
assert_equal @record, record
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'to_msgpack_stream' do
|
33
|
-
stream = @es.to_msgpack_stream
|
34
|
-
MessagePack::Unpacker.new.feed_each(stream) { |time, record|
|
35
|
-
assert_equal @time, time
|
36
|
-
assert_equal @record, record
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class ArrayEventStreamTest < ::Test::Unit::TestCase
|
42
|
-
include Fluent
|
43
|
-
|
44
|
-
def setup
|
45
|
-
@times = [Engine.now, Engine.now + 1]
|
46
|
-
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
47
|
-
@es = ArrayEventStream.new(@times.zip(@records))
|
48
|
-
end
|
49
|
-
|
50
|
-
test 'repeatable?' do
|
51
|
-
assert_true @es.repeatable?
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'dup' do
|
55
|
-
dupped = @es.dup
|
56
|
-
assert_kind_of ArrayEventStream, dupped
|
57
|
-
assert_not_equal @es.object_id, dupped.object_id
|
58
|
-
end
|
59
|
-
|
60
|
-
test 'empty?' do
|
61
|
-
assert_not_empty @es
|
62
|
-
assert_true ArrayEventStream.new([]).empty?
|
63
|
-
end
|
64
|
-
|
65
|
-
test 'each' do
|
66
|
-
i = 0
|
67
|
-
@es.each { |time, record|
|
68
|
-
assert_equal @times[i], time
|
69
|
-
assert_equal @records[i], record
|
70
|
-
i += 1
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
test 'to_msgpack_stream' do
|
75
|
-
i = 0
|
76
|
-
stream = @es.to_msgpack_stream
|
77
|
-
MessagePack::Unpacker.new.feed_each(stream) { |time, record|
|
78
|
-
assert_equal @times[i], time
|
79
|
-
assert_equal @records[i], record
|
80
|
-
i += 1
|
81
|
-
}
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class MultiEventStreamTest < ::Test::Unit::TestCase
|
86
|
-
include Fluent
|
87
|
-
|
88
|
-
def setup
|
89
|
-
@times = [Engine.now, Engine.now + 1]
|
90
|
-
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
91
|
-
@es = MultiEventStream.new
|
92
|
-
@times.zip(@records).each { |time, record|
|
93
|
-
@es.add(time, record)
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
test 'repeatable?' do
|
98
|
-
assert_true @es.repeatable?
|
99
|
-
end
|
100
|
-
|
101
|
-
test 'dup' do
|
102
|
-
dupped = @es.dup
|
103
|
-
assert_kind_of MultiEventStream, dupped
|
104
|
-
assert_not_equal @es.object_id, dupped.object_id
|
105
|
-
end
|
106
|
-
|
107
|
-
test 'empty?' do
|
108
|
-
assert_not_empty @es
|
109
|
-
assert_true MultiEventStream.new.empty?
|
110
|
-
end
|
111
|
-
|
112
|
-
test 'each' do
|
113
|
-
i = 0
|
114
|
-
@es.each { |time, record|
|
115
|
-
assert_equal @times[i], time
|
116
|
-
assert_equal @records[i], record
|
117
|
-
i += 1
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
test 'to_msgpack_stream' do
|
122
|
-
i = 0
|
123
|
-
stream = @es.to_msgpack_stream
|
124
|
-
MessagePack::Unpacker.new.feed_each(stream) { |time, record|
|
125
|
-
assert_equal @times[i], time
|
126
|
-
assert_equal @records[i], record
|
127
|
-
i += 1
|
128
|
-
}
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
class MessagePackEventStreamTest < ::Test::Unit::TestCase
|
133
|
-
include Fluent
|
134
|
-
|
135
|
-
def setup
|
136
|
-
out = ''.force_encoding('ASCII-8BIT')
|
137
|
-
@times = [Engine.now, Engine.now + 1]
|
138
|
-
@records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
|
139
|
-
@times.zip(@records).each { |time, record|
|
140
|
-
out << MessagePack.pack([time, record])
|
141
|
-
}
|
142
|
-
@es = MessagePackEventStream.new(out)
|
143
|
-
end
|
144
|
-
|
145
|
-
test 'repeatable?' do
|
146
|
-
assert_true @es.repeatable?
|
147
|
-
end
|
148
|
-
|
149
|
-
test 'each' do
|
150
|
-
i = 0
|
151
|
-
@es.each { |time, record|
|
152
|
-
assert_equal @times[i], time
|
153
|
-
assert_equal @records[i], record
|
154
|
-
i += 1
|
155
|
-
}
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'to_msgpack_stream' do
|
159
|
-
i = 0
|
160
|
-
stream = @es.to_msgpack_stream
|
161
|
-
MessagePack::Unpacker.new.feed_each(stream) { |time, record|
|
162
|
-
assert_equal @times[i], time
|
163
|
-
assert_equal @records[i], record
|
164
|
-
i += 1
|
165
|
-
}
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|