fluent-plugin-mongo 0.7.16 → 0.8.0.rc1

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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16
4
+ version: 0.8.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.9'
39
+ version: 2.2.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.9'
46
+ version: 2.2.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -119,17 +119,14 @@ files:
119
119
  - bin/mongo-tail
120
120
  - fluent-plugin-mongo.gemspec
121
121
  - lib/fluent/plugin/in_mongo_tail.rb
122
- - lib/fluent/plugin/mongo_util.rb
122
+ - lib/fluent/plugin/logger_support.rb
123
+ - lib/fluent/plugin/mongo_auth.rb
123
124
  - lib/fluent/plugin/out_mongo.rb
124
125
  - lib/fluent/plugin/out_mongo_replset.rb
125
- - lib/fluent/plugin/out_mongo_tag_collection.rb
126
- - test/plugin/in_mongo_tail.rb
127
- - test/plugin/out_mongo.rb
128
- - test/plugin/out_mongo_tag_mapped.rb
129
- - test/test_helper.rb
130
- - test/tools/auth_repl_set_manager.rb
131
- - test/tools/repl_set_manager.rb
132
- - test/tools/rs_test_helper.rb
126
+ - test/helper.rb
127
+ - test/plugin/test_in_mongo_tail.rb
128
+ - test/plugin/test_out_mongo.rb
129
+ - test/plugin/test_out_mongo_replset.rb
133
130
  homepage: https://github.com/fluent/fluent-plugin-mongo
134
131
  licenses:
135
132
  - Apache-2.0
@@ -145,9 +142,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
142
  version: '0'
146
143
  required_rubygems_version: !ruby/object:Gem::Requirement
147
144
  requirements:
148
- - - ">="
145
+ - - ">"
149
146
  - !ruby/object:Gem::Version
150
- version: '0'
147
+ version: 1.3.1
151
148
  requirements: []
152
149
  rubyforge_project:
153
150
  rubygems_version: 2.5.1
@@ -155,10 +152,7 @@ signing_key:
155
152
  specification_version: 4
156
153
  summary: MongoDB plugin for Fluentd
157
154
  test_files:
158
- - test/plugin/in_mongo_tail.rb
159
- - test/plugin/out_mongo.rb
160
- - test/plugin/out_mongo_tag_mapped.rb
161
- - test/test_helper.rb
162
- - test/tools/auth_repl_set_manager.rb
163
- - test/tools/repl_set_manager.rb
164
- - test/tools/rs_test_helper.rb
155
+ - test/helper.rb
156
+ - test/plugin/test_in_mongo_tail.rb
157
+ - test/plugin/test_out_mongo.rb
158
+ - test/plugin/test_out_mongo_replset.rb
@@ -1,27 +0,0 @@
1
- module Fluent
2
-
3
-
4
- module MongoUtil
5
- def self.included(klass)
6
- klass.instance_eval {
7
- config_param :user, :string, :default => nil
8
- config_param :password, :string, :default => nil, :secret => true
9
- }
10
- end
11
-
12
- def authenticate(db)
13
- unless @user.nil? || @password.nil?
14
- begin
15
- db.authenticate(@user, @password)
16
- rescue Mongo::AuthenticationError => e
17
- log.fatal e
18
- exit!
19
- end
20
- end
21
-
22
- db
23
- end
24
- end
25
-
26
-
27
- end
@@ -1,20 +0,0 @@
1
- require 'fluent/plugin/out_mongo'
2
-
3
- module Fluent
4
- class MongoOutputTagCollection < MongoOutput
5
- Plugin.register_output('mongo_tag_collection', self)
6
-
7
- config_param :collection, :string, :default => 'untagged'
8
-
9
- def configure(conf)
10
- super
11
-
12
- @tag_mapped = true
13
- if remove_prefix_collection = conf['remove_prefix_collection']
14
- @remove_tag_prefix = Regexp.new('^' + Regexp.escape(remove_prefix_collection))
15
- end
16
-
17
- log.warn "'mongo_tag_collection' deprecated. Please use 'mongo' type with 'tag_mapped' parameter"
18
- end
19
- end
20
- end
@@ -1,73 +0,0 @@
1
- require 'test_helper'
2
- require 'fluent/plugin/in_mongo_tail'
3
-
4
- class MongoTailInputTest < Test::Unit::TestCase
5
- def setup
6
- Fluent::Test.setup
7
- end
8
-
9
- CONFIG = %[
10
- type mongo_tail
11
- database test
12
- collection log
13
- tag_key tag
14
- time_key time
15
- id_store_file /tmp/fluent_mongo_last_id
16
- id_store_collection test_last_id
17
- ]
18
-
19
- def create_driver(conf = CONFIG)
20
- Fluent::Test::InputTestDriver.new(Fluent::MongoTailInput).configure(conf)
21
- end
22
-
23
- def test_configure
24
- d = create_driver
25
- assert_equal('localhost', d.instance.host)
26
- assert_equal(27017, d.instance.port)
27
- assert_equal('test', d.instance.database)
28
- assert_equal('log', d.instance.collection)
29
- assert_equal('tag', d.instance.tag_key)
30
- assert_equal('time', d.instance.time_key)
31
- assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
32
- assert_equal('test_last_id', d.instance.id_store_collection)
33
- end
34
-
35
- def test_url_configration
36
- config = %[
37
- type mongo_tail
38
- url mongodb://localhost:27017/test
39
- collection log
40
- tag_key tag
41
- time_key time
42
- id_store_file /tmp/fluent_mongo_last_id
43
- ]
44
-
45
- d = create_driver(config)
46
- assert_equal("mongodb://localhost:27017/test", d.instance.url)
47
- assert_nil(d.instance.database)
48
- assert_equal('log', d.instance.collection)
49
- assert_equal('tag', d.instance.tag_key)
50
- assert_equal('time', d.instance.time_key)
51
- assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
52
- end
53
-
54
- def test_url_and_database_can_not_exist
55
- config = %[
56
- type mongo_tail
57
- url mongodb://localhost:27017/test
58
- database test2
59
- collection log
60
- tag_key tag
61
- time_key time
62
- id_store_file /tmp/fluent_mongo_last_id
63
- ]
64
-
65
- assert_raises Fluent::ConfigError do
66
- create_driver(config)
67
- end
68
- end
69
-
70
- def test_emit
71
- # TODO: write actual code
72
- end
73
- end
@@ -1,298 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'tools/rs_test_helper'
3
- require 'fluent/plugin/out_mongo'
4
-
5
- module MongoOutputTestCases
6
- def collection_name
7
- 'test'
8
- end
9
-
10
- def test_configure_with_write_concern
11
- d = create_driver(default_config + %[
12
- write_concern 2
13
- ])
14
-
15
- assert_equal({:w => 2, :pool_size => 1, :ssl => false, :j => false}, d.instance.connection_options)
16
- end
17
-
18
- def test_configure_with_journaled
19
- d = create_driver(default_config + %[
20
- journaled true
21
- ])
22
-
23
- assert_equal({:ssl => false, :pool_size => 1, :j => true}, d.instance.connection_options)
24
- end
25
-
26
- def test_configure_with_ssl
27
- d = create_driver(default_config + %[
28
- ssl true
29
- ])
30
-
31
- assert_equal({:ssl => true, :pool_size => 1, :j => false, :ssl_cert=>nil, :ssl_key=>nil, :ssl_key_pass_phrase=>nil, :ssl_verify=>false, :ssl_ca_cert=>nil}, d.instance.connection_options)
32
- end
33
-
34
- def test_format
35
- d = create_driver
36
-
37
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
38
- d.emit({'a' => 1}, time)
39
- d.emit({'a' => 2}, time)
40
- d.expect_format([time, {'a' => 1, d.instance.time_key => time}].to_msgpack)
41
- d.expect_format([time, {'a' => 2, d.instance.time_key => time}].to_msgpack)
42
- d.run
43
-
44
- assert_equal(2, @db.collection(collection_name).count)
45
- end
46
-
47
- def emit_documents(d)
48
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
49
- d.emit({'a' => 1}, time)
50
- d.emit({'a' => 2}, time)
51
- time
52
- end
53
-
54
- def get_documents
55
- @db.collection(collection_name).find().to_a.map { |e| e.delete('_id'); e }
56
- end
57
-
58
- def test_write
59
- d = create_driver
60
- t = emit_documents(d)
61
-
62
- d.run
63
- documents = get_documents.map { |e| e['a'] }.sort
64
- assert_equal([1, 2], documents)
65
- assert_equal(2, documents.size)
66
- end
67
-
68
- def test_write_at_enable_tag
69
- d = create_driver(default_config + %[
70
- include_tag_key true
71
- include_time_key false
72
- ])
73
- t = emit_documents(d)
74
-
75
- d.run
76
- documents = get_documents.sort_by { |e| e['a'] }
77
- assert_equal([{'a' => 1, d.instance.tag_key => 'test'},
78
- {'a' => 2, d.instance.tag_key => 'test'}], documents)
79
- assert_equal(2, documents.size)
80
- end
81
-
82
- def emit_invalid_documents(d)
83
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
84
- d.emit({'a' => 3, 'b' => "c", '$last' => '石動'}, time)
85
- d.emit({'a' => 4, 'b' => "d", 'first' => '菖蒲'.encode('EUC-JP').force_encoding('UTF-8')}, time)
86
- time
87
- end
88
-
89
- def test_write_with_invalid_recoreds_with_keys_containing_dot_and_dollar
90
- d = create_driver(default_config + %[
91
- replace_dot_in_key_with _dot_
92
- replace_dollar_in_key_with _dollar_
93
- ])
94
-
95
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
96
- d.emit({
97
- "foo.bar1" => {
98
- "$foo$bar" => "baz"
99
- },
100
- "foo.bar2" => [
101
- {
102
- "$foo$bar" => "baz"
103
- }
104
- ],
105
- }, time)
106
- d.run
107
-
108
- documents = get_documents
109
- assert_equal(1, documents.size)
110
- assert_equal("baz", documents[0]["foo_dot_bar1"]["_dollar_foo$bar"])
111
- assert_equal("baz", documents[0]["foo_dot_bar2"][0]["_dollar_foo$bar"])
112
- assert_equal(0, documents.select { |e| e.has_key?(Fluent::MongoOutput::BROKEN_DATA_KEY)}.size)
113
- end
114
-
115
- def test_write_with_invalid_recoreds
116
- d = create_driver
117
- t = emit_documents(d)
118
- t = emit_invalid_documents(d)
119
-
120
- d.run
121
- documents = get_documents
122
- assert_equal(4, documents.size)
123
- assert_equal([1, 2], documents.select { |e| e.has_key?('a') }.map { |e| e['a'] }.sort)
124
- assert_equal(2, documents.select { |e| e.has_key?(Fluent::MongoOutput::BROKEN_DATA_KEY)}.size)
125
- assert_equal([3, 4], @db.collection(collection_name).find({Fluent::MongoOutput::BROKEN_DATA_KEY => {'$exists' => true}}).map { |doc|
126
- Marshal.load(doc[Fluent::MongoOutput::BROKEN_DATA_KEY].to_s)['a']
127
- }.sort)
128
- end
129
-
130
- def test_write_with_invalid_recoreds_with_exclude_one_broken_fields
131
- d = create_driver(default_config + %[
132
- exclude_broken_fields a
133
- ])
134
- t = emit_documents(d)
135
- t = emit_invalid_documents(d)
136
-
137
- d.run
138
- documents = get_documents
139
- assert_equal(4, documents.size)
140
- assert_equal(2, documents.select { |e| e.has_key?(Fluent::MongoOutput::BROKEN_DATA_KEY) }.size)
141
- assert_equal([1, 2, 3, 4], documents.select { |e| e.has_key?('a') }.map { |e| e['a'] }.sort)
142
- assert_equal(0, documents.select { |e| e.has_key?('b') }.size)
143
- end
144
-
145
- def test_write_with_invalid_recoreds_with_exclude_two_broken_fields
146
- d = create_driver(default_config + %[
147
- exclude_broken_fields a,b
148
- ])
149
- t = emit_documents(d)
150
- t = emit_invalid_documents(d)
151
-
152
- d.run
153
- documents = get_documents
154
- assert_equal(4, documents.size)
155
- assert_equal(2, documents.select { |e| e.has_key?(Fluent::MongoOutput::BROKEN_DATA_KEY) }.size)
156
- assert_equal([1, 2, 3, 4], documents.select { |e| e.has_key?('a') }.map { |e| e['a'] }.sort)
157
- assert_equal(["c", "d"], documents.select { |e| e.has_key?('b') }.map { |e| e['b'] }.sort)
158
- end
159
-
160
- def test_write_with_invalid_recoreds_at_ignore
161
- d = create_driver(default_config + %[
162
- ignore_invalid_record true
163
- ])
164
- t = emit_documents(d)
165
- t = emit_invalid_documents(d)
166
-
167
- d.run
168
- documents = get_documents
169
- assert_equal(2, documents.size)
170
- assert_equal([1, 2], documents.select { |e| e.has_key?('a') }.map { |e| e['a'] }.sort)
171
- assert_equal(true, @db.collection(collection_name).find({Fluent::MongoOutput::BROKEN_DATA_KEY => {'$exists' => true}}).count.zero?)
172
- end
173
- end
174
-
175
- class MongoOutputTest < Test::Unit::TestCase
176
- include MongoOutputTestCases
177
-
178
- class << self
179
- def startup
180
- MongoTestHelper.setup_mongod
181
- end
182
-
183
- def shutdown
184
- MongoTestHelper.teardown_mongod
185
- end
186
- end
187
-
188
- def setup
189
- Fluent::Test.setup
190
- end
191
-
192
- def teardown
193
- @db.collection(collection_name).drop
194
- end
195
-
196
- def default_config
197
- %[
198
- type mongo
199
- database #{MONGO_DB_DB}
200
- collection #{collection_name}
201
- include_time_key true # TestDriver ignore config_set_default?
202
- ]
203
- end
204
-
205
- def create_driver(conf = default_config)
206
- conf = conf + %[
207
- port #{MongoTestHelper.mongod_port}
208
- ]
209
- @db = Mongo::MongoClient.new('localhost', MongoTestHelper.mongod_port).db(MONGO_DB_DB)
210
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::MongoOutput).configure(conf)
211
- end
212
-
213
- def test_configure
214
- d = create_driver(%[
215
- type mongo
216
- database fluent_test
217
- collection test_collection
218
-
219
- capped
220
- capped_size 100
221
- ])
222
-
223
- assert_equal('fluent_test', d.instance.database)
224
- assert_equal('test_collection', d.instance.collection)
225
- assert_equal('localhost', d.instance.host)
226
- assert_equal(MongoTestHelper.mongod_port, d.instance.port)
227
- assert_equal({:capped => true, :size => 100}, d.instance.collection_options)
228
- assert_equal({:ssl => false, :pool_size => 1, :j => false}, d.instance.connection_options)
229
- # buffer_chunk_limit moved from configure to start
230
- # I will move this test to correct space after BufferedOutputTestDriver supports start method invoking
231
- # assert_equal(Fluent::MongoOutput::LIMIT_BEFORE_v1_8, d.instance.instance_variable_get(:@buffer).buffer_chunk_limit)
232
- end
233
- end
234
-
235
- class MongoReplOutputTest < Test::Unit::TestCase
236
- include MongoOutputTestCases
237
-
238
- class << self
239
- def startup
240
- setup_rs
241
- end
242
-
243
- def shutdown
244
- teardown_rs
245
- end
246
- end
247
-
248
- def setup
249
- Fluent::Test.setup
250
- require 'fluent/plugin/out_mongo_replset'
251
- end
252
-
253
- def teardown
254
- @@rs.restart_killed_nodes
255
- if defined?(@db) && @db
256
- @db.collection(collection_name).drop
257
- @db.connection.close
258
- end
259
- end
260
-
261
- def default_config
262
- %[
263
- type mongo_replset
264
- database #{MONGO_DB_DB}
265
- collection #{collection_name}
266
- nodes #{build_seeds(3).join(',')}
267
- num_retries 30
268
- include_time_key true # TestDriver ignore config_set_default?
269
- ]
270
- end
271
-
272
- def create_driver(conf = default_config)
273
- @db = Mongo::MongoReplicaSetClient.new(build_seeds(3), :name => @@rs.name).db(MONGO_DB_DB)
274
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::MongoOutputReplset).configure(conf)
275
- end
276
-
277
- def test_configure
278
- d = create_driver(%[
279
- type mongo_replset
280
-
281
- database fluent_test
282
- collection test_collection
283
- nodes #{build_seeds(3).join(',')}
284
- num_retries 45
285
-
286
- capped
287
- capped_size 100
288
- ])
289
-
290
- assert_equal('fluent_test', d.instance.database)
291
- assert_equal('test_collection', d.instance.collection)
292
- assert_equal(build_seeds(3), d.instance.nodes)
293
- assert_equal(45, d.instance.num_retries)
294
- assert_equal({:capped => true, :size => 100}, d.instance.collection_options)
295
- assert_equal({:ssl => false, :pool_size => 1, :j => false}, d.instance.connection_options)
296
- end
297
- end
298
-