logstash-output-jdbc 0.2.0.rc5 → 0.2.1
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/README.md +10 -3
- data/spec/outputs/jdbc_spec.rb +86 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f8f8ec2eabfa0a313b967c55e70d3746877d1f
|
4
|
+
data.tar.gz: 4176e942c025b4ad292b2ad611bf975e343da133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e000bfc928a3cdcbdcfff5a70088e88ba0445dd57ad411ee9af98051bb1e31c9de9ce3c325f46aea568a9fe9e77854a7dc53beb65c833f6b09d40edfd66bc4
|
7
|
+
data.tar.gz: 17ca8bf92beae6a3f7c8c3e3de00d73b9d3ef6a39211a60f5c2927b6c13f92f7965de2c4da40fe7f8c038a532ef6ac7022831355ef9308ced1e4ff952309f71b
|
data/README.md
CHANGED
@@ -12,9 +12,9 @@ This plugin does not bundle any JDBC jar files, and does expect them to be in a
|
|
12
12
|
particular location. Please ensure you read the 4 installation lines below.
|
13
13
|
|
14
14
|
## Headlines
|
15
|
-
- Support for connection pooling added in 0.2.0
|
16
|
-
- Support for unsafe statement handling (allowing dynamic queries) in 0.2.0
|
17
|
-
- Altered exception handling to now count sequential flushes with exceptions thrown in 0.2.0
|
15
|
+
- Support for connection pooling added in 0.2.0
|
16
|
+
- Support for unsafe statement handling (allowing dynamic queries) in 0.2.0
|
17
|
+
- Altered exception handling to now count sequential flushes with exceptions thrown in 0.2.0
|
18
18
|
|
19
19
|
## Versions
|
20
20
|
- See master branch for logstash v2+
|
@@ -30,6 +30,13 @@ particular location. Please ensure you read the 4 installation lines below.
|
|
30
30
|
- Add JDBC jar files to vendor/jar/jdbc in your logstash installation
|
31
31
|
- And then configure (examples below)
|
32
32
|
|
33
|
+
## Running tests
|
34
|
+
Assuming valid JDBC jar, and jruby is setup and installed, and you have issued `jruby -S bundle install` in the development directory
|
35
|
+
- `SQL_JAR=path/to/your.jar jruby -S bundle exec rspec`
|
36
|
+
If you need to provide username and password you may do this via the environment variables `SQL_USERNAME` and `SQL_PASSWORD`.
|
37
|
+
|
38
|
+
Tests are not yet 100% complete.
|
39
|
+
|
33
40
|
## Configuration options
|
34
41
|
|
35
42
|
| Option | Type | Description | Required? | Default |
|
data/spec/outputs/jdbc_spec.rb
CHANGED
@@ -1,13 +1,95 @@
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
2
2
|
require "logstash/outputs/jdbc"
|
3
3
|
require "stud/temporary"
|
4
|
+
require "java"
|
4
5
|
|
5
6
|
describe LogStash::Outputs::Jdbc do
|
7
|
+
def fetch_log_table_rowcount
|
8
|
+
# sleep for a second to let the flush happen
|
9
|
+
sleep 1
|
10
|
+
|
11
|
+
stmt = @sql.createStatement()
|
12
|
+
rs = stmt.executeQuery("select count(*) as total from log")
|
13
|
+
count = 0
|
14
|
+
while rs.next()
|
15
|
+
count = rs.getInt("total")
|
16
|
+
end
|
17
|
+
stmt.close()
|
18
|
+
|
19
|
+
return count
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:base_settings) { {
|
23
|
+
"driver_jar_path" => @driver_jar_path,
|
24
|
+
"connection_string" => @test_connection_string,
|
25
|
+
"username" => ENV['SQL_USERNAME'],
|
26
|
+
"password" => ENV['SQL_PASSWORD'],
|
27
|
+
"statement" => [ "insert into log (message) values(?)", "message" ],
|
28
|
+
"max_pool_size" => 1,
|
29
|
+
"flush_size" => 1,
|
30
|
+
"max_flush_exceptions" => 1
|
31
|
+
} }
|
32
|
+
let(:test_settings) { {} }
|
33
|
+
let(:plugin) { LogStash::Outputs::Jdbc.new(base_settings.merge(test_settings)) }
|
34
|
+
let(:event_fields) { { "message" => "This is a message!" } }
|
35
|
+
let(:event) { LogStash::Event.new(event_fields) }
|
36
|
+
|
37
|
+
before(:all) do
|
38
|
+
@driver_jar_path = File.absolute_path(ENV['SQL_JAR'])
|
39
|
+
@test_db_path = File.join(Stud::Temporary.directory, "test.db")
|
40
|
+
@test_connection_string = "jdbc:sqlite:#{@test_db_path}"
|
41
|
+
|
42
|
+
require @driver_jar_path
|
43
|
+
|
44
|
+
@sql = java.sql.DriverManager.get_connection(@test_connection_string, ENV['SQL_USERNAME'].to_s, ENV['SQL_PASSWORD'].to_s)
|
45
|
+
stmt = @sql.createStatement()
|
46
|
+
stmt.executeUpdate("CREATE table log (host text, timestamp datetime, message text);")
|
47
|
+
stmt.close()
|
48
|
+
end
|
49
|
+
|
50
|
+
before(:each) do
|
51
|
+
stmt = @sql.createStatement()
|
52
|
+
stmt.executeUpdate("delete from log")
|
53
|
+
stmt.close()
|
54
|
+
end
|
55
|
+
|
56
|
+
after(:all) do
|
57
|
+
File.unlink(@test_db_path)
|
58
|
+
Dir.rmdir(File.dirname(@test_db_path))
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "safe statement" do
|
62
|
+
it "should register without errors" do
|
63
|
+
expect { plugin.register }.to_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it "receive event, without error" do
|
67
|
+
plugin.register
|
68
|
+
expect { plugin.receive(event) }.to_not raise_error
|
69
|
+
|
70
|
+
expect(fetch_log_table_rowcount).to eq(1)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "unsafe statement" do
|
76
|
+
let(:event_fields) {
|
77
|
+
{ "message" => "This is a message!", "table" => "log" }
|
78
|
+
}
|
79
|
+
let(:test_settings) { {
|
80
|
+
"statement" => [ "insert into %{table} (message) values(?)", "message" ],
|
81
|
+
"unsafe_statement" => true
|
82
|
+
} }
|
83
|
+
|
84
|
+
it "should register without errors" do
|
85
|
+
expect { plugin.register }.to_not raise_error
|
86
|
+
end
|
6
87
|
|
7
|
-
|
8
|
-
|
9
|
-
|
88
|
+
it "receive event, without error" do
|
89
|
+
plugin.register
|
90
|
+
plugin.receive(event)
|
91
|
+
expect(fetch_log_table_rowcount).to eq(1)
|
92
|
+
end
|
10
93
|
|
11
94
|
end
|
12
|
-
|
13
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- the_angry_angel
|
@@ -107,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - '
|
110
|
+
- - '>='
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 2.0.14
|