Skip to content

Commit 50cfef5

Browse files
committed
split out specs to unit and integration
1 parent 00cb1f2 commit 50cfef5

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ services:
66
rvm:
77
- jruby-1.7.23
88
script:
9-
- bundle exec rspec spec && bundle exec rspec spec --tag redis
9+
- bundle exec rspec spec && bundle exec rspec spec --tag integration
Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
describe 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) }
@@ -73,36 +73,5 @@
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
10776
end
10877

spec/unit/outputs/redis_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+

0 commit comments

Comments
 (0)