logstash-integration-jdbc 5.0.3 → 5.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c64a823a0973adc161faebb9a8d71fbaa19b8815ebac92dbb5a85dca53a9941
4
- data.tar.gz: effe43eb271c805374fd39084c54d4b522067a1cbaa6bc5f0efe5ad1a9264aa4
3
+ metadata.gz: c112f66e8224282b05dd0d43c1eb864164629951ebd9f2fdbc5d08514731057f
4
+ data.tar.gz: 69ee8e0cf79f4f4be6d4f0aae5b3f95a1fae46e3458c6a840e23722f9bbb8a60
5
5
  SHA512:
6
- metadata.gz: 43b515624423bd156a471b51ed83545b91875cb364277ef79e5685ab0a019744dbe37227ec230a20f11b164df76187e4df3b4f7961aa1672ee8b36d1338e8ec8
7
- data.tar.gz: abf96d5cd6c97f3896e60395f5f390f6e67e308e168bdbc996d095ecb5a7e0eef6e89f224a91ee0f2908210b78e852b85ab3441f660fdda2cb6cd43b3374d74c
6
+ metadata.gz: 8cc11af1a041fbb7784603be07de4243844bffbdfb980bf0f3ff4394af95d3ea2ed9da8543673f7fa866d999c9ba3df772567b64f31538eb8336cbf68283d39d
7
+ data.tar.gz: 9bc94ac7a6575a5ac797a44f8a8d987978a1bd0816733f252d80924e945a89b54383df101b2381b3d95afa2090149b7bdbdac1fb7dce06f34bd3fa987fba3354
@@ -1,3 +1,6 @@
1
+ ## 5.0.4
2
+ - Fixed issue where JDBC Drivers that don't correctly register with Java's DriverManager fail to load (such as Sybase) [#34](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/34)
3
+
1
4
  ## 5.0.3
2
5
  - Fixed issue where a lost connection to the database can cause errors when using prepared statements with the scheduler [#25](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/25)
3
6
 
@@ -95,7 +95,7 @@ module LogStash module Filters module Jdbc
95
95
  end
96
96
  begin
97
97
  db = nil
98
- ::Sequel::JDBC.load_driver(driver_class)
98
+ @options_hash[:driver] = ::Sequel::JDBC.load_driver(driver_class)
99
99
  @connection_string = connection_string
100
100
  if user
101
101
  @options_hash[:user] = user
@@ -110,13 +110,14 @@ module LogStash module PluginMixins module Jdbc
110
110
  :user => @jdbc_user,
111
111
  :password => @jdbc_password.nil? ? nil : @jdbc_password.value,
112
112
  :pool_timeout => @jdbc_pool_timeout,
113
+ :driver => @driver_impl, # Sequel uses this as a fallback, if given URI doesn't auto-load the driver correctly
113
114
  :keep_reference => false
114
115
  }.merge(@sequel_opts)
115
116
  retry_attempts = @connection_retry_attempts
116
117
  loop do
117
118
  retry_attempts -= 1
118
119
  begin
119
- return Sequel.connect(@jdbc_connection_string, opts=opts)
120
+ return Sequel.connect(@jdbc_connection_string, opts)
120
121
  rescue Sequel::PoolTimeout => e
121
122
  if retry_attempts <= 0
122
123
  @logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Tried #{@connection_retry_attempts} times.")
@@ -147,7 +148,7 @@ module LogStash module PluginMixins module Jdbc
147
148
 
148
149
  load_driver_jars
149
150
  begin
150
- Sequel::JDBC.load_driver(@jdbc_driver_class)
151
+ @driver_impl = Sequel::JDBC.load_driver(@jdbc_driver_class)
151
152
  rescue Sequel::AdapterNotFound => e # Sequel::AdapterNotFound, "#{@jdbc_driver_class} not loaded"
152
153
  # fix this !!!
153
154
  message = if jdbc_driver_library_set?
@@ -84,7 +84,7 @@ module LogStash module PluginMixins module JdbcStreaming
84
84
  @sequel_opts_symbols[:user] = @jdbc_user unless @jdbc_user.nil? || @jdbc_user.empty?
85
85
  @sequel_opts_symbols[:password] = @jdbc_password.value unless @jdbc_password.nil?
86
86
 
87
- Sequel::JDBC.load_driver(@jdbc_driver_class)
87
+ @sequel_opts_symbols[:driver] = Sequel::JDBC.load_driver(@jdbc_driver_class)
88
88
  @database = Sequel.connect(@jdbc_connection_string, @sequel_opts_symbols)
89
89
  if @jdbc_validate_connection
90
90
  @database.extension(:connection_validator)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-integration-jdbc'
3
- s.version = '5.0.3'
3
+ s.version = '5.0.4'
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"
@@ -4,7 +4,6 @@ require "logstash/filters/jdbc_static"
4
4
  require "sequel"
5
5
  require "sequel/adapters/jdbc"
6
6
  require "stud/temporary"
7
- require "timecop"
8
7
 
9
8
  module LogStash module Filters
10
9
  describe JdbcStatic, :integration => true do
@@ -136,18 +135,16 @@ module LogStash module Filters
136
135
  describe "scheduled operation" do
137
136
  context "given a loader_schedule" do
138
137
  it "should properly schedule" do
139
- settings["loader_schedule"] = "*/10 * * * * * UTC"
140
- Timecop.travel(Time.now.utc - 3600)
141
- Timecop.scale(60)
138
+ settings["loader_schedule"] = "*/3 * * * * * UTC"
142
139
  static_filter = JdbcStatic.new(settings)
143
140
  runner = Thread.new(static_filter) do |filter|
144
141
  filter.register
145
142
  end
146
- sleep 3
143
+ runner.join(4)
144
+ sleep 4
147
145
  static_filter.filter(event)
148
146
  expect(static_filter.loader_runner.reload_count).to be > 1
149
147
  static_filter.close
150
- Timecop.return
151
148
  expect(event.get("server")).to eq([{"ip"=>"10.3.1.1", "name"=>"mv-server-1", "location"=>"MV-9-6-4"}])
152
149
  end
153
150
  end
@@ -10,28 +10,37 @@ module LogStash module Filters module Jdbc
10
10
  let(:driver_class) { "org.apache.derby.jdbc.EmbeddedDriver" }
11
11
  let(:driver_library) { nil }
12
12
  subject(:read_only_db) { described_class.create(connection_string, driver_class, driver_library) }
13
+ let(:stub_driver_class) { double(driver_class).as_null_object }
13
14
 
14
15
  describe "basic operations" do
15
16
  describe "initializing" do
17
+ before(:each) do
18
+ allow(Sequel::JDBC).to receive(:load_driver).and_return(stub_driver_class)
19
+ end
20
+
16
21
  it "tests the connection with defaults" do
17
22
  expect(Sequel::JDBC).to receive(:load_driver).once.with(driver_class)
18
- expect(Sequel).to receive(:connect).once.with(connection_string, {:test => true})
23
+ expect(Sequel).to receive(:connect).once.with(connection_string, {:test => true, :driver => stub_driver_class})
19
24
  expect(read_only_db.empty_record_set).to eq([])
20
25
  end
21
26
 
22
- it "tests the connection with fully specified arguments" do
23
- connection_str = "a connection string"
24
- user = "a user"
25
- password = Util::Password.new("secret")
26
- expect(Sequel::JDBC).to receive(:load_driver).once.with("a driver class")
27
- expect(Sequel).to receive(:connect).once.with(connection_str, {:user => user, :password => password.value, :test => true}).and_return(db)
28
- described_class.create(connection_str, "a driver class", nil, user, password)
27
+ context 'with fully-specified arguments' do
28
+ let(:connection_string) { "a connection string" }
29
+ let(:user) { "a user" }
30
+ let(:password) { Util::Password.new("secret") }
31
+ let(:driver_class) { "a driver class" }
32
+
33
+ it "tests the connection" do
34
+ expect(Sequel::JDBC).to receive(:load_driver).once.with(driver_class)
35
+ expect(Sequel).to receive(:connect).once.with(connection_string, {:user => user, :password => password.value, :test => true, :driver => stub_driver_class}).and_return(db)
36
+ described_class.create(connection_string, driver_class, nil, user, password)
37
+ end
29
38
  end
30
39
 
31
40
  it "connects with defaults" do
32
41
  expect(Sequel::JDBC).to receive(:load_driver).once.with(driver_class)
33
- expect(Sequel).to receive(:connect).once.with(connection_string, {:test => true}).and_return(db)
34
- expect(Sequel).to receive(:connect).once.with(connection_string, {}).and_return(db)
42
+ expect(Sequel).to receive(:connect).once.with(connection_string, {:test => true, :driver => stub_driver_class}).and_return(db)
43
+ expect(Sequel).to receive(:connect).once.with(connection_string, {:driver => stub_driver_class}).and_return(db)
35
44
  expect(read_only_db.connected?).to be_falsey
36
45
  read_only_db.connect("a caller specific error message")
37
46
  expect(read_only_db.connected?).to be_truthy
@@ -16,10 +16,11 @@ module LogStash module Filters module Jdbc
16
16
  describe "basic operations" do
17
17
  context "connecting to a db" do
18
18
  it "connects with defaults" do
19
- expect(::Sequel::JDBC).to receive(:load_driver).once.with("org.apache.derby.jdbc.EmbeddedDriver")
19
+ stub_driver_class = double('org.apache.derby.jdbc.EmbeddedDriver').as_null_object
20
+ expect(::Sequel::JDBC).to receive(:load_driver).once.with("org.apache.derby.jdbc.EmbeddedDriver").and_return(stub_driver_class)
20
21
  # two calls to connect because ReadWriteDatabase does verify_connection and connect
21
- expect(::Sequel).to receive(:connect).once.with(connection_string_regex, {:test => true}).and_return(db)
22
- expect(::Sequel).to receive(:connect).once.with(connection_string_regex, {}).and_return(db)
22
+ expect(::Sequel).to receive(:connect).once.with(connection_string_regex, {:driver => stub_driver_class, :test => true}).and_return(db)
23
+ expect(::Sequel).to receive(:connect).once.with(connection_string_regex, {:driver => stub_driver_class}).and_return(db)
23
24
  expect(read_write_db.empty_record_set).to eq([])
24
25
  end
25
26
 
@@ -27,9 +28,10 @@ module LogStash module Filters module Jdbc
27
28
  connection_str = "a connection string"
28
29
  user = "a user"
29
30
  password = Util::Password.new("secret")
30
- expect(::Sequel::JDBC).to receive(:load_driver).once.with("a driver class")
31
- expect(::Sequel).to receive(:connect).once.with(connection_str, {:user => user, :password => password.value, :test => true}).and_return(db)
32
- expect(::Sequel).to receive(:connect).once.with(connection_str, {:user => user, :password => password.value}).and_return(db)
31
+ stub_driver_class = double('com.example.Driver')
32
+ expect(::Sequel::JDBC).to receive(:load_driver).once.with("a driver class").and_return(stub_driver_class)
33
+ expect(::Sequel).to receive(:connect).once.with(connection_str, {:driver => stub_driver_class, :user => user, :password => password.value, :test => true}).and_return(db)
34
+ expect(::Sequel).to receive(:connect).once.with(connection_str, {:driver => stub_driver_class, :user => user, :password => password.value}).and_return(db)
33
35
  described_class.create(connection_str, "a driver class", nil, user, password)
34
36
  end
35
37
  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.0.3
4
+ version: 5.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement