fluent-plugin-mysql-replicator 0.6.1 → 1.0.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 +5 -5
- data/.travis.yml +1 -0
- data/README.md +18 -3
- data/fluent-plugin-mysql-replicator.gemspec +2 -2
- data/lib/fluent/plugin/in_mysql_replicator.rb +13 -14
- data/lib/fluent/plugin/in_mysql_replicator_multi.rb +26 -12
- data/lib/fluent/plugin/out_mysql_replicator_elasticsearch.rb +18 -1
- data/lib/fluent/plugin/out_mysql_replicator_solr.rb +18 -1
- data/test/plugin/test_in_mysql_replicator.rb +3 -2
- data/test/plugin/test_in_mysql_replicator_multi.rb +3 -2
- data/test/plugin/test_out_mysql_replicator_elasticsearch.rb +51 -34
- data/test/plugin/test_out_mysql_replicator_solr.rb +3 -2
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5c523ddf1d5052d11c6c7a0f7e9172d319c881257d791a0006cd1a6601f5a948
|
4
|
+
data.tar.gz: ca9f218dfa56543f141d8911578250194281bfbad16d8f5ed6b4980120d99c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5266cd4f824e781d53eaa613c37f260c7814badcee87fb6c49a1321e9c9ac8bc8d9505b2ea800f3a8ccde237b2b0eeb808e187463996c2b1aecc93065128869
|
7
|
+
data.tar.gz: 70834ef8629d34bbd53aa1ff9d66ba706d6df5b48cd310d8a554c7d25628682633860123f63855e851482abda385e6288c4fcd01da848cbffc56bc0525553968
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -10,8 +10,20 @@ It's comming support replicate to another RDB/noSQL.
|
|
10
10
|
|
11
11
|
| fluent-plugin-mysql-replicator | fluentd | ruby |
|
12
12
|
|--------------------|------------|--------|
|
13
|
-
| 0.6.1
|
14
|
-
| 0.6.1
|
13
|
+
| >= 0.6.1 | >= v0.14.x | >= 2.1 |
|
14
|
+
| <= 0.6.1 | >= v0.12.x | >= 1.9 |
|
15
|
+
|
16
|
+
## Dependency
|
17
|
+
|
18
|
+
before use, install dependent library as:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
# for RHEL/CentOS
|
22
|
+
$ sudo yum group install "Development Tools"
|
23
|
+
|
24
|
+
# for Ubuntu/Debian
|
25
|
+
$ sudo apt-get install build-essential
|
26
|
+
```
|
15
27
|
|
16
28
|
## Installation
|
17
29
|
|
@@ -19,10 +31,13 @@ install with gem or fluent-gem command as:
|
|
19
31
|
|
20
32
|
`````
|
21
33
|
# for system installed fluentd
|
22
|
-
$ gem install fluent-plugin-mysql-replicator -v 0.
|
34
|
+
$ gem install fluent-plugin-mysql-replicator -v 1.0.2
|
23
35
|
|
24
36
|
# for td-agent2
|
25
37
|
$ sudo td-agent-gem install fluent-plugin-mysql-replicator -v 0.6.1
|
38
|
+
|
39
|
+
# for td-agent3
|
40
|
+
$ sudo td-agent-gem install fluent-plugin-mysql-replicator -v 1.0.2
|
26
41
|
`````
|
27
42
|
|
28
43
|
## Included plugins
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "fluent-plugin-mysql-replicator"
|
4
|
-
s.version = "0.
|
4
|
+
s.version = "1.0.2"
|
5
5
|
s.authors = ["Kentaro Yoshida"]
|
6
6
|
s.email = ["y.ken.studio@gmail.com"]
|
7
7
|
s.homepage = "https://github.com/y-ken/fluent-plugin-mysql-replicator"
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency "webmock", "~> 1.24.0"
|
20
20
|
s.add_development_dependency "test-unit", ">= 3.1.0"
|
21
21
|
|
22
|
-
s.add_runtime_dependency "fluentd", [">= 0.
|
22
|
+
s.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
|
23
23
|
s.add_runtime_dependency "mysql2"
|
24
24
|
s.add_runtime_dependency "rsolr"
|
25
25
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'mysql2'
|
2
|
+
require 'digest/sha1'
|
3
|
+
require 'fluent/plugin/input'
|
2
4
|
|
3
|
-
module Fluent
|
4
|
-
class MysqlReplicatorInput < Fluent::Input
|
5
|
-
Plugin.register_input('mysql_replicator', self)
|
5
|
+
module Fluent::Plugin
|
6
|
+
class MysqlReplicatorInput < Fluent::Plugin::Input
|
7
|
+
Fluent::Plugin.register_input('mysql_replicator', self)
|
6
8
|
|
7
|
-
|
8
|
-
require 'mysql2'
|
9
|
-
require 'digest/sha1'
|
10
|
-
super
|
11
|
-
end
|
9
|
+
helpers :thread
|
12
10
|
|
13
11
|
config_param :host, :string, :default => 'localhost'
|
14
12
|
config_param :port, :integer, :default => 3306
|
@@ -25,7 +23,7 @@ module Fluent
|
|
25
23
|
|
26
24
|
def configure(conf)
|
27
25
|
super
|
28
|
-
@interval = Config.time_value(@interval)
|
26
|
+
@interval = Fluent::Config.time_value(@interval)
|
29
27
|
|
30
28
|
if @tag.nil?
|
31
29
|
raise Fluent::ConfigError, "mysql_replicator: missing 'tag' parameter. Please add following line into config like 'tag replicator.mydatabase.mytable.${event}.${primary_key}'"
|
@@ -35,11 +33,12 @@ module Fluent
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def start
|
38
|
-
|
36
|
+
super
|
37
|
+
thread_create(:in_mysql_replicator_runner, &method(:run))
|
39
38
|
end
|
40
39
|
|
41
40
|
def shutdown
|
42
|
-
|
41
|
+
super
|
43
42
|
end
|
44
43
|
|
45
44
|
def run
|
@@ -72,7 +71,7 @@ module Fluent
|
|
72
71
|
current_ids << row[@primary_key]
|
73
72
|
current_hash = Digest::SHA1.hexdigest(row.flatten.join)
|
74
73
|
row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
|
75
|
-
row.select {|k, v| v.to_s.strip.match(/^SELECT/i) }.each do |k, v|
|
74
|
+
row.select {|k, v| v.to_s.strip.match(/^SELECT(\s+)/i) }.each do |k, v|
|
76
75
|
row[k] = [] unless row[k].is_a?(Array)
|
77
76
|
nest_rows, prepared_con = query(v.gsub(/\$\{([^\}]+)\}/, row[$1].to_s), prepared_con)
|
78
77
|
nest_rows.each do |nest_row|
|
@@ -107,7 +106,7 @@ module Fluent
|
|
107
106
|
end
|
108
107
|
if deleted_ids.count > 0
|
109
108
|
hash_delete_by_list(table_hash, deleted_ids)
|
110
|
-
deleted_ids.each do |id|
|
109
|
+
deleted_ids.each do |id|
|
111
110
|
tag = format_tag(@tag, {:event => :delete})
|
112
111
|
emit_record(tag, {@primary_key => id})
|
113
112
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
require 'fluent/input'
|
1
|
+
require 'fluent/plugin/input'
|
2
2
|
|
3
|
-
module Fluent
|
4
|
-
class MysqlReplicatorMultiInput < Fluent::Input
|
5
|
-
Plugin.register_input('mysql_replicator_multi', self)
|
3
|
+
module Fluent::Plugin
|
4
|
+
class MysqlReplicatorMultiInput < Fluent::Plugin::Input
|
5
|
+
Fluent::Plugin.register_input('mysql_replicator_multi', self)
|
6
|
+
|
7
|
+
helpers :thread
|
6
8
|
|
7
9
|
def initialize
|
8
10
|
require 'mysql2'
|
@@ -28,18 +30,20 @@ module Fluent
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def start
|
33
|
+
super
|
31
34
|
begin
|
32
35
|
@threads = []
|
33
36
|
@mutex = Mutex.new
|
34
37
|
@manager_db = get_manager_connection
|
35
38
|
@manager_db.query("SET SESSION wait_timeout=1800;")
|
36
|
-
@
|
39
|
+
@running = true
|
40
|
+
@threads << thread_create(:in_mysql_replicator_flusher) {
|
37
41
|
@hash_table_bulk_insert = []
|
38
42
|
@hash_table_bulk_insert_last_time = Time.now
|
39
43
|
hash_table_flusher
|
40
44
|
}
|
41
|
-
get_settings.
|
42
|
-
@threads <<
|
45
|
+
get_settings.each_with_index do |config, idx|
|
46
|
+
@threads << thread_create(:"in_mysql_replicator_pollers_#{idx}") {
|
43
47
|
poll(config)
|
44
48
|
}
|
45
49
|
end
|
@@ -50,10 +54,14 @@ module Fluent
|
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
57
|
+
def stop
|
58
|
+
@running = false
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
53
62
|
def shutdown
|
54
|
-
@threads.each
|
55
|
-
|
56
|
-
end
|
63
|
+
@threads.each(&:join)
|
64
|
+
super
|
57
65
|
end
|
58
66
|
|
59
67
|
def get_settings
|
@@ -74,7 +82,7 @@ module Fluent
|
|
74
82
|
}
|
75
83
|
primary_key = config['primary_key']
|
76
84
|
previous_id = current_id = nil
|
77
|
-
|
85
|
+
while @running
|
78
86
|
rows_count = 0
|
79
87
|
start_time = Time.now
|
80
88
|
unless config['prepared_query'].nil?
|
@@ -106,6 +114,9 @@ module Fluent
|
|
106
114
|
rows_count += 1
|
107
115
|
end
|
108
116
|
db.close
|
117
|
+
unless config['prepared_query'].nil?
|
118
|
+
nest_db.close
|
119
|
+
end
|
109
120
|
elapsed_time = sprintf("%0.02f", Time.now - start_time)
|
110
121
|
@mutex.synchronize {
|
111
122
|
log.info "mysql_replicator_multi: execution finished. :setting_name=>#{config['name']} :rows_count=>#{rows_count} :elapsed_time=>#{elapsed_time} sec"
|
@@ -212,7 +223,7 @@ module Fluent
|
|
212
223
|
|
213
224
|
def hash_table_flusher
|
214
225
|
begin
|
215
|
-
|
226
|
+
while @running
|
216
227
|
if @hash_table_bulk_insert.empty? || @bulk_insert_timeout > (Time.now - @hash_table_bulk_insert_last_time)
|
217
228
|
sleep @bulk_insert_timeout
|
218
229
|
next
|
@@ -221,6 +232,9 @@ module Fluent
|
|
221
232
|
flush_hash_table
|
222
233
|
}
|
223
234
|
end
|
235
|
+
@mutex.synchronize {
|
236
|
+
flush_hash_table
|
237
|
+
}
|
224
238
|
rescue StandardError => e
|
225
239
|
@mutex.synchronize {
|
226
240
|
log.error "mysql_replicator_multi: failed to flush buffered query. :config=>#{masked_config}"
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'date'
|
3
|
+
require 'fluent/plugin/output'
|
3
4
|
|
4
|
-
class Fluent::MysqlReplicatorElasticsearchOutput < Fluent::
|
5
|
+
class Fluent::Plugin::MysqlReplicatorElasticsearchOutput < Fluent::Plugin::Output
|
5
6
|
Fluent::Plugin.register_output('mysql_replicator_elasticsearch', self)
|
6
7
|
|
8
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
9
|
+
|
10
|
+
helpers :compat_parameters
|
11
|
+
|
7
12
|
config_param :host, :string, :default => 'localhost'
|
8
13
|
config_param :port, :integer, :default => 9200
|
9
14
|
config_param :tag_format, :string, :default => nil
|
@@ -11,6 +16,10 @@ class Fluent::MysqlReplicatorElasticsearchOutput < Fluent::BufferedOutput
|
|
11
16
|
config_param :username, :string, :default => nil
|
12
17
|
config_param :password, :string, :default => nil, :secret => true
|
13
18
|
|
19
|
+
config_section :buffer do
|
20
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
21
|
+
end
|
22
|
+
|
14
23
|
DEFAULT_TAG_FORMAT = /(?<index_name>[^\.]+)\.(?<type_name>[^\.]+)\.(?<event>[^\.]+)\.(?<primary_key>[^\.]+)$/
|
15
24
|
|
16
25
|
def initialize
|
@@ -39,6 +48,14 @@ class Fluent::MysqlReplicatorElasticsearchOutput < Fluent::BufferedOutput
|
|
39
48
|
super
|
40
49
|
end
|
41
50
|
|
51
|
+
def multi_workers_ready?
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
def formatted_to_msgpack_binary?
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
42
59
|
def write(chunk)
|
43
60
|
bulk_message = []
|
44
61
|
|
@@ -1,13 +1,22 @@
|
|
1
1
|
require 'rsolr'
|
2
2
|
require 'uri'
|
3
|
+
require 'fluent/plugin/output'
|
3
4
|
|
4
|
-
class Fluent::MysqlReplicatorSolrOutput < Fluent::
|
5
|
+
class Fluent::Plugin::MysqlReplicatorSolrOutput < Fluent::Plugin::Output
|
5
6
|
Fluent::Plugin.register_output('mysql_replicator_solr', self)
|
6
7
|
|
8
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
9
|
+
|
10
|
+
helpers :compat_parameters
|
11
|
+
|
7
12
|
config_param :host, :string, :default => 'localhost'
|
8
13
|
config_param :port, :integer, :default => 8983
|
9
14
|
config_param :tag_format, :string, :default => nil
|
10
15
|
|
16
|
+
config_section :buffer do
|
17
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
18
|
+
end
|
19
|
+
|
11
20
|
DEFAULT_TAG_FORMAT = /(?<core_name>[^\.]+)\.(?<event>[^\.]+)\.(?<primary_key>[^\.]+)$/
|
12
21
|
|
13
22
|
def initialize
|
@@ -36,6 +45,14 @@ class Fluent::MysqlReplicatorSolrOutput < Fluent::BufferedOutput
|
|
36
45
|
super
|
37
46
|
end
|
38
47
|
|
48
|
+
def multi_workers_ready?
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def formatted_to_msgpack_binary?
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
39
56
|
def write(chunk)
|
40
57
|
solr_connection = {}
|
41
58
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/driver/input'
|
2
3
|
|
3
4
|
class MysqlReplicatorInputTest < Test::Unit::TestCase
|
4
5
|
def setup
|
@@ -14,8 +15,8 @@ class MysqlReplicatorInputTest < Test::Unit::TestCase
|
|
14
15
|
record_hostname yes
|
15
16
|
]
|
16
17
|
|
17
|
-
def create_driver(conf=CONFIG
|
18
|
-
Fluent::Test::
|
18
|
+
def create_driver(conf=CONFIG)
|
19
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::MysqlReplicatorInput).configure(conf)
|
19
20
|
end
|
20
21
|
|
21
22
|
def test_configure
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/driver/input'
|
2
3
|
|
3
4
|
class MysqlReplicatorMultiInputTest < Test::Unit::TestCase
|
4
5
|
def setup
|
@@ -13,8 +14,8 @@ class MysqlReplicatorMultiInputTest < Test::Unit::TestCase
|
|
13
14
|
tag replicator.${name}.${event}.${primary_key}
|
14
15
|
]
|
15
16
|
|
16
|
-
def create_driver(conf=CONFIG
|
17
|
-
Fluent::Test::
|
17
|
+
def create_driver(conf=CONFIG)
|
18
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::MysqlReplicatorMultiInput).configure(conf)
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_configure
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/driver/output'
|
2
3
|
require 'webmock/test_unit'
|
3
4
|
|
4
5
|
WebMock.disable_net_connect!
|
@@ -9,10 +10,11 @@ class MysqlReplicatorElasticsearchOutput < Test::Unit::TestCase
|
|
9
10
|
def setup
|
10
11
|
Fluent::Test.setup
|
11
12
|
@driver = nil
|
13
|
+
@tag = 'myindex.mytype.insert.id'
|
12
14
|
end
|
13
15
|
|
14
|
-
def driver(
|
15
|
-
@driver ||= Fluent::Test::
|
16
|
+
def driver(conf='')
|
17
|
+
@driver ||= Fluent::Test::Driver::Output.new(Fluent::Plugin::MysqlReplicatorElasticsearchOutput).configure(conf)
|
16
18
|
end
|
17
19
|
|
18
20
|
def sample_record
|
@@ -32,56 +34,63 @@ class MysqlReplicatorElasticsearchOutput < Test::Unit::TestCase
|
|
32
34
|
|
33
35
|
def test_wrties_with_proper_content_type
|
34
36
|
stub_elastic
|
35
|
-
driver.
|
36
|
-
|
37
|
+
driver.run(default_tag: @tag) do
|
38
|
+
driver.feed(sample_record)
|
39
|
+
end
|
37
40
|
assert_equal("application/json; charset=utf-8", @content_type)
|
38
41
|
end
|
39
42
|
|
40
43
|
def test_writes_to_speficied_index
|
41
44
|
driver.configure("index_name myindex\n")
|
42
45
|
stub_elastic
|
43
|
-
driver.
|
44
|
-
|
46
|
+
driver.run(default_tag: @tag) do
|
47
|
+
driver.feed(sample_record)
|
48
|
+
end
|
45
49
|
assert_equal('myindex', index_cmds.first['index']['_index'])
|
46
50
|
end
|
47
51
|
|
48
52
|
def test_writes_to_speficied_type
|
49
53
|
driver.configure("type_name mytype\n")
|
50
54
|
stub_elastic
|
51
|
-
driver.
|
52
|
-
|
55
|
+
driver.run(default_tag: @tag) do
|
56
|
+
driver.feed(sample_record)
|
57
|
+
end
|
53
58
|
assert_equal('mytype', index_cmds.first['index']['_type'])
|
54
59
|
end
|
55
60
|
|
56
61
|
def test_writes_to_speficied_host
|
57
62
|
driver.configure("host 192.168.33.50\n")
|
58
63
|
elastic_request = stub_elastic("http://192.168.33.50:9200/_bulk")
|
59
|
-
driver.
|
60
|
-
|
64
|
+
driver.run(default_tag: @tag) do
|
65
|
+
driver.feed(sample_record)
|
66
|
+
end
|
61
67
|
assert_requested(elastic_request)
|
62
68
|
end
|
63
69
|
|
64
70
|
def test_writes_to_speficied_port
|
65
71
|
driver.configure("port 9201\n")
|
66
72
|
elastic_request = stub_elastic("http://localhost:9201/_bulk")
|
67
|
-
driver.
|
68
|
-
|
73
|
+
driver.run(default_tag: @tag) do
|
74
|
+
driver.feed(sample_record)
|
75
|
+
end
|
69
76
|
assert_requested(elastic_request)
|
70
77
|
end
|
71
78
|
|
72
79
|
def test_makes_bulk_request
|
73
80
|
stub_elastic
|
74
|
-
driver.
|
75
|
-
|
76
|
-
|
81
|
+
driver.run(default_tag: @tag) do
|
82
|
+
driver.feed(sample_record)
|
83
|
+
driver.feed(sample_record.merge('age' => 27))
|
84
|
+
end
|
77
85
|
assert_equal(4, index_cmds.count)
|
78
86
|
end
|
79
87
|
|
80
88
|
def test_all_records_are_preserved_in_bulk
|
81
89
|
stub_elastic
|
82
|
-
driver.
|
83
|
-
|
84
|
-
|
90
|
+
driver.run(default_tag: @tag) do
|
91
|
+
driver.feed(sample_record)
|
92
|
+
driver.feed(sample_record.merge('age' => 27))
|
93
|
+
end
|
85
94
|
assert_equal(26, index_cmds[1]['age'])
|
86
95
|
assert_equal(27, index_cmds[3]['age'])
|
87
96
|
end
|
@@ -89,47 +98,53 @@ class MysqlReplicatorElasticsearchOutput < Test::Unit::TestCase
|
|
89
98
|
|
90
99
|
def test_doesnt_add_logstash_timestamp_by_default
|
91
100
|
stub_elastic
|
92
|
-
driver.
|
93
|
-
|
101
|
+
driver.run(default_tag: @tag) do
|
102
|
+
driver.feed(sample_record)
|
103
|
+
end
|
94
104
|
assert_nil(index_cmds[1]['@timestamp'])
|
95
105
|
end
|
96
106
|
|
97
107
|
|
98
108
|
def test_doesnt_add_tag_key_by_default
|
99
109
|
stub_elastic
|
100
|
-
driver.
|
101
|
-
|
110
|
+
driver.run(default_tag: @tag) do
|
111
|
+
driver.feed(sample_record)
|
112
|
+
end
|
102
113
|
assert_nil(index_cmds[1]['tag'])
|
103
114
|
end
|
104
115
|
|
105
116
|
def test_doesnt_add_id_key_if_missing_when_configured
|
106
117
|
driver.configure("id_key another_request_id\n")
|
107
118
|
stub_elastic
|
108
|
-
driver.
|
109
|
-
|
119
|
+
driver.run(default_tag: @tag) do
|
120
|
+
driver.feed(sample_record)
|
121
|
+
end
|
110
122
|
assert(!index_cmds[0]['index'].has_key?('_id'))
|
111
123
|
end
|
112
124
|
|
113
125
|
def test_adds_id_key_when_not_configured
|
114
126
|
stub_elastic
|
115
|
-
driver.
|
116
|
-
|
127
|
+
driver.run(default_tag: @tag) do
|
128
|
+
driver.feed(sample_record)
|
129
|
+
end
|
117
130
|
assert(!index_cmds[0]['index'].has_key?('_id'))
|
118
131
|
end
|
119
132
|
|
120
133
|
def test_request_error
|
121
134
|
stub_elastic_unavailable
|
122
|
-
driver.emit(sample_record)
|
123
135
|
assert_raise(Net::HTTPFatalError) {
|
124
|
-
driver.run
|
136
|
+
driver.run(default_tag: @tag) do
|
137
|
+
driver.feed(sample_record)
|
138
|
+
end
|
125
139
|
}
|
126
140
|
end
|
127
141
|
|
128
142
|
def test_writes_to_https_host
|
129
143
|
driver.configure("ssl true\n")
|
130
144
|
elastic_request = stub_elastic("https://localhost:9200/_bulk")
|
131
|
-
driver.
|
132
|
-
|
145
|
+
driver.run(default_tag: @tag) do
|
146
|
+
driver.feed(sample_record)
|
147
|
+
end
|
133
148
|
assert_requested(elastic_request)
|
134
149
|
end
|
135
150
|
|
@@ -139,8 +154,9 @@ class MysqlReplicatorElasticsearchOutput < Test::Unit::TestCase
|
|
139
154
|
password bar\n
|
140
155
|
])
|
141
156
|
elastic_request = stub_elastic("http://foo:bar@localhost:9200/_bulk")
|
142
|
-
driver.
|
143
|
-
|
157
|
+
driver.run(default_tag: @tag) do
|
158
|
+
driver.feed(sample_record)
|
159
|
+
end
|
144
160
|
assert_requested(elastic_request)
|
145
161
|
end
|
146
162
|
|
@@ -150,9 +166,10 @@ class MysqlReplicatorElasticsearchOutput < Test::Unit::TestCase
|
|
150
166
|
password bar\n
|
151
167
|
])
|
152
168
|
elastic_request = stub_elastic("http://foo:bar@localhost:9200/_bulk")
|
153
|
-
driver.emit(sample_record)
|
154
169
|
assert_raise(WebMock::NetConnectNotAllowedError) {
|
155
|
-
driver.run
|
170
|
+
driver.run(default_tag: @tag) do
|
171
|
+
driver.feed(sample_record)
|
172
|
+
end
|
156
173
|
}
|
157
174
|
end
|
158
175
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'fluent/test/driver/output'
|
2
3
|
|
3
4
|
class MysqlReplicatorSolrOutput < Test::Unit::TestCase
|
4
5
|
|
@@ -12,8 +13,8 @@ class MysqlReplicatorSolrOutput < Test::Unit::TestCase
|
|
12
13
|
tag_format (?<core_name>[^\.]+)\.(?<event>[^\.]+)\.(?<primary_key>[^\.]+)$
|
13
14
|
]
|
14
15
|
|
15
|
-
def create_driver(conf=CONFIG
|
16
|
-
Fluent::Test::
|
16
|
+
def create_driver(conf=CONFIG)
|
17
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::MysqlReplicatorSolrOutput).configure(conf)
|
17
18
|
end
|
18
19
|
|
19
20
|
def test_configure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mysql-replicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.14.15
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '2'
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.
|
71
|
+
version: 0.14.15
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2'
|
@@ -149,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
|
153
|
-
rubygems_version: 2.4.5
|
152
|
+
rubygems_version: 3.1.6
|
154
153
|
signing_key:
|
155
154
|
specification_version: 4
|
156
155
|
summary: Fluentd input plugin to track insert/update/delete event from MySQL database
|