- report stats on completion

- randomize flush_size
This commit is contained in:
Jordan Sissel 2012-09-01 16:40:56 -07:00
parent c9cf0be101
commit 571d66d587

View file

@ -1,20 +1,18 @@
require "test_utils"
require "logstash/outputs/elasticsearch_http"
require "insist"
require "stud/try"
require "spoon"
describe LogStash::Outputs::ElasticSearchHTTP do
describe "outputs/elasticsearch_http" do
extend LogStash::RSpec
describe "ship lots of events" do
# Generate a random index name
index = 10.times.collect { rand(10).to_s }.join("")
# Write a random number of events
# Write about 10000 events. Add jitter to increase likeliness of finding
# boundary-related bugs.
event_count = 10000 + rand(500)
flush_size = rand(200) + 1
puts "Index: #{index}"
p :index => index, :event_count => event_count, :flush_size => flush_size
config <<-CONFIG
input {
@ -30,14 +28,18 @@ describe LogStash::Outputs::ElasticSearchHTTP do
port => 9200
index => "#{index}"
index_type => "testing"
flush_size => 20
flush_size => #{flush_size}
}
}
CONFIG
agent do
Stud::try(5.times) do
puts "Checking ES for results"
# Try a few times to check if we have the correct number of events stored
# in ES.
#
# We try multiple times to allow final agent flushes as well as allowing
# elasticsearch to finish processing everything.
Stud::try(10.times) do
ftw = FTW::Agent.new
data = ""
response = ftw.get!("http://127.0.0.1:9200/#{index}/_count?q=*")
@ -45,6 +47,8 @@ describe LogStash::Outputs::ElasticSearchHTTP do
count = JSON.parse(data)["count"]
insist { count } == event_count
end
puts "Rate: #{event_count / @duration}/sec (flush_size: #{flush_size})"
end
end
end