File tree Expand file tree Collapse file tree 3 files changed +42
-33
lines changed
Expand file tree Collapse file tree 3 files changed +42
-33
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ services:
66rvm :
77 - jruby-1.7.23
88script :
9- - bundle exec rspec spec && bundle exec rspec spec --tag redis
9+ - bundle exec rspec spec && bundle exec rspec spec --tag integration
Original file line number Diff line number Diff line change 66
77describe LogStash ::Outputs ::Redis do
88
9- context "integration tests" , :redis => true do
9+ context "integration tests" , :integration => true do
1010 shared_examples_for "writing to redis list" do |extra_config |
1111 let ( :key ) { 10 . times . collect { rand ( 10 ) . to_s } . join ( "" ) }
1212 let ( :event_count ) { Flores ::Random . integer ( 0 ..10000 ) }
7373 end
7474 end
7575 end
76-
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- }
91- }
92- let ( :redis ) { described_class . new ( config ) }
93-
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
98-
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
104- end
105- end
106- end
10776end
10877
Original file line number Diff line number Diff line change 1+ require "logstash/devutils/rspec/spec_helper"
2+ require "logstash/outputs/redis"
3+ require "logstash/json"
4+ require "redis"
5+ require "flores/random"
6+
7+ describe LogStash ::Outputs ::Redis do
8+
9+ context "Redis#receive in batch mode" do
10+ # this is a regression test harness to verify fix for https://github.com/logstash-plugins/logstash-output-redis/issues/26
11+ # TODO: refactor specs above and probably rely on a Redis mock to correctly test the code expected behaviour, the actual
12+ # tests agains Redis should be moved into integration tests.
13+ let ( :key ) { "thekey" }
14+ let ( :payload ) { "somepayload" }
15+ let ( :event ) { LogStash ::Event . new ( { "message" => "test" } ) }
16+ let ( :config ) {
17+ {
18+ "key" => key ,
19+ "data_type" => "list" ,
20+ "batch" => true ,
21+ "batch_events" => 50 ,
22+ }
23+ }
24+ let ( :redis ) { described_class . new ( config ) }
25+
26+ it "should call buffer_receive" do
27+ redis . register
28+ expect ( redis ) . to receive ( :buffer_receive ) . exactly ( 10000 ) . times . and_call_original
29+ expect ( redis ) . to receive ( :flush ) . exactly ( 200 ) . times
30+
31+ # I was able to reproduce the LocalJumpError: unexpected next exception at around 50
32+ # consicutive invocations. setting to 10000 should reproduce it for any environment
33+ # I have no clue at this point why this problem does not happen at every invocation
34+ 1 . upto ( 10000 ) do
35+ expect { redis . receive ( event ) } . to_not raise_error
36+ end
37+ end
38+ end
39+ end
40+
You can’t perform that action at this time.
0 commit comments