mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- Add redis output test; currently covers 'list' mode only.
This commit is contained in:
parent
031ef354fd
commit
fa40fcf304
1 changed files with 48 additions and 0 deletions
48
spec/outputs/redis.rb
Normal file
48
spec/outputs/redis.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
require "test_utils"
|
||||
|
||||
describe "outputs/elasticsearch_http" do
|
||||
extend LogStash::RSpec
|
||||
|
||||
describe "ship lots of events to a list" do
|
||||
key = 10.times.collect { rand(10).to_s }.join("")
|
||||
event_count = 10000 + rand(500)
|
||||
|
||||
config <<-CONFIG
|
||||
input {
|
||||
generator {
|
||||
message => "hello world"
|
||||
count => #{event_count}
|
||||
type => "generator"
|
||||
}
|
||||
}
|
||||
output {
|
||||
redis {
|
||||
host => "127.0.0.1"
|
||||
key => "#{key}"
|
||||
data_type => list
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
agent do
|
||||
# Query redis directly and inspect the goodness.
|
||||
redis = Redis.new(:host => "127.0.0.1")
|
||||
|
||||
# The list should contain the number of elements our agent pushed up.
|
||||
insist { redis.llen(key) } == event_count
|
||||
|
||||
# Now check all events for order and correctness.
|
||||
event_count.times do |value|
|
||||
id, element = redis.blpop(key, 0)
|
||||
event = LogStash::Event.new(JSON.parse(element))
|
||||
insist { event["sequence"] } == value
|
||||
insist { event.message } == "hello world"
|
||||
insist { event.type } == "generator"
|
||||
end
|
||||
|
||||
# The list should now be empty
|
||||
insist { redis.llen(key) } == 0
|
||||
end # agent
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue