logstash-integration-jdbc 5.4.3 → 5.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/logstash/plugin_mixins/jdbc/value_tracking.rb +14 -1
- data/logstash-integration-jdbc.gemspec +2 -2
- data/spec/filters/jdbc_streaming_spec.rb +7 -7
- data/spec/inputs/jdbc_spec.rb +6 -6
- data/spec/plugin_mixins/jdbc/value_tracking_spec.rb +113 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d90a719c8d965230d4a27d17aedabc24d0c853a3c4f192d1e447335ce69411d
|
4
|
+
data.tar.gz: 6b5027909850ccdf8bbe8873fdf284dde3acc4131da70367c88aad305f265012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2225fadcdb6537e67119a502b1d78061dbb4d9cb7a45a899cb921ae6e77fe5f5059ff7742697399bb904fcb362b2a04fbd5818758312064ad3d0a9ad7368263d
|
7
|
+
data.tar.gz: a9d45af9511c5f415b1014784defdec0a2f862870dcf46907697d734ea8dbfecf465c2af3cd302d8ddef7b88ed97ce97f5ee0cc74a79689c460566c0b1ab7bab
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 5.4.5
|
2
|
+
- Pin sequel to < 5.72.0 due to ruby/bigdecimal#169 [#141](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/141)
|
3
|
+
|
4
|
+
## 5.4.4
|
5
|
+
- Fix: adaptations for JRuby 9.4 [#125](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/125)
|
6
|
+
|
1
7
|
## 5.4.3
|
2
8
|
- Fix crash when metadata file can't be deleted after moving under path.data [#136](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/136)
|
3
9
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "yaml" # persistence
|
3
|
+
require "date"
|
4
|
+
require "bigdecimal"
|
3
5
|
|
4
6
|
module LogStash module PluginMixins module Jdbc
|
5
7
|
class ValueTracking
|
@@ -31,6 +33,17 @@ module LogStash module PluginMixins module Jdbc
|
|
31
33
|
set_initial
|
32
34
|
end
|
33
35
|
|
36
|
+
if Psych::VERSION&.split('.')&.first.to_i >= 4
|
37
|
+
YAML_PERMITTED_CLASSES = [::DateTime, ::Time, ::BigDecimal].freeze
|
38
|
+
def self.load_yaml(source)
|
39
|
+
Psych::safe_load(source, permitted_classes: YAML_PERMITTED_CLASSES)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
def self.load_yaml(source)
|
43
|
+
YAML::load(source)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
def set_initial
|
35
48
|
# override in subclass
|
36
49
|
end
|
@@ -112,7 +125,7 @@ module LogStash module PluginMixins module Jdbc
|
|
112
125
|
|
113
126
|
def read
|
114
127
|
return unless @exists
|
115
|
-
|
128
|
+
ValueTracking.load_yaml(::File.read(@path))
|
116
129
|
end
|
117
130
|
|
118
131
|
def write(value)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-integration-jdbc'
|
3
|
-
s.version = '5.4.
|
3
|
+
s.version = '5.4.5'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Integration with JDBC - input and filter plugins"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
# Restrict use of this plugin to versions of Logstash where support for integration plugins is present.
|
30
30
|
s.add_runtime_dependency "logstash-core", ">= 6.5.0"
|
31
31
|
s.add_runtime_dependency 'logstash-codec-plain'
|
32
|
-
s.add_runtime_dependency 'sequel'
|
32
|
+
s.add_runtime_dependency 'sequel', '< 5.72.0' # until https://github.com/ruby/bigdecimal/issues/169 is fixed
|
33
33
|
s.add_runtime_dependency 'lru_redux' # lru cache with ttl
|
34
34
|
|
35
35
|
s.add_runtime_dependency 'tzinfo'
|
@@ -259,7 +259,7 @@ module LogStash module Filters
|
|
259
259
|
CONFIG
|
260
260
|
end
|
261
261
|
|
262
|
-
sample("message" => "some text") do
|
262
|
+
sample({"message" => "some text"}) do
|
263
263
|
expect(subject.get('new_field')).to eq([{"1" => 'from_database'}])
|
264
264
|
end
|
265
265
|
end
|
@@ -277,7 +277,7 @@ module LogStash module Filters
|
|
277
277
|
CONFIG
|
278
278
|
end
|
279
279
|
|
280
|
-
sample("message" => "some text") do
|
280
|
+
sample({"message" => "some text"}) do
|
281
281
|
expect(subject.get('new_field')).to eq([{"col_1" => 'from_database'}])
|
282
282
|
end
|
283
283
|
end
|
@@ -296,11 +296,11 @@ module LogStash module Filters
|
|
296
296
|
CONFIG
|
297
297
|
end
|
298
298
|
|
299
|
-
sample("message" => "some text", "param_field" => "1") do
|
299
|
+
sample({"message" => "some text", "param_field" => "1"}) do
|
300
300
|
expect(subject.get('new_field')).to eq([{"1" => 'from_database'}])
|
301
301
|
end
|
302
302
|
|
303
|
-
sample("message" => "some text", "param_field" => "2") do
|
303
|
+
sample({"message" => "some text", "param_field" => "2"}) do
|
304
304
|
expect(subject.get('new_field').nil?)
|
305
305
|
end
|
306
306
|
end
|
@@ -319,11 +319,11 @@ module LogStash module Filters
|
|
319
319
|
CONFIG
|
320
320
|
end
|
321
321
|
|
322
|
-
sample("message" => "some text", "param_field" => 1) do
|
322
|
+
sample({"message" => "some text", "param_field" => 1}) do
|
323
323
|
expect(subject.get('new_field')).to eq([{"1" => 'from_database'}])
|
324
324
|
end
|
325
325
|
|
326
|
-
sample("message" => "some text", "param_field" => "1") do
|
326
|
+
sample({"message" => "some text", "param_field" => "1"}) do
|
327
327
|
expect(subject.get('new_field').nil?)
|
328
328
|
end
|
329
329
|
end
|
@@ -342,7 +342,7 @@ module LogStash module Filters
|
|
342
342
|
CONFIG
|
343
343
|
end
|
344
344
|
|
345
|
-
sample("message" => "some text") do
|
345
|
+
sample({"message" => "some text"}) do
|
346
346
|
expect(subject.get('new_field')).to eq([{"1" => 'from_database'}])
|
347
347
|
end
|
348
348
|
end
|
data/spec/inputs/jdbc_spec.rb
CHANGED
@@ -277,7 +277,7 @@ describe LogStash::Inputs::Jdbc do
|
|
277
277
|
sleep 1
|
278
278
|
for i in 0..1
|
279
279
|
sleep 1
|
280
|
-
updated_last_run =
|
280
|
+
updated_last_run = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(File.read(settings["last_run_metadata_path"]))
|
281
281
|
expect(updated_last_run).to be > last_run_time
|
282
282
|
last_run_time = updated_last_run
|
283
283
|
end
|
@@ -547,7 +547,7 @@ describe LogStash::Inputs::Jdbc do
|
|
547
547
|
expect(actual).to eq(expected)
|
548
548
|
plugin.stop
|
549
549
|
raw_last_run_value = File.read(settings["last_run_metadata_path"])
|
550
|
-
last_run_value =
|
550
|
+
last_run_value = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(raw_last_run_value)
|
551
551
|
expect(last_run_value).to be_a(DateTime)
|
552
552
|
expect(last_run_value.strftime("%F %T.%N %Z")).to eq("2015-01-02 02:00:00.722000000 +00:00")
|
553
553
|
|
@@ -562,7 +562,7 @@ describe LogStash::Inputs::Jdbc do
|
|
562
562
|
plugin.stop
|
563
563
|
expect(event.get("num")).to eq(12)
|
564
564
|
expect(event.get("custom_time").time).to eq(Time.iso8601("2015-01-02T03:00:00.811Z"))
|
565
|
-
last_run_value =
|
565
|
+
last_run_value = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(File.read(settings["last_run_metadata_path"]))
|
566
566
|
expect(last_run_value).to be_a(DateTime)
|
567
567
|
# verify that sub-seconds are recorded to the file
|
568
568
|
expect(last_run_value.strftime("%F %T.%N %Z")).to eq("2015-01-02 03:00:00.811000000 +00:00")
|
@@ -1169,7 +1169,7 @@ describe LogStash::Inputs::Jdbc do
|
|
1169
1169
|
context "when a file exists" do
|
1170
1170
|
before do
|
1171
1171
|
# in a faked HOME folder save a valid previous last_run metadata file
|
1172
|
-
allow(ENV).to receive(:[]).and_call_original
|
1172
|
+
allow(ENV).to receive(:[]).with(anything).and_call_original
|
1173
1173
|
allow(ENV).to receive(:[]).with('HOME').and_return(fake_home)
|
1174
1174
|
|
1175
1175
|
File.open("#{fake_home}/.logstash_jdbc_last_run", 'w') do |file|
|
@@ -1722,7 +1722,7 @@ describe LogStash::Inputs::Jdbc do
|
|
1722
1722
|
plugin.run(queue)
|
1723
1723
|
|
1724
1724
|
expect(queue.size).to eq(expected_queue_size)
|
1725
|
-
expect(
|
1725
|
+
expect(LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(File.read(settings["last_run_metadata_path"]))).to eq(expected_queue_size)
|
1726
1726
|
end
|
1727
1727
|
end
|
1728
1728
|
|
@@ -1747,7 +1747,7 @@ describe LogStash::Inputs::Jdbc do
|
|
1747
1747
|
plugin.run(queue)
|
1748
1748
|
|
1749
1749
|
expect(queue.size).to eq(expected_queue_size)
|
1750
|
-
expect(
|
1750
|
+
expect(LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(File.read(settings["last_run_metadata_path"]))).to eq(last_run_value + expected_queue_size)
|
1751
1751
|
end
|
1752
1752
|
end
|
1753
1753
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/plugin_mixins/jdbc/value_tracking"
|
3
|
+
require "tempfile"
|
4
|
+
|
5
|
+
module LogStash module PluginMixins module Jdbc
|
6
|
+
describe ValueTracking do
|
7
|
+
context "#load_yaml" do
|
8
|
+
|
9
|
+
context "with date string" do
|
10
|
+
let(:yaml_date_source) { "--- !ruby/object:DateTime '2023-06-15 09:59:30.558000000 +02:00'\n" }
|
11
|
+
|
12
|
+
it "should be loaded" do
|
13
|
+
parsed_date = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(yaml_date_source)
|
14
|
+
expect(parsed_date.class).to eq DateTime
|
15
|
+
expect(parsed_date.year).to eq 2023
|
16
|
+
expect(parsed_date.month).to eq 6
|
17
|
+
expect(parsed_date.day).to eq 15
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with time string" do
|
22
|
+
let(:yaml_time_source) { "--- 2023-06-15 15:28:15.227874000 +02:00\n" }
|
23
|
+
|
24
|
+
it "should be loaded" do
|
25
|
+
parsed_time = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(yaml_time_source)
|
26
|
+
expect(parsed_time.class).to eq Time
|
27
|
+
expect(parsed_time.year).to eq 2023
|
28
|
+
expect(parsed_time.month).to eq 6
|
29
|
+
expect(parsed_time.day).to eq 15
|
30
|
+
expect(parsed_time.hour).to eq 15
|
31
|
+
expect(parsed_time.min).to eq 28
|
32
|
+
expect(parsed_time.sec).to eq 15
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with date string" do
|
37
|
+
let(:yaml_bigdecimal_source) { "--- !ruby/object:BigDecimal '0:0.1e1'\n" }
|
38
|
+
|
39
|
+
it "should be loaded" do
|
40
|
+
parsed_bigdecimal = LogStash::PluginMixins::Jdbc::ValueTracking.load_yaml(yaml_bigdecimal_source)
|
41
|
+
expect(parsed_bigdecimal.class).to eq BigDecimal
|
42
|
+
expect(parsed_bigdecimal.to_i).to eq 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "#build_last_value_tracker" do
|
48
|
+
|
49
|
+
let(:plugin) { double("fake plugin") }
|
50
|
+
let(:temp_file) { Tempfile.new('last_run_tracker') }
|
51
|
+
|
52
|
+
before(:each) do
|
53
|
+
allow(plugin).to receive(:record_last_run).and_return(true)
|
54
|
+
allow(plugin).to receive(:clean_run).and_return(false)
|
55
|
+
allow(plugin).to receive(:last_run_metadata_file_path).and_return(temp_file.path)
|
56
|
+
end
|
57
|
+
|
58
|
+
context "create numerical tracker" do
|
59
|
+
before(:each) do
|
60
|
+
allow(plugin).to receive(:use_column_value).and_return(true)
|
61
|
+
allow(plugin).to receive(:tracking_column_type).and_return("numeric")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should write correctly" do
|
65
|
+
tracker = ValueTracking.build_last_value_tracker(plugin)
|
66
|
+
tracker.set_value(1)
|
67
|
+
tracker.write
|
68
|
+
|
69
|
+
temp_file.rewind
|
70
|
+
v = ValueTracking.load_yaml(::File.read(temp_file.path))
|
71
|
+
expect(v).to eq 1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "create date time tracker" do
|
76
|
+
before(:each) do
|
77
|
+
allow(plugin).to receive(:use_column_value).and_return(false)
|
78
|
+
allow(plugin).to receive(:jdbc_default_timezone).and_return(:something_not_nil)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should write correctly" do
|
82
|
+
tracker = ValueTracking.build_last_value_tracker(plugin)
|
83
|
+
tracker.set_value("2023-06-15T15:28:15+02:00")
|
84
|
+
tracker.write
|
85
|
+
|
86
|
+
temp_file.rewind
|
87
|
+
v = ValueTracking.load_yaml(::File.read(temp_file.path))
|
88
|
+
expect(v.class).to eq DateTime
|
89
|
+
expect(v.year).to eq 2023
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "create time tracker" do
|
94
|
+
before(:each) do
|
95
|
+
allow(plugin).to receive(:use_column_value).and_return(false)
|
96
|
+
allow(plugin).to receive(:jdbc_default_timezone).and_return(nil)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should write correctly" do
|
100
|
+
tracker = ValueTracking.build_last_value_tracker(plugin)
|
101
|
+
tracker.set_value("2023-06-15T15:28:15+02:00")
|
102
|
+
tracker.write
|
103
|
+
|
104
|
+
temp_file.rewind
|
105
|
+
v = ValueTracking.load_yaml(::File.read(temp_file.path))
|
106
|
+
expect(v.class).to eq Time
|
107
|
+
expect(v.min).to eq 28
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end end end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-integration-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.4.
|
4
|
+
version: 5.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,17 +75,17 @@ dependencies:
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - "<"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 5.72.0
|
81
81
|
name: sequel
|
82
82
|
prerelease: false
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - "
|
86
|
+
- - "<"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: 5.72.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- spec/inputs/integration/integ_spec.rb
|
308
308
|
- spec/inputs/jdbc_spec.rb
|
309
309
|
- spec/plugin_mixins/jdbc/timezone_proxy_spec.rb
|
310
|
+
- spec/plugin_mixins/jdbc/value_tracking_spec.rb
|
310
311
|
- spec/plugin_mixins/jdbc_streaming/parameter_handler_spec.rb
|
311
312
|
- vendor/jar-dependencies/org/apache/derby/derby/10.14.1.0/derby-10.14.1.0.jar
|
312
313
|
- vendor/jar-dependencies/org/apache/derby/derbyclient/10.14.1.0/derbyclient-10.14.1.0.jar
|
@@ -360,4 +361,5 @@ test_files:
|
|
360
361
|
- spec/inputs/integration/integ_spec.rb
|
361
362
|
- spec/inputs/jdbc_spec.rb
|
362
363
|
- spec/plugin_mixins/jdbc/timezone_proxy_spec.rb
|
364
|
+
- spec/plugin_mixins/jdbc/value_tracking_spec.rb
|
363
365
|
- spec/plugin_mixins/jdbc_streaming/parameter_handler_spec.rb
|