fluent-plugin-copy_ex 0.0.3 → 0.1.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 +3 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.v0.12 +4 -0
- data/Rakefile +1 -1
- data/example/stdout_and_file.conf +25 -0
- data/example/stdout_and_stdout.conf +14 -0
- data/fluent-plugin-copy_ex.gemspec +1 -1
- data/lib/fluent/plugin/out_copy_ex.rb +6 -80
- data/lib/fluent/plugin/out_copy_ex/v12.rb +49 -0
- data/lib/fluent/plugin/out_copy_ex/v14.rb +46 -0
- data/test/{plugin/test_out_copy_ex.rb → out_copy_ex/v12.rb} +21 -43
- data/test/out_copy_ex/v14.rb +203 -0
- data/test/test_out_copy_ex.rb +9 -0
- metadata +14 -6
- data/example/fluent.conf +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9594127ab0102725fc88886986e3934234088aa1
|
4
|
+
data.tar.gz: 78c257e8b902c9c82cc3a973ca89fcaea447e2d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c12758f99c7876d8d85b0309f29a4cc07281033f9df0040baba572a084cec05dd8852e6a49947cdf372f7b161d3c39802c6375a5d3024a1845bd6aa186df801d
|
7
|
+
data.tar.gz: ac50e1b57fb77b181a57bba289835a32ba9edc8cd1918403d6bd68c02429ccae5e85f3c62542555f27be171c5c378eb8152ce44bac316dc7c7e5b9761b62d8fa
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.v0.12
ADDED
data/Rakefile
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
<source>
|
2
|
+
@type dummy
|
3
|
+
tag "test.*"
|
4
|
+
</source>
|
5
|
+
<match **>
|
6
|
+
@type copy_ex
|
7
|
+
<store>
|
8
|
+
@type stdout
|
9
|
+
</store>
|
10
|
+
<store>
|
11
|
+
@type file
|
12
|
+
append true
|
13
|
+
path "output.log"
|
14
|
+
time_slice_format test-%Y-%m-%d
|
15
|
+
<format>
|
16
|
+
@type json
|
17
|
+
localtime false
|
18
|
+
</format>
|
19
|
+
<buffer>
|
20
|
+
@type memory
|
21
|
+
flush_mode immediate
|
22
|
+
flush_at_shutdown true
|
23
|
+
</buffer>
|
24
|
+
</store>
|
25
|
+
</match>
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-copy_ex"
|
6
|
-
s.version = "0.0
|
6
|
+
s.version = "0.1.0"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-copy_ex"
|
@@ -1,81 +1,7 @@
|
|
1
|
-
require 'fluent/
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
config_param :deep_copy, :bool, :default => false
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
super
|
11
|
-
@outputs = []
|
12
|
-
@ignore_errors = []
|
13
|
-
@emit_procs = []
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_reader :outputs, :ignore_errors
|
17
|
-
|
18
|
-
def configure(conf)
|
19
|
-
super
|
20
|
-
conf.elements.select {|e|
|
21
|
-
e.name == 'store'
|
22
|
-
}.each {|e|
|
23
|
-
type = e['@type'] || e['type']
|
24
|
-
unless type
|
25
|
-
raise ConfigError, "Missing '@type' parameter on <store> directive"
|
26
|
-
end
|
27
|
-
log.debug "adding store type=#{type.dump}"
|
28
|
-
|
29
|
-
output = Plugin.new_output(type)
|
30
|
-
output.configure(e)
|
31
|
-
emit_proc = if output.respond_to?(:emit_events)
|
32
|
-
Proc.new {|output, tag, es, _chain| output.emit_events(tag, es)}
|
33
|
-
else
|
34
|
-
Proc.new {|output, tag, es, _chain| output.emit(tag, es, NullOutputChain.instance)}
|
35
|
-
end
|
36
|
-
@emit_procs << emit_proc
|
37
|
-
@outputs << output
|
38
|
-
|
39
|
-
@ignore_errors << (e.arg == "ignore_error")
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def start
|
44
|
-
@outputs.each {|o|
|
45
|
-
o.start
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def shutdown
|
50
|
-
@outputs.each {|o|
|
51
|
-
o.shutdown
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def emit(tag, es, chain)
|
56
|
-
unless es.repeatable?
|
57
|
-
m = MultiEventStream.new
|
58
|
-
es.each {|time,record|
|
59
|
-
m.add(time, record)
|
60
|
-
}
|
61
|
-
es = m
|
62
|
-
end
|
63
|
-
|
64
|
-
# Here, we do not use OutputChain for custom
|
65
|
-
@outputs.each_index do |idx|
|
66
|
-
_es = @deep_copy ? es.dup : es
|
67
|
-
begin
|
68
|
-
@emit_procs[idx].call(@outputs[idx], tag, _es, NullOutputChain.instance)
|
69
|
-
rescue => e
|
70
|
-
if @ignore_errors[idx]
|
71
|
-
log.error :error_class => e.class, :error => e.message
|
72
|
-
else
|
73
|
-
raise e
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
chain.next
|
79
|
-
end
|
80
|
-
end
|
1
|
+
require 'fluent/version'
|
2
|
+
major, minor, patch = Fluent::VERSION.split('.').map(&:to_i)
|
3
|
+
if major > 0 || (major == 0 && minor >= 14)
|
4
|
+
require_relative 'out_copy_ex/v14'
|
5
|
+
else
|
6
|
+
require_relative 'out_copy_ex/v12'
|
81
7
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fluent/plugin/out_copy'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class CopyExOutput < CopyOutput
|
5
|
+
Plugin.register_output('copy_ex', self)
|
6
|
+
|
7
|
+
attr_reader :ignore_errors
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
@ignore_errors = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(conf)
|
15
|
+
super
|
16
|
+
|
17
|
+
conf.elements.select {|e|
|
18
|
+
e.name == 'store'
|
19
|
+
}.each {|e|
|
20
|
+
@ignore_errors << (e.arg == "ignore_error")
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def emit(tag, es, chain)
|
25
|
+
unless es.repeatable?
|
26
|
+
m = MultiEventStream.new
|
27
|
+
es.each {|time,record|
|
28
|
+
m.add(time, record)
|
29
|
+
}
|
30
|
+
es = m
|
31
|
+
end
|
32
|
+
|
33
|
+
# Here, we do not use OutputChain for custom
|
34
|
+
outputs.each.with_index do |output, idx|
|
35
|
+
begin
|
36
|
+
output.emit(tag, @deep_copy ? es.dup : es, NullOutputChain.instance)
|
37
|
+
rescue => e
|
38
|
+
if @ignore_errors[idx]
|
39
|
+
log.error :error_class => e.class, :error => e.message
|
40
|
+
else
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
chain.next
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fluent/plugin/out_copy'
|
2
|
+
|
3
|
+
module Fluent::Plugin
|
4
|
+
class CopyExOutput < CopyOutput
|
5
|
+
Fluent::Plugin.register_output('copy_ex', self)
|
6
|
+
|
7
|
+
attr_reader :ignore_errors
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
@ignore_errors = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(conf)
|
15
|
+
super
|
16
|
+
|
17
|
+
conf.elements.select {|e|
|
18
|
+
e.name == 'store'
|
19
|
+
}.each {|e|
|
20
|
+
@ignore_errors << (e.arg == "ignore_error")
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def process(tag, es)
|
25
|
+
unless es.repeatable?
|
26
|
+
m = Fluent::MultiEventStream.new
|
27
|
+
es.each {|time,record|
|
28
|
+
m.add(time, record)
|
29
|
+
}
|
30
|
+
es = m
|
31
|
+
end
|
32
|
+
|
33
|
+
outputs.each.with_index do |output, idx|
|
34
|
+
begin
|
35
|
+
output.emit_events(tag, @deep_copy ? es.dup : es)
|
36
|
+
rescue => e
|
37
|
+
if @ignore_errors[idx]
|
38
|
+
log.error :error_class => e.class, :error => e.message
|
39
|
+
else
|
40
|
+
raise e
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
|
1
|
+
require_relative '../helper'
|
2
2
|
|
3
3
|
class CopyExOutputTest < Test::Unit::TestCase
|
4
4
|
class << self
|
5
5
|
def startup
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift File.join(spec.full_gem_path, 'test', 'scripts')
|
6
|
+
$LOAD_PATH.unshift "#{Gem.loaded_specs['fluentd'].full_gem_path}/test/scripts"
|
8
7
|
require 'fluent/plugin/out_test'
|
9
8
|
end
|
10
9
|
|
@@ -17,10 +16,6 @@ class CopyExOutputTest < Test::Unit::TestCase
|
|
17
16
|
Fluent::Test.setup
|
18
17
|
end
|
19
18
|
|
20
|
-
def config_element(name = 'test', argument = '', params = {}, elements = [])
|
21
|
-
Fluent::Config::Element.new(name, argument, params, elements)
|
22
|
-
end
|
23
|
-
|
24
19
|
CONFIG = %[
|
25
20
|
<store>
|
26
21
|
type test
|
@@ -60,9 +55,9 @@ class CopyExOutputTest < Test::Unit::TestCase
|
|
60
55
|
|
61
56
|
outputs = d.instance.outputs
|
62
57
|
assert_equal 3, outputs.size
|
63
|
-
assert_equal Fluent::
|
64
|
-
assert_equal Fluent::
|
65
|
-
assert_equal Fluent::
|
58
|
+
assert_equal Fluent::TestOutput, outputs[0].class
|
59
|
+
assert_equal Fluent::TestOutput, outputs[1].class
|
60
|
+
assert_equal Fluent::TestOutput, outputs[2].class
|
66
61
|
assert_equal "c0", outputs[0].name
|
67
62
|
assert_equal "c1", outputs[1].name
|
68
63
|
assert_equal "c2", outputs[2].name
|
@@ -88,39 +83,35 @@ class CopyExOutputTest < Test::Unit::TestCase
|
|
88
83
|
|
89
84
|
d.instance.outputs.each {|o|
|
90
85
|
assert_equal [
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
[time, {"a"=>1}],
|
87
|
+
[time, {"a"=>2}],
|
88
|
+
], o.events
|
89
|
+
}
|
90
|
+
|
91
|
+
d.instance.outputs.each {|o|
|
92
|
+
assert_not_nil o.router
|
94
93
|
}
|
95
94
|
end
|
96
95
|
|
97
96
|
def test_msgpack_es_emit_bug
|
98
97
|
d = Fluent::Test::OutputTestDriver.new(Fluent::CopyExOutput)
|
99
98
|
|
100
|
-
emit_procs = []
|
101
99
|
outputs = %w(p1 p2).map do |pname|
|
102
100
|
p = Fluent::Plugin.new_output('test')
|
103
|
-
p.configure(
|
101
|
+
p.configure('name' => pname)
|
104
102
|
p.define_singleton_method(:emit) do |tag, es, chain|
|
105
103
|
es.each do |time, record|
|
106
104
|
super(tag, [[time, record]], chain)
|
107
105
|
end
|
108
106
|
end
|
109
|
-
emit_proc = if p.respond_to?(:emit_events)
|
110
|
-
Proc.new {|p, tag, es, _chain| p.emit_events(tag, es)}
|
111
|
-
else
|
112
|
-
Proc.new {|p, tag, es, _chain| p.emit(tag, es, NullOutputChain.instance)}
|
113
|
-
end
|
114
|
-
emit_procs << emit_proc
|
115
107
|
p
|
116
108
|
end
|
117
109
|
|
118
110
|
d.instance.instance_eval { @outputs = outputs }
|
119
|
-
d.instance.instance_eval { @emit_procs = emit_procs }
|
120
111
|
|
121
112
|
es = if defined?(MessagePack::Packer)
|
122
113
|
time = Time.parse("2013-05-26 06:37:22 UTC").to_i
|
123
|
-
packer =
|
114
|
+
packer = Fluent::Engine.msgpack_factory.packer
|
124
115
|
packer.pack([time, {"a" => 1}])
|
125
116
|
packer.pack([time, {"a" => 2}])
|
126
117
|
Fluent::MessagePackEventStream.new(packer.to_s)
|
@@ -142,42 +133,30 @@ class CopyExOutputTest < Test::Unit::TestCase
|
|
142
133
|
def create_event_test_driver(is_deep_copy = false)
|
143
134
|
deep_copy_config = %[
|
144
135
|
deep_copy true
|
145
|
-
]
|
136
|
+
]
|
146
137
|
|
147
138
|
output1 = Fluent::Plugin.new_output('test')
|
148
|
-
output1.configure(
|
149
|
-
output1.define_singleton_method(:
|
139
|
+
output1.configure('name' => 'output1')
|
140
|
+
output1.define_singleton_method(:emit) do |tag, es, chain|
|
150
141
|
es.each do |time, record|
|
151
142
|
record['foo'] = 'bar'
|
152
|
-
super(tag, [[time, record]])
|
143
|
+
super(tag, [[time, record]], chain)
|
153
144
|
end
|
154
145
|
end
|
155
|
-
proc1 = if output1.respond_to?(:emit_events)
|
156
|
-
Proc.new {|output1, tag, es, _chain| output1.emit_events(tag, es)}
|
157
|
-
else
|
158
|
-
Proc.new {|output1, tag, es, _chain| output1.emit(tag, es, NullOutputChain.instance)}
|
159
|
-
end
|
160
146
|
|
161
147
|
output2 = Fluent::Plugin.new_output('test')
|
162
|
-
output2.configure(
|
163
|
-
output2.define_singleton_method(:
|
148
|
+
output2.configure('name' => 'output2')
|
149
|
+
output2.define_singleton_method(:emit) do |tag, es, chain|
|
164
150
|
es.each do |time, record|
|
165
|
-
super(tag, [[time, record]])
|
151
|
+
super(tag, [[time, record]], chain)
|
166
152
|
end
|
167
153
|
end
|
168
|
-
proc2 = if output2.respond_to?(:emit_events)
|
169
|
-
Proc.new {|output2, tag, es, _chain| output2.emit_events(tag, es)}
|
170
|
-
else
|
171
|
-
Proc.new {|output2, tag, es, _chain| output2.emit(tag, es, NullOutputChain.instance)}
|
172
|
-
end
|
173
154
|
|
174
155
|
outputs = [output1, output2]
|
175
|
-
emit_procs = [proc1, proc2]
|
176
156
|
|
177
157
|
d = Fluent::Test::OutputTestDriver.new(Fluent::CopyExOutput)
|
178
158
|
d = d.configure(deep_copy_config) if is_deep_copy
|
179
159
|
d.instance.instance_eval { @outputs = outputs }
|
180
|
-
d.instance.instance_eval { @emit_procs = emit_procs }
|
181
160
|
d
|
182
161
|
end
|
183
162
|
|
@@ -241,4 +220,3 @@ deep_copy true
|
|
241
220
|
assert_nothing_raised { d.emit({"a"=>1}, time) }
|
242
221
|
end
|
243
222
|
end
|
244
|
-
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require "fluent/test/driver/multi_output"
|
3
|
+
|
4
|
+
class CopyExOutputTest < Test::Unit::TestCase
|
5
|
+
class << self
|
6
|
+
def startup
|
7
|
+
$LOAD_PATH.unshift "#{Gem.loaded_specs['fluentd'].full_gem_path}/test/scripts"
|
8
|
+
require 'fluent/plugin/out_test'
|
9
|
+
require 'fluent/plugin/out_test2'
|
10
|
+
end
|
11
|
+
|
12
|
+
def shutdown
|
13
|
+
$LOAD_PATH.shift
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
Fluent::Test.setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_element(name = 'test', argument = '', params = {}, elements = [])
|
22
|
+
Fluent::Config::Element.new(name, argument, params, elements)
|
23
|
+
end
|
24
|
+
|
25
|
+
CONFIG = %[
|
26
|
+
<store>
|
27
|
+
@type test
|
28
|
+
name c0
|
29
|
+
</store>
|
30
|
+
<store>
|
31
|
+
@type test2
|
32
|
+
name c1
|
33
|
+
</store>
|
34
|
+
<store>
|
35
|
+
@type test
|
36
|
+
name c2
|
37
|
+
</store>
|
38
|
+
]
|
39
|
+
|
40
|
+
IGNORE_ERROR_CONFIG = %[
|
41
|
+
<store ignore_error>
|
42
|
+
@type test
|
43
|
+
name c0
|
44
|
+
</store>
|
45
|
+
<store ignore_error>
|
46
|
+
@type test
|
47
|
+
name c1
|
48
|
+
</store>
|
49
|
+
<store>
|
50
|
+
@type test
|
51
|
+
name c2
|
52
|
+
</store>
|
53
|
+
]
|
54
|
+
|
55
|
+
def create_driver(conf = CONFIG)
|
56
|
+
Fluent::Test::Driver::MultiOutput.new(Fluent::Plugin::CopyExOutput).configure(conf)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_configure
|
60
|
+
d = create_driver
|
61
|
+
|
62
|
+
outputs = d.instance.outputs
|
63
|
+
assert_equal 3, outputs.size
|
64
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[0].class
|
65
|
+
assert_equal Fluent::Plugin::Test2Output, outputs[1].class
|
66
|
+
assert_equal Fluent::Plugin::TestOutput, outputs[2].class
|
67
|
+
assert_equal "c0", outputs[0].name
|
68
|
+
assert_equal "c1", outputs[1].name
|
69
|
+
assert_equal "c2", outputs[2].name
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_configure_ignore_error
|
73
|
+
d = create_driver(IGNORE_ERROR_CONFIG)
|
74
|
+
|
75
|
+
outputs = d.instance.outputs
|
76
|
+
ignore_errors = d.instance.ignore_errors
|
77
|
+
assert_equal outputs.size, ignore_errors.size
|
78
|
+
assert_equal true, ignore_errors[0]
|
79
|
+
assert_equal true, ignore_errors[1]
|
80
|
+
assert_equal false, ignore_errors[2]
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_feed_events
|
84
|
+
d = create_driver
|
85
|
+
|
86
|
+
assert !d.instance.outputs[0].has_router?
|
87
|
+
assert_not_nil d.instance.outputs[1].router
|
88
|
+
assert !d.instance.outputs[2].has_router?
|
89
|
+
|
90
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
91
|
+
d.run(default_tag: 'test') do
|
92
|
+
d.feed(time, {"a" => 1})
|
93
|
+
d.feed(time, {"a" => 2})
|
94
|
+
end
|
95
|
+
|
96
|
+
d.instance.outputs.each {|o|
|
97
|
+
assert_equal [ [time, {"a"=>1}], [time, {"a"=>2}] ], o.events
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_msgpack_unpacker_cache_bug_for_msgpack_event_stream
|
102
|
+
d = create_driver
|
103
|
+
|
104
|
+
time = Fluent::EventTime.parse("2011-01-02 13:14:15 UTC")
|
105
|
+
source = Fluent::ArrayEventStream.new([ [time, {"a" => 1}], [time, {"a" => 2}] ])
|
106
|
+
es = Fluent::MessagePackEventStream.new(source.to_msgpack_stream)
|
107
|
+
|
108
|
+
d.run(default_tag: 'test') do
|
109
|
+
d.feed(es)
|
110
|
+
end
|
111
|
+
|
112
|
+
d.instance.outputs.each { |o|
|
113
|
+
assert_equal [ [time, {"a"=>1}], [time, {"a"=>2}] ], o.events
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
def create_event_test_driver(does_deep_copy = false)
|
118
|
+
config = %[
|
119
|
+
deep_copy #{does_deep_copy}
|
120
|
+
<store>
|
121
|
+
@type test
|
122
|
+
name output1
|
123
|
+
</store>
|
124
|
+
<store>
|
125
|
+
@type test
|
126
|
+
name output2
|
127
|
+
</store>
|
128
|
+
]
|
129
|
+
|
130
|
+
d = Fluent::Test::Driver::MultiOutput.new(Fluent::Plugin::CopyExOutput).configure(config)
|
131
|
+
d.instance.outputs[0].define_singleton_method(:process) do |tag, es|
|
132
|
+
es.each do |time, record|
|
133
|
+
record['foo'] = 'bar'
|
134
|
+
end
|
135
|
+
super(tag, es)
|
136
|
+
end
|
137
|
+
d
|
138
|
+
end
|
139
|
+
|
140
|
+
time = Fluent::EventTime.parse("2013-05-26 06:37:22 UTC")
|
141
|
+
mes0 = Fluent::MultiEventStream.new
|
142
|
+
mes0.add(time, {"a" => 1})
|
143
|
+
mes0.add(time, {"b" => 1})
|
144
|
+
mes1 = Fluent::MultiEventStream.new
|
145
|
+
mes1.add(time, {"a" => 1})
|
146
|
+
mes1.add(time, {"b" => 1})
|
147
|
+
|
148
|
+
data(
|
149
|
+
"OneEventStream without deep_copy" => [false, Fluent::OneEventStream.new(time, {"a" => 1})],
|
150
|
+
"OneEventStream with deep_copy" => [true, Fluent::OneEventStream.new(time, {"a" => 1})],
|
151
|
+
"ArrayEventStream without deep_copy" => [false, Fluent::ArrayEventStream.new([ [time, {"a" => 1}], [time, {"b" => 2}] ])],
|
152
|
+
"ArrayEventStream with deep_copy" => [true, Fluent::ArrayEventStream.new([ [time, {"a" => 1}], [time, {"b" => 2}] ])],
|
153
|
+
"MultiEventStream without deep_copy" => [false, mes0],
|
154
|
+
"MultiEventStream with deep_copy" => [true, mes1],
|
155
|
+
)
|
156
|
+
def test_deep_copy_controls_shallow_or_deep_copied(data)
|
157
|
+
does_deep_copy, es = data
|
158
|
+
|
159
|
+
d = create_event_test_driver(does_deep_copy)
|
160
|
+
|
161
|
+
d.run(default_tag: 'test') do
|
162
|
+
d.feed(es)
|
163
|
+
end
|
164
|
+
|
165
|
+
events = d.instance.outputs.map(&:events)
|
166
|
+
|
167
|
+
if does_deep_copy
|
168
|
+
events[0].each_with_index do |entry0, i|
|
169
|
+
record0 = entry0.last
|
170
|
+
record1 = events[1][i].last
|
171
|
+
|
172
|
+
assert{ record0.object_id != record1.object_id }
|
173
|
+
assert_equal "bar", record0["foo"]
|
174
|
+
assert !record1.has_key?("foo")
|
175
|
+
end
|
176
|
+
else
|
177
|
+
events[0].each_with_index do |entry0, i|
|
178
|
+
record0 = entry0.last
|
179
|
+
record1 = events[1][i].last
|
180
|
+
|
181
|
+
assert{ record0.object_id == record1.object_id }
|
182
|
+
assert_equal "bar", record0["foo"]
|
183
|
+
assert_equal "bar", record1["foo"]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_ignore_error
|
189
|
+
d = create_driver(IGNORE_ERROR_CONFIG)
|
190
|
+
|
191
|
+
# override to raise an error
|
192
|
+
d.instance.outputs[0].define_singleton_method(:process) do |tag, es|
|
193
|
+
raise ArgumentError, 'Failed'
|
194
|
+
end
|
195
|
+
|
196
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
197
|
+
assert_nothing_raised do
|
198
|
+
d.run(default_tag: 'test') do
|
199
|
+
d.feed(time, {"a"=>1})
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-copy_ex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -91,14 +91,20 @@ files:
|
|
91
91
|
- ".travis.yml"
|
92
92
|
- CHANGELOG.md
|
93
93
|
- Gemfile
|
94
|
+
- Gemfile.v0.12
|
94
95
|
- LICENSE
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
|
-
- example/
|
98
|
+
- example/stdout_and_file.conf
|
99
|
+
- example/stdout_and_stdout.conf
|
98
100
|
- fluent-plugin-copy_ex.gemspec
|
99
101
|
- lib/fluent/plugin/out_copy_ex.rb
|
102
|
+
- lib/fluent/plugin/out_copy_ex/v12.rb
|
103
|
+
- lib/fluent/plugin/out_copy_ex/v14.rb
|
100
104
|
- test/helper.rb
|
101
|
-
- test/
|
105
|
+
- test/out_copy_ex/v12.rb
|
106
|
+
- test/out_copy_ex/v14.rb
|
107
|
+
- test/test_out_copy_ex.rb
|
102
108
|
homepage: https://github.com/sonots/fluent-plugin-copy_ex
|
103
109
|
licenses:
|
104
110
|
- MIT
|
@@ -119,10 +125,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
125
|
version: '0'
|
120
126
|
requirements: []
|
121
127
|
rubyforge_project: fluent-plugin-copy_ex
|
122
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.13
|
123
129
|
signing_key:
|
124
130
|
specification_version: 4
|
125
131
|
summary: Fluentd out_copy extension
|
126
132
|
test_files:
|
127
133
|
- test/helper.rb
|
128
|
-
- test/
|
134
|
+
- test/out_copy_ex/v12.rb
|
135
|
+
- test/out_copy_ex/v14.rb
|
136
|
+
- test/test_out_copy_ex.rb
|