logstash-output-redis 2.0.4 → 2.0.5

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
  SHA1:
3
- metadata.gz: a529cca11d4cde933249b32c7e76ae676d9b755b
4
- data.tar.gz: 2ec4475ed8cb05a5c68e989a8e87b44394fa9016
3
+ metadata.gz: e5521e16c30f64515f0280b3dac67304d69704a0
4
+ data.tar.gz: 0cdffaddc9e1d3347be833351cb6a31981061174
5
5
  SHA512:
6
- metadata.gz: 3fe3cfc505241664aa8e9eaf267090145c9cf0ec51e3099e0aa0c1e983513e53b4a6955d342a5209f0dd09f316eb050454b638f43101cfd815f366ce0bd33808
7
- data.tar.gz: 39c5ec408749415ecedc7a3edb7f5f5be74aa2df9878d7323eb652dd90754f2a9ec1cdf6e7c6614234668f1540b9653472279e38df093d6892b4028236c76ec7
6
+ metadata.gz: 7e489069572645b18d6db062d0cf4712ac4087d92fa88b5c54b9f78485407085bd18bc4cca54a15de908ed6657b5a37596dce2f11fa5805acb7de2a64d4882ec
7
+ data.tar.gz: b398711520f6e4667f5c18a487c6efeea300058152c6b31bf7b659bbd85a5ec7c6ac6c0e90feba3ec0c1024191579ffd067c7b2053c5b516e54e4b96f10fdac8
data/CHANGELOG.md CHANGED
@@ -1,9 +1,11 @@
1
+ # 2.0.5
2
+ - Fix LocalJumpError exception see https://github.com/logstash-plugins/logstash-output-redis/pull/27
1
3
  # 2.0.4
2
4
  - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
3
5
  # 2.0.3
4
6
  - New dependency requirements for logstash-core for the 5.0 release
5
7
  ## 2.0.0
6
- - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
8
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
7
9
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
8
10
  - Dependency on logstash-core update to 2.0
9
11
 
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Build
4
- Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-redis-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-redis-unit/)
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-redis.svg)](https://travis-ci.org/logstash-plugins/logstash-output-redis)
5
4
 
6
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
6
 
@@ -7,7 +7,7 @@ require "stud/buffer"
7
7
  # The RPUSH command is supported in Redis v0.0.7+. Using
8
8
  # PUBLISH to a channel requires at least v1.3.8+.
9
9
  # While you may be able to make these Redis versions work,
10
- # the best performance and stability will be found in more
10
+ # the best performance and stability will be found in more
11
11
  # recent stable versions. Versions 2.6.0+ are recommended.
12
12
  #
13
13
  # For more information, see http://redis.io/[the Redis homepage]
@@ -144,14 +144,17 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
144
144
  end # def register
145
145
 
146
146
  def receive(event)
147
-
148
-
149
147
  # TODO(sissel): We really should not drop an event, but historically
150
148
  # we have dropped events that fail to be converted to json.
151
149
  # TODO(sissel): Find a way to continue passing events through even
152
150
  # if they fail to convert properly.
153
151
  begin
154
152
  @codec.encode(event)
153
+ rescue LocalJumpError
154
+ # This LocalJumpError rescue clause is required to test for regressions
155
+ # for https://github.com/logstash-plugins/logstash-output-redis/issues/26
156
+ # see specs. Without it the LocalJumpError is rescued by the StandardError
157
+ raise
155
158
  rescue StandardError => e
156
159
  @logger.warn("Error encoding event", :exception => e,
157
160
  :event => event)
@@ -229,11 +232,11 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
229
232
  def send_to_redis(event, payload)
230
233
  # How can I do this sort of thing with codecs?
231
234
  key = event.sprintf(@key)
232
-
233
- if @batch and @data_type == 'list' # Don't use batched method for pubsub.
235
+
236
+ if @batch && @data_type == 'list' # Don't use batched method for pubsub.
234
237
  # Stud::Buffer
235
238
  buffer_receive(payload, key)
236
- next
239
+ return
237
240
  end
238
241
 
239
242
  begin
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-redis'
4
- s.version = '2.0.4'
4
+ s.version = '2.0.5'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This output will send events to a Redis queue using RPUSH"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -4,70 +4,103 @@ require "logstash/json"
4
4
  require "redis"
5
5
  require "flores/random"
6
6
 
7
- describe LogStash::Outputs::Redis, :redis => true do
7
+ describe LogStash::Outputs::Redis do
8
8
 
9
- shared_examples_for "writing to redis list" do |extra_config|
10
- let(:key) { 10.times.collect { rand(10).to_s }.join("") }
11
- let(:event_count) { Flores::Random.integer(0..10000) }
12
- let(:message) { Flores::Random.text(0..100) }
13
- let(:default_config) {
14
- {
15
- "key" => key,
16
- "data_type" => "list",
17
- "host" => "localhost"
9
+ context "integration tests", :redis => true do
10
+ shared_examples_for "writing to redis list" do |extra_config|
11
+ let(:key) { 10.times.collect { rand(10).to_s }.join("") }
12
+ let(:event_count) { Flores::Random.integer(0..10000) }
13
+ let(:message) { Flores::Random.text(0..100) }
14
+ let(:default_config) {
15
+ {
16
+ "key" => key,
17
+ "data_type" => "list",
18
+ "host" => "localhost"
19
+ }
18
20
  }
19
- }
20
- let(:redis_config) {
21
- default_config.merge(extra_config || {})
22
- }
23
- let(:redis_output) { described_class.new(redis_config) }
21
+ let(:redis_config) {
22
+ default_config.merge(extra_config || {})
23
+ }
24
+ let(:redis_output) { described_class.new(redis_config) }
24
25
 
25
- before do
26
- redis_output.register
27
- event_count.times do |i|
28
- event = LogStash::Event.new("sequence" => i, "message" => message)
29
- redis_output.receive(event)
26
+ before do
27
+ redis_output.register
28
+ event_count.times do |i|
29
+ event = LogStash::Event.new("sequence" => i, "message" => message)
30
+ redis_output.receive(event)
31
+ end
32
+ redis_output.close
30
33
  end
31
- redis_output.close
32
- end
33
34
 
34
- it "should successfully send all events to redis" do
35
- redis = Redis.new(:host => "127.0.0.1")
36
-
37
- # The list should contain the number of elements our agent pushed up.
38
- insist { redis.llen(key) } == event_count
35
+ it "should successfully send all events to redis" do
36
+ redis = Redis.new(:host => "127.0.0.1")
37
+
38
+ # The list should contain the number of elements our agent pushed up.
39
+ insist { redis.llen(key) } == event_count
39
40
 
40
- # Now check all events for order and correctness.
41
- event_count.times do |value|
42
- id, element = redis.blpop(key, 0)
43
- event = LogStash::Event.new(LogStash::Json.load(element))
44
- insist { event["sequence"] } == value
45
- insist { event["message"] } == message
41
+ # Now check all events for order and correctness.
42
+ event_count.times do |value|
43
+ id, element = redis.blpop(key, 0)
44
+ event = LogStash::Event.new(LogStash::Json.load(element))
45
+ insist { event["sequence"] } == value
46
+ insist { event["message"] } == message
47
+ end
48
+
49
+ # The list should now be empty
50
+ insist { redis.llen(key) } == 0
46
51
  end
52
+ end
47
53
 
48
- # The list should now be empty
49
- insist { redis.llen(key) } == 0
54
+ context "when batch_mode is false" do
55
+ include_examples "writing to redis list"
50
56
  end
51
- end
52
57
 
53
- context "when batch_mode is false" do
54
- include_examples "writing to redis list"
58
+ context "when batch_mode is true" do
59
+ batch_events = Flores::Random.integer(1..1000)
60
+ batch_settings = {
61
+ "batch" => true,
62
+ "batch_events" => batch_events
63
+ }
64
+
65
+ include_examples "writing to redis list", batch_settings do
66
+
67
+ # A canary to make sure we're actually enabling batch mode
68
+ # in this shared example.
69
+ it "should have batch mode enabled" do
70
+ expect(redis_config).to include("batch")
71
+ expect(redis_config["batch"]).to be_truthy
72
+ end
73
+ end
74
+ end
55
75
  end
56
76
 
57
- context "when batch_mode is true" do
58
- batch_events = Flores::Random.integer(1..1000)
59
- batch_settings = {
60
- "batch" => true,
61
- "batch_events" => batch_events
77
+ context "Redis#receive in batch mode" do
78
+ # this is a regression test harness to verify fix for https://github.com/logstash-plugins/logstash-output-redis/issues/26
79
+ # TODO: refactor specs above and probably rely on a Redis mock to correctly test the code expected behaviour, the actual
80
+ # tests agains Redis should be moved into integration tests.
81
+ let(:key) { "thekey" }
82
+ let(:payload) { "somepayload"}
83
+ let(:event) { LogStash::Event.new({"message" => "test"}) }
84
+ let(:config) {
85
+ {
86
+ "key" => key,
87
+ "data_type" => "list",
88
+ "batch" => true,
89
+ "batch_events" => 50,
90
+ }
62
91
  }
92
+ let(:redis) { described_class.new(config) }
63
93
 
64
- include_examples "writing to redis list", batch_settings do
94
+ it "should call buffer_receive" do
95
+ redis.register
96
+ expect(redis).to receive(:buffer_receive).exactly(10000).times.and_call_original
97
+ expect(redis).to receive(:flush).exactly(200).times
65
98
 
66
- # A canary to make sure we're actually enabling batch mode
67
- # in this shared example.
68
- it "should have batch mode enabled" do
69
- expect(redis_config).to include("batch")
70
- expect(redis_config["batch"]).to be_truthy
99
+ # I was able to reproduce the LocalJumpError: unexpected next exception at around 50
100
+ # consicutive invocations. setting to 10000 should reproduce it for any environment
101
+ # I have no clue at this point why this problem does not happen at every invocation
102
+ 1.upto(10000) do
103
+ expect{redis.receive(event)}.to_not raise_error
71
104
  end
72
105
  end
73
106
  end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
14
20
  requirement: !ruby/object:Gem::Requirement
15
21
  requirements:
16
- - - "~>"
22
+ - - ~>
17
23
  - !ruby/object:Gem::Version
18
24
  version: '1.0'
19
- name: logstash-core-plugin-api
20
25
  prerelease: false
21
26
  type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis
22
29
  version_requirements: !ruby/object:Gem::Requirement
23
30
  requirements:
24
- - - "~>"
31
+ - - '>='
25
32
  - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
33
+ version: '0'
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
- - - ">="
36
+ - - '>='
31
37
  - !ruby/object:Gem::Version
32
38
  version: '0'
33
- name: redis
34
39
  prerelease: false
35
40
  type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: stud
36
43
  version_requirements: !ruby/object:Gem::Requirement
37
44
  requirements:
38
- - - ">="
45
+ - - '>='
39
46
  - !ruby/object:Gem::Version
40
47
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
48
  requirement: !ruby/object:Gem::Requirement
43
49
  requirements:
44
- - - ">="
50
+ - - '>='
45
51
  - !ruby/object:Gem::Version
46
52
  version: '0'
47
- name: stud
48
53
  prerelease: false
49
54
  type: :runtime
55
+ - !ruby/object:Gem::Dependency
56
+ name: logstash-devutils
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ">="
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
62
  requirement: !ruby/object:Gem::Requirement
57
63
  requirements:
58
- - - ">="
64
+ - - '>='
59
65
  - !ruby/object:Gem::Version
60
66
  version: '0'
61
- name: logstash-devutils
62
67
  prerelease: false
63
68
  type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: logstash-input-generator
64
71
  version_requirements: !ruby/object:Gem::Requirement
65
72
  requirements:
66
- - - ">="
73
+ - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
76
  requirement: !ruby/object:Gem::Requirement
71
77
  requirements:
72
- - - ">="
78
+ - - '>='
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
- name: logstash-input-generator
76
81
  prerelease: false
77
82
  type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: logstash-codec-json
78
85
  version_requirements: !ruby/object:Gem::Requirement
79
86
  requirements:
80
- - - ">="
87
+ - - '>='
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
90
  requirement: !ruby/object:Gem::Requirement
85
91
  requirements:
86
- - - ">="
92
+ - - '>='
87
93
  - !ruby/object:Gem::Version
88
94
  version: '0'
89
- name: logstash-codec-json
90
95
  prerelease: false
91
96
  type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: flores
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
- - - ">="
101
+ - - '>='
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
104
  requirement: !ruby/object:Gem::Requirement
99
105
  requirements:
100
- - - ">="
106
+ - - '>='
101
107
  - !ruby/object:Gem::Version
102
108
  version: '0'
103
- name: flores
104
109
  prerelease: false
105
110
  type: :development
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
111
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
112
112
  email: info@elastic.co
113
113
  executables: []
@@ -135,12 +135,12 @@ require_paths:
135
135
  - lib
136
136
  required_ruby_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ">="
138
+ - - '>='
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []