logstash-output-charrington 0.3.19 → 0.3.20

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: 93fef656027952ae8fd353066e05b572c76bf5632a1af82ff402dda7fe2fc79e
4
- data.tar.gz: ebb249f4b2b5ad42bafce89725635017dbcc81be865a933dd6ac0a83709e5e82
3
+ metadata.gz: 2ae644e2b642cfbf37d315289ff166d7b03e19865dd50320126e71f50954965c
4
+ data.tar.gz: 5af164f7c8a73ed16001ef89922095bb0d37699fbc7c144c06eff4ab23e0481a
5
5
  SHA512:
6
- metadata.gz: ede84fd07dd59e83de1338b2d095a5d5818074e10ebb13131ccc22e6cf0874c8b182190b099f7b2df1e09f110b8d9e9a63cabd4add3505ac14ecb50de016ceb6
7
- data.tar.gz: 84a254e11976eecaa84bb5057d153035f5578039b1da666993bd01be421d8801cfa29604fd50461f53c6bd7d479ccdb617e0043d03fc3ab854a971498d57bd73
6
+ metadata.gz: 5f6583538a0632625e50bb48e6b48864455c2edb0987d434bda4f31edd0479b4805e72974feb0213496f6db77bb6e133661e09d448ac4423cd69bce5ddf07c9e
7
+ data.tar.gz: 7f3cf086ba6be74f724beed922eaf3fc8d8dc8dcabf24a599cce0ac5acbc1cc8ae927d0d10f0da8e287c00145cdbaa770141d7608e79966dcfb521bdde91c76e
@@ -176,11 +176,15 @@ module Charrington
176
176
  values << value
177
177
 
178
178
  if @@timestamp_columns.include?(key)
179
- format = java.text.SimpleDateFormat.new("yyyy-MM-dd'T'HH:mm:ss'Z'")
180
- parsed = format.parse(value)
181
- time = java.sql.Timestamp.new(parsed.getTime)
182
- stmt.setTimestamp(pos, time)
183
- next
179
+ begin
180
+ time = parse_date(value)
181
+ stmt.setTimestamp(pos, time)
182
+ next
183
+ rescue java.text.ParseException => e
184
+ time = parse_date(value, "yyyy-MM-dd'T'HH:mm:ss'Z'")
185
+ stmt.setTimestamp(pos, time)
186
+ next
187
+ end
184
188
  end
185
189
 
186
190
  case value
@@ -212,6 +216,11 @@ module Charrington
212
216
  end
213
217
 
214
218
  ### Helpers
219
+ def parse_date(date, fmt = "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
220
+ format = java.text.SimpleDateFormat.new(fmt)
221
+ parsed = format.parse(date)
222
+ java.sql.Timestamp.new(parsed.getTime)
223
+ end
215
224
 
216
225
  def arr_to_csv(arr)
217
226
  '(' + arr.join(', ') + ')'
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-charrington'
3
- s.version = '0.3.19'
3
+ s.version = '0.3.20'
4
4
 
5
5
  s.licenses = ['Apache-2.0']
6
6
  s.homepage = 'https://gitlab.podium.com/engineering/analytics/logstash-output-charrington'
@@ -19,10 +19,14 @@ RSpec.shared_context 'pipeline' do
19
19
  end
20
20
 
21
21
  RSpec.shared_context 'postgres' do
22
- def start_database(host='localhost', port=57354, database='winston', user='testuser', password='password')
23
- config = Java::RuYandexQatoolsEmbedPostgresql::EmbeddedPostgres::cachedRuntimeConfig(Paths::get('/tmp/charrington-test-db-cache')) # avoid archive extraction every time
24
- db = Java::RuYandexQatoolsEmbedPostgresql::EmbeddedPostgres.new
25
- @url = db.start(config, host, port, database, user, password, ArrayList.new(["-E", "SQL_ASCII", "--locale=C", "--lc-collate=C", "--lc-ctype=C"]))
22
+ def start_database(embedded = true, host='localhost', port=57354, database='winston', user='testuser', password='password')
23
+ if embedded
24
+ config = Java::RuYandexQatoolsEmbedPostgresql::EmbeddedPostgres::cachedRuntimeConfig(Paths::get('/tmp/charrington-test-db-cache')) # avoid archive extraction every time
25
+ db = Java::RuYandexQatoolsEmbedPostgresql::EmbeddedPostgres.new
26
+ @url = db.start(config, host, port, database, user, password, ArrayList.new(["-E", "SQL_ASCII", "--locale=C", "--lc-collate=C", "--lc-ctype=C"]))
27
+ else
28
+ @url = "jdbc:postgresql://#{host}/#{database}?user=#{user}&password=#{password}";
29
+ end
26
30
 
27
31
  # setup connection manager
28
32
  @connection_manager = Java::ComZaxxerHikari::HikariDataSource.new
@@ -33,7 +37,11 @@ RSpec.shared_context 'postgres' do
33
37
  end
34
38
 
35
39
  before(:all) do
36
- start_database
40
+ if ENV.fetch("TEST_ENV", "").to_s.casecmp?("ci")
41
+ start_database(false, 'postgres', 5432, 'postgres', 'postgres', '')
42
+ else
43
+ start_database
44
+ end
37
45
  end
38
46
 
39
47
  let(:driver_path) {
@@ -248,7 +248,7 @@ describe LogStash::Outputs::Charrington do
248
248
  ])
249
249
  expect(query('SELECT COUNT(1) FROM schemaless').first[:count]).to eq("1")
250
250
  expect(query("SELECT * FROM tracks")).to match_array([
251
- {:id=>a_kind_of(String), :anonymous_id=>"", :app_name=>"Web App", :context_campaign_content=>nil, :context_campaign_medium=>nil, :context_campaign_name=>nil, :context_campaign_source=>nil, :context_ip=>nil, :context_library_name=>nil, :context_library_version=>nil, :context_page_path=>nil, :context_page_referrer=>nil, :context_page_search=>nil, :context_page_title=>nil, :context_page_url=>nil, :context_user_agent=>nil, :event=>"schemaless", :event_text=>"schemaless", :original_timestamp=>nil, :received_at=>nil, :segment_dedupe_id=>nil, :sent_at=>a_kind_of(String), :timestamp=>nil, :user_id=>"123", :user_uid=>"456", :uuid=>nil, :uuid_ts=>a_kind_of(String)}
251
+ {:id=>a_kind_of(String), :anonymous_id=>"", :app_name=>"Web App", :context_campaign_content=>nil, :context_campaign_medium=>nil, :context_campaign_name=>nil, :context_campaign_source=>nil, :context_ip=>nil, :context_library_name=>nil, :context_library_version=>nil, :context_page_path=>nil, :context_page_referrer=>nil, :context_page_search=>nil, :context_page_title=>nil, :context_page_url=>nil, :context_user_agent=>nil, :event=>"schemaless", :event_text=>"schemaless", :original_timestamp=>"2019-07-29 20:09:18", :received_at=>"2019-07-29 20:09:18", :segment_dedupe_id=>nil, :sent_at=>"2019-07-29 20:09:18", :timestamp=>"2019-07-29 20:09:18", :user_id=>"123", :user_uid=>"456", :uuid=>nil, :uuid_ts=>a_kind_of(String)}
252
252
  ])
253
253
  end
254
254
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-charrington
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.19
4
+ version: 0.3.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - dconger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-28 00:00:00.000000000 Z
13
+ date: 2019-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement