logstash-filter-jdbc_static 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44a9dc021efa08eb1c02d143f9c3b16e89b1dab5be971a1c1bd18c047f1b9dcb
|
4
|
+
data.tar.gz: ff306839f602b625350173005b9780504b9ec6f3bfba2abe5cad4f92a654ab4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb10e33bcbd0db98bdbad8ad8575cf2ed631a606285ea2ac489588d033b7c5179e89b2b5133003ac0dad979fa374e303fe55bf6ca5f70f1906b3487f182094e
|
7
|
+
data.tar.gz: 8fb1524a50778571c1fc7bfd8811de682eecdf842cacc0e1c467f42d7296297c6a92b2fe34785fe9d23470d18a0d54e447c212a36f2ff19a0dade3122ab1bb7e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 1.0.7
|
2
|
+
- Fixed issue with driver verification using Java 11 [#51](https://github.com/logstash-plugins/logstash-filter-jdbc_static/pull/51)
|
3
|
+
|
1
4
|
## 1.0.6
|
2
5
|
- Added info to documentation to emphasize significance of table order [36](https://github.com/logstash-plugins/logstash-filter-jdbc_static/pull/36)
|
3
6
|
|
@@ -85,9 +85,8 @@ module LogStash module Filters module Jdbc
|
|
85
85
|
def verify_connection(connection_string, driver_class, driver_library, user, password)
|
86
86
|
begin
|
87
87
|
if driver_library
|
88
|
-
class_loader = java.lang.ClassLoader.getSystemClassLoader().to_java(java.net.URLClassLoader)
|
89
88
|
driver_library.split(",").each do |driver_path|
|
90
|
-
|
89
|
+
require driver_path
|
91
90
|
end
|
92
91
|
end
|
93
92
|
rescue LoadError => e
|
@@ -115,11 +114,6 @@ module LogStash module Filters module Jdbc
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
|
-
def make_driver_path_loadable(class_loader, driver_path)
|
119
|
-
# so we can set an expectation in rspec
|
120
|
-
class_loader.add_url(java.io.File.new(driver_path).toURI().toURL())
|
121
|
-
end
|
122
|
-
|
123
117
|
def post_initialize()
|
124
118
|
@unique_db_name = SecureRandom.hex(12)
|
125
119
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-jdbc_static'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.7'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = "This filter executes a SQL query to fetch a SQL query result, store it locally then use a second SQL query to update an event."
|
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"
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/filters/jdbc_static"
|
4
|
+
require "sequel"
|
5
|
+
require "sequel/adapters/jdbc"
|
6
|
+
require "stud/temporary"
|
7
|
+
require "timecop"
|
8
|
+
|
9
|
+
module LogStash module Filters
|
10
|
+
describe JdbcStatic, :integration => true do
|
11
|
+
|
12
|
+
before(:all) do
|
13
|
+
@thread_abort = Thread.abort_on_exception
|
14
|
+
Thread.abort_on_exception = true
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:loader_statement) { "SELECT ip, name, location FROM reference_table" }
|
18
|
+
let(:lookup_statement) { "SELECT * FROM servers WHERE ip LIKE :ip" }
|
19
|
+
let(:parameters_rhs) { "%%{[ip]}" }
|
20
|
+
let(:temp_import_path_plugin) { Stud::Temporary.pathname }
|
21
|
+
let(:temp_import_path_rspec) { Stud::Temporary.pathname }
|
22
|
+
|
23
|
+
ENV["TZ"] = "Etc/UTC"
|
24
|
+
|
25
|
+
# For Travis and CI based on docker, we source from ENV
|
26
|
+
jdbc_connection_string = ENV.fetch("PG_CONNECTION_STRING",
|
27
|
+
"jdbc:postgresql://postgresql:5432") + "/jdbc_static_db?user=postgres"
|
28
|
+
|
29
|
+
let(:local_db_objects) do
|
30
|
+
[
|
31
|
+
{"name" => "servers", "index_columns" => ["ip"], "columns" => [["ip", "varchar(64)"], ["name", "varchar(64)"], ["location", "varchar(64)"]]},
|
32
|
+
]
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:settings) do
|
36
|
+
{
|
37
|
+
"jdbc_user" => ENV['USER'],
|
38
|
+
"jdbc_driver_class" => "org.postgresql.Driver",
|
39
|
+
"jdbc_driver_library" => "/usr/share/logstash/postgresql.jar",
|
40
|
+
"staging_directory" => temp_import_path_plugin,
|
41
|
+
"jdbc_connection_string" => jdbc_connection_string,
|
42
|
+
"loaders" => [
|
43
|
+
{
|
44
|
+
"id" =>"servers",
|
45
|
+
"query" => loader_statement,
|
46
|
+
"local_table" => "servers"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"local_db_objects" => local_db_objects,
|
50
|
+
"local_lookups" => [
|
51
|
+
{
|
52
|
+
"query" => lookup_statement,
|
53
|
+
"parameters" => {"ip" => parameters_rhs},
|
54
|
+
"target" => "server"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
let(:plugin) { JdbcStatic.new(settings) }
|
61
|
+
|
62
|
+
let(:event) { ::LogStash::Event.new("message" => "some text", "ip" => ipaddr) }
|
63
|
+
|
64
|
+
let(:ipaddr) { ".3.1.1" }
|
65
|
+
|
66
|
+
describe "non scheduled operation" do
|
67
|
+
after { plugin.close }
|
68
|
+
|
69
|
+
context "under normal conditions" do
|
70
|
+
it "enhances an event" do
|
71
|
+
plugin.register
|
72
|
+
plugin.filter(event)
|
73
|
+
expect(event.get("server")).to eq([{"ip"=>"10.3.1.1", "name"=>"mv-server-1", "location"=>"MV-9-6-4"}])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when the loader query returns no results" do
|
78
|
+
let(:loader_statement) { "SELECT ip, name, location FROM reference_table WHERE ip LIKE '20%'" }
|
79
|
+
it "add an empty array to the target field" do
|
80
|
+
plugin.register
|
81
|
+
plugin.filter(event)
|
82
|
+
expect(event.get("server")).to eq([])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "under normal conditions when index_columns is not specified" do
|
87
|
+
let(:local_db_objects) do
|
88
|
+
[
|
89
|
+
{"name" => "servers", "columns" => [["ip", "varchar(64)"], ["name", "varchar(64)"], ["location", "varchar(64)"]]},
|
90
|
+
]
|
91
|
+
end
|
92
|
+
it "enhances an event" do
|
93
|
+
plugin.register
|
94
|
+
plugin.filter(event)
|
95
|
+
expect(event.get("server")).to eq([{"ip"=>"10.3.1.1", "name"=>"mv-server-1", "location"=>"MV-9-6-4"}])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "scheduled operation" do
|
101
|
+
context "given a loader_schedule" do
|
102
|
+
it "should properly schedule" do
|
103
|
+
settings["loader_schedule"] = "*/10 * * * * * UTC"
|
104
|
+
Timecop.travel(Time.now.utc - 3600)
|
105
|
+
Timecop.scale(60)
|
106
|
+
static_filter = JdbcStatic.new(settings)
|
107
|
+
runner = Thread.new(static_filter) do |filter|
|
108
|
+
filter.register
|
109
|
+
end
|
110
|
+
sleep 3
|
111
|
+
static_filter.filter(event)
|
112
|
+
expect(static_filter.loader_runner.reload_count).to be > 1
|
113
|
+
static_filter.close
|
114
|
+
Timecop.return
|
115
|
+
expect(event.get("server")).to eq([{"ip"=>"10.3.1.1", "name"=>"mv-server-1", "location"=>"MV-9-6-4"}])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end end
|
@@ -38,29 +38,6 @@ module LogStash module Filters module Jdbc
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe "multiple driver loading" do
|
42
|
-
before :each do
|
43
|
-
allow(Sequel::JDBC).to receive(:load_driver)
|
44
|
-
allow_any_instance_of(described_class).to receive(:make_driver_path_loadable)
|
45
|
-
end
|
46
|
-
|
47
|
-
context "using three drivers" do
|
48
|
-
it "makes all loadable" do
|
49
|
-
expect_any_instance_of(described_class).to receive(:make_driver_path_loadable).with(anything, "/foo/bar.jar")
|
50
|
-
expect_any_instance_of(described_class).to receive(:make_driver_path_loadable).with(anything, "/foo/baz.jar")
|
51
|
-
expect_any_instance_of(described_class).to receive(:make_driver_path_loadable).with(anything, "/foo/biz.jar")
|
52
|
-
described_class.create("mock://mydb", "a driver class", "/foo/bar.jar, /foo/baz.jar, /foo/biz.jar")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "just one driver" do
|
57
|
-
it "makes one loadable" do
|
58
|
-
expect_any_instance_of(described_class).to receive(:make_driver_path_loadable).once.with(anything, "/foo/bar.jar")
|
59
|
-
described_class.create("mock://mydb", "a driver class", "/foo/bar.jar")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
41
|
describe "methods" do
|
65
42
|
let(:dataset) { double("Sequel::Dataset") }
|
66
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-jdbc_static
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/logstash/filters/jdbc_static.rb
|
174
174
|
- logstash-filter-jdbc_static.gemspec
|
175
175
|
- spec/filters/env_helper.rb
|
176
|
+
- spec/filters/integration/jdbc_static_spec.rb
|
176
177
|
- spec/filters/jdbc/column_spec.rb
|
177
178
|
- spec/filters/jdbc/db_object_spec.rb
|
178
179
|
- spec/filters/jdbc/loader_spec.rb
|
@@ -220,6 +221,7 @@ summary: This filter executes a SQL query to fetch a SQL query result, store it
|
|
220
221
|
then use a second SQL query to update an event.
|
221
222
|
test_files:
|
222
223
|
- spec/filters/env_helper.rb
|
224
|
+
- spec/filters/integration/jdbc_static_spec.rb
|
223
225
|
- spec/filters/jdbc/column_spec.rb
|
224
226
|
- spec/filters/jdbc/db_object_spec.rb
|
225
227
|
- spec/filters/jdbc/loader_spec.rb
|