fluent-plugin-sql 2.3.0 → 2.3.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 +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/linux-ruby-head.yml +45 -0
- data/.github/workflows/linux.yml +10 -33
- data/.gitignore +4 -0
- data/ChangeLog +10 -0
- data/VERSION +1 -1
- data/fluent-plugin-sql.gemspec +2 -1
- data/lib/fluent/plugin/in_sql.rb +1 -1
- data/lib/fluent/plugin/out_sql.rb +2 -2
- data/test/helper.rb +1 -1
- data/test/plugin/test_in_sql_with_state_file.rb +96 -0
- metadata +36 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d90c196fbc84a7921ba99ea09cdc7aef2c564b4c19799cc1bcce9973e1f391e
|
|
4
|
+
data.tar.gz: 358dbde32a842e26b2ff9e34a11acff25790624dec8ae1e4689aaa8488d179de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cbe495ae7aab0133427155b1a136f8a499b9b0924305bf24807c0f2950f2a84b7a3d0657093375e682be37d2d81f96b503e77635c7ddb24f51a5abb40914a51
|
|
7
|
+
data.tar.gz: 9b856ce7892a9d9f2fd35d36137eca67508d129194043516e976f5497518da251604c35cba15d483386d0879bb073e2fe9fd1d96a0e027dcbe66fb5fd2a78b7d
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Test with Ruby head
|
|
2
|
+
on:
|
|
3
|
+
schedule:
|
|
4
|
+
- cron: '11 23 * * 0'
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
ruby: [ 'head' ]
|
|
14
|
+
postgres: [ '16', '15', '14', '13', '12' ]
|
|
15
|
+
os:
|
|
16
|
+
- ubuntu-latest
|
|
17
|
+
services:
|
|
18
|
+
postgres:
|
|
19
|
+
image: postgres:${{ matrix.postgres }}
|
|
20
|
+
ports:
|
|
21
|
+
- 5432:5432
|
|
22
|
+
env:
|
|
23
|
+
POSTGRES_USER: postgres
|
|
24
|
+
POSTGRES_PASSWORD: password
|
|
25
|
+
POSTGRES_DB: test
|
|
26
|
+
options: >-
|
|
27
|
+
--health-cmd pg_isready
|
|
28
|
+
--health-interval 10s
|
|
29
|
+
--health-timeout 5s
|
|
30
|
+
--health-retries 5
|
|
31
|
+
name: Ruby ${{ matrix.ruby }} with PostgreSQL ${{ matrix.postgres }} unit testing on ${{ matrix.os }}
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v6
|
|
34
|
+
- uses: ruby/setup-ruby@v1
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
|
37
|
+
bundler-cache: true
|
|
38
|
+
- name: prepare database
|
|
39
|
+
env:
|
|
40
|
+
PGPASSWORD: password
|
|
41
|
+
run: |
|
|
42
|
+
psql -h localhost -p 5432 -U postgres -c "CREATE ROLE fluentd WITH LOGIN ENCRYPTED PASSWORD 'fluentd';"
|
|
43
|
+
psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE fluentd_test OWNER fluentd;"
|
|
44
|
+
- name: unit testing
|
|
45
|
+
run: bundle exec rake test
|
data/.github/workflows/linux.yml
CHANGED
|
@@ -1,41 +1,20 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Test
|
|
2
2
|
on:
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
push:
|
|
4
|
+
branches: [master]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [master]
|
|
5
7
|
|
|
6
8
|
jobs:
|
|
7
9
|
build:
|
|
8
10
|
runs-on: ${{ matrix.os }}
|
|
9
|
-
continue-on-error: ${{ matrix.experimental }}
|
|
10
11
|
strategy:
|
|
11
12
|
fail-fast: false
|
|
12
13
|
matrix:
|
|
13
|
-
ruby: [ '
|
|
14
|
-
postgres: [ '
|
|
14
|
+
ruby: [ '4.0', '3.4', '3.3', '3.2', '3.1', '3.0', '2.7' ]
|
|
15
|
+
postgres: [ '16', '15', '14', '13', '12' ]
|
|
15
16
|
os:
|
|
16
17
|
- ubuntu-latest
|
|
17
|
-
experimental: [false]
|
|
18
|
-
include:
|
|
19
|
-
- ruby: head
|
|
20
|
-
postgres: '9'
|
|
21
|
-
os: ubuntu-latest
|
|
22
|
-
experimental: true
|
|
23
|
-
- ruby: head
|
|
24
|
-
postgres: '10'
|
|
25
|
-
os: ubuntu-latest
|
|
26
|
-
experimental: true
|
|
27
|
-
- ruby: head
|
|
28
|
-
postgres: '11'
|
|
29
|
-
os: ubuntu-latest
|
|
30
|
-
experimental: true
|
|
31
|
-
- ruby: head
|
|
32
|
-
postgres: '12'
|
|
33
|
-
os: ubuntu-latest
|
|
34
|
-
experimental: true
|
|
35
|
-
- ruby: head
|
|
36
|
-
postgres: '13'
|
|
37
|
-
os: ubuntu-latest
|
|
38
|
-
experimental: true
|
|
39
18
|
services:
|
|
40
19
|
postgres:
|
|
41
20
|
image: postgres:${{ matrix.postgres }}
|
|
@@ -52,10 +31,11 @@ jobs:
|
|
|
52
31
|
--health-retries 5
|
|
53
32
|
name: Ruby ${{ matrix.ruby }} with PostgreSQL ${{ matrix.postgres }} unit testing on ${{ matrix.os }}
|
|
54
33
|
steps:
|
|
55
|
-
- uses: actions/checkout@
|
|
34
|
+
- uses: actions/checkout@v6
|
|
56
35
|
- uses: ruby/setup-ruby@v1
|
|
57
36
|
with:
|
|
58
37
|
ruby-version: ${{ matrix.ruby }}
|
|
38
|
+
bundler-cache: true
|
|
59
39
|
- name: prepare database
|
|
60
40
|
env:
|
|
61
41
|
PGPASSWORD: password
|
|
@@ -63,7 +43,4 @@ jobs:
|
|
|
63
43
|
psql -h localhost -p 5432 -U postgres -c "CREATE ROLE fluentd WITH LOGIN ENCRYPTED PASSWORD 'fluentd';"
|
|
64
44
|
psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE fluentd_test OWNER fluentd;"
|
|
65
45
|
- name: unit testing
|
|
66
|
-
run:
|
|
67
|
-
gem install bundler rake
|
|
68
|
-
bundle install --jobs 4 --retry 3
|
|
69
|
-
bundle exec rake test
|
|
46
|
+
run: bundle exec rake test
|
data/.gitignore
ADDED
data/ChangeLog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
Release 2.3.2 - 2026/01/13
|
|
2
|
+
|
|
3
|
+
* out_sql: Use isolated connection configurations in the output plugin (#152)
|
|
4
|
+
* gem: Add ostruct as dependency for Ruby 4.0 (#159)
|
|
5
|
+
* gem: Relax required activesupport version to accept latest one (#161, #148)
|
|
6
|
+
|
|
7
|
+
Release 2.3.1 - 2024/02/29
|
|
8
|
+
|
|
9
|
+
* in_sql: Fix incompatibility against Ruby 3.2
|
|
10
|
+
|
|
1
11
|
Release 2.3.0 - 2021/10/08
|
|
2
12
|
|
|
3
13
|
* in_sql: Make table time_format configurable
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.3.
|
|
1
|
+
2.3.2
|
data/fluent-plugin-sql.gemspec
CHANGED
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
|
|
|
17
17
|
gem.license = "Apache-2.0"
|
|
18
18
|
|
|
19
19
|
gem.add_dependency "fluentd", [">= 1.7.0", "< 2"]
|
|
20
|
-
gem.add_dependency
|
|
20
|
+
gem.add_dependency "ostruct", '~> 0.6'
|
|
21
|
+
gem.add_dependency 'activerecord', [">= 6.1", "< 8.2"]
|
|
21
22
|
gem.add_dependency 'activerecord-import', "~> 1.0"
|
|
22
23
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
|
23
24
|
gem.add_development_dependency "test-unit", "> 3.1.0"
|
data/lib/fluent/plugin/in_sql.rb
CHANGED
|
@@ -206,7 +206,7 @@ module Fluent::Plugin
|
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
SQLOutput.const_set("BaseModel_#{rand(1 << 31)}", @base_model)
|
|
209
|
-
|
|
209
|
+
@base_model.establish_connection(config)
|
|
210
210
|
|
|
211
211
|
# ignore tables if TableElement#init failed
|
|
212
212
|
@tables.reject! do |te|
|
|
@@ -224,7 +224,7 @@ module Fluent::Plugin
|
|
|
224
224
|
end
|
|
225
225
|
|
|
226
226
|
def write(chunk)
|
|
227
|
-
|
|
227
|
+
@base_model.connection_pool.with_connection do
|
|
228
228
|
|
|
229
229
|
@tables.each { |table|
|
|
230
230
|
tag = format_tag(chunk.metadata.tag)
|
data/test/helper.rb
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require "helper"
|
|
2
|
+
require "fluent/test/driver/input"
|
|
3
|
+
|
|
4
|
+
class SqlInputStateFileTest < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
Fluent::Test.setup
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
CONFIG = %[
|
|
13
|
+
adapter postgresql
|
|
14
|
+
host localhost
|
|
15
|
+
port 5432
|
|
16
|
+
database fluentd_test
|
|
17
|
+
|
|
18
|
+
username fluentd
|
|
19
|
+
password fluentd
|
|
20
|
+
|
|
21
|
+
state_file /tmp/sql_state
|
|
22
|
+
|
|
23
|
+
schema_search_path public
|
|
24
|
+
|
|
25
|
+
tag_prefix db
|
|
26
|
+
|
|
27
|
+
<table>
|
|
28
|
+
table messages
|
|
29
|
+
tag logs
|
|
30
|
+
update_column updated_at
|
|
31
|
+
time_column updated_at
|
|
32
|
+
</table>
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
def create_driver(conf = CONFIG)
|
|
36
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::SQLInput).configure(conf)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_configure
|
|
40
|
+
d = create_driver
|
|
41
|
+
expected = {
|
|
42
|
+
host: "localhost",
|
|
43
|
+
port: 5432,
|
|
44
|
+
adapter: "postgresql",
|
|
45
|
+
database: "fluentd_test",
|
|
46
|
+
username: "fluentd",
|
|
47
|
+
password: "fluentd",
|
|
48
|
+
schema_search_path: "public",
|
|
49
|
+
tag_prefix: "db"
|
|
50
|
+
}
|
|
51
|
+
actual = {
|
|
52
|
+
host: d.instance.host,
|
|
53
|
+
port: d.instance.port,
|
|
54
|
+
adapter: d.instance.adapter,
|
|
55
|
+
database: d.instance.database,
|
|
56
|
+
username: d.instance.username,
|
|
57
|
+
password: d.instance.password,
|
|
58
|
+
schema_search_path: d.instance.schema_search_path,
|
|
59
|
+
tag_prefix: d.instance.tag_prefix
|
|
60
|
+
}
|
|
61
|
+
assert_equal(expected, actual)
|
|
62
|
+
tables = d.instance.instance_variable_get(:@tables)
|
|
63
|
+
assert_equal(1, tables.size)
|
|
64
|
+
messages = tables.first
|
|
65
|
+
assert_equal("messages", messages.table)
|
|
66
|
+
assert_equal("logs", messages.tag)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_message
|
|
70
|
+
d = create_driver(CONFIG + "select_interval 1")
|
|
71
|
+
Message.create!(message: "message 1")
|
|
72
|
+
Message.create!(message: "message 2")
|
|
73
|
+
Message.create!(message: "message 3")
|
|
74
|
+
|
|
75
|
+
d.end_if do
|
|
76
|
+
d.record_count >= 3
|
|
77
|
+
end
|
|
78
|
+
d.run
|
|
79
|
+
|
|
80
|
+
assert_equal("db.logs", d.events[0][0])
|
|
81
|
+
expected = [
|
|
82
|
+
[d.events[0][1], "message 1"],
|
|
83
|
+
[d.events[1][1], "message 2"],
|
|
84
|
+
[d.events[2][1], "message 3"],
|
|
85
|
+
]
|
|
86
|
+
actual = [
|
|
87
|
+
[Fluent::EventTime.parse(d.events[0][2]["updated_at"]), d.events[0][2]["message"]],
|
|
88
|
+
[Fluent::EventTime.parse(d.events[1][2]["updated_at"]), d.events[1][2]["message"]],
|
|
89
|
+
[Fluent::EventTime.parse(d.events[2][2]["updated_at"]), d.events[2][2]["message"]],
|
|
90
|
+
]
|
|
91
|
+
assert_equal(expected, actual)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class Message < ActiveRecord::Base
|
|
95
|
+
end
|
|
96
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-sql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: fluentd
|
|
@@ -31,19 +30,39 @@ dependencies:
|
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
31
|
version: '2'
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
33
|
+
name: ostruct
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
36
35
|
requirements:
|
|
37
36
|
- - "~>"
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '6
|
|
38
|
+
version: '0.6'
|
|
40
39
|
type: :runtime
|
|
41
40
|
prerelease: false
|
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
42
|
requirements:
|
|
44
43
|
- - "~>"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0.6'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: activerecord
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '6.1'
|
|
53
|
+
- - "<"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '8.2'
|
|
56
|
+
type: :runtime
|
|
57
|
+
prerelease: false
|
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
45
61
|
- !ruby/object:Gem::Version
|
|
46
62
|
version: '6.1'
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '8.2'
|
|
47
66
|
- !ruby/object:Gem::Dependency
|
|
48
67
|
name: activerecord-import
|
|
49
68
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -134,7 +153,10 @@ executables: []
|
|
|
134
153
|
extensions: []
|
|
135
154
|
extra_rdoc_files: []
|
|
136
155
|
files:
|
|
156
|
+
- ".github/dependabot.yml"
|
|
157
|
+
- ".github/workflows/linux-ruby-head.yml"
|
|
137
158
|
- ".github/workflows/linux.yml"
|
|
159
|
+
- ".gitignore"
|
|
138
160
|
- ChangeLog
|
|
139
161
|
- Gemfile
|
|
140
162
|
- Gemfile.v0.12
|
|
@@ -148,12 +170,12 @@ files:
|
|
|
148
170
|
- test/helper.rb
|
|
149
171
|
- test/plugin/test_in_sql.rb
|
|
150
172
|
- test/plugin/test_in_sql_with_custom_time.rb
|
|
173
|
+
- test/plugin/test_in_sql_with_state_file.rb
|
|
151
174
|
- test/plugin/test_out_sql.rb
|
|
152
175
|
homepage: https://github.com/fluent/fluent-plugin-sql
|
|
153
176
|
licenses:
|
|
154
177
|
- Apache-2.0
|
|
155
178
|
metadata: {}
|
|
156
|
-
post_install_message:
|
|
157
179
|
rdoc_options: []
|
|
158
180
|
require_paths:
|
|
159
181
|
- lib
|
|
@@ -168,8 +190,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
190
|
- !ruby/object:Gem::Version
|
|
169
191
|
version: '0'
|
|
170
192
|
requirements: []
|
|
171
|
-
rubygems_version: 3.
|
|
172
|
-
signing_key:
|
|
193
|
+
rubygems_version: 3.6.9
|
|
173
194
|
specification_version: 4
|
|
174
195
|
summary: SQL input/output plugin for Fluentd event collector
|
|
175
|
-
test_files:
|
|
196
|
+
test_files:
|
|
197
|
+
- test/fixtures/schema.rb
|
|
198
|
+
- test/helper.rb
|
|
199
|
+
- test/plugin/test_in_sql.rb
|
|
200
|
+
- test/plugin/test_in_sql_with_custom_time.rb
|
|
201
|
+
- test/plugin/test_in_sql_with_state_file.rb
|
|
202
|
+
- test/plugin/test_out_sql.rb
|