forked from elastic/logstash-performance-testing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
suite.rb
46 lines (33 loc) · 1.19 KB
/
suite.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# encoding: utf-8
require_relative 'run'
RUNNER = File.join(File.expand_path(File.dirname(__FILE__)), "run.rb")
BASE_DIR = File.expand_path(File.dirname(__FILE__))
## script main
if ARGV.size < 1 or ARGV.size > 2
$stderr.puts("usage: ruby suite.rb [suite file] [logstash path]")
exit(1)
end
@debug = !!ENV["DEBUG"]
logstash_home = ENV['LOGSTASH_HOME'] || 'logstash'
install_path = ARGV.size > 1 ? ARGV[1] : logstash_home
tests = eval(IO.read(ARGV[0]))
lines = ["name, #{Runner.headers.join(',')}"]
first = true
reporter = Thread.new do
loop do
$stderr.print "."
sleep 1
end
end
tests.each do |test|
events = test[:events].to_i # total number of events to feed, independant of input file size
time = test[:time].to_i
config = File.join(BASE_DIR, test[:config])
input = File.join(BASE_DIR, test[:input])
runner = Runner.new(config, @debug, install_path)
p, elaspsed, events_count = runner.run(events, time, runner.read_input_file(input))
lines << "#{test[:name]}, #{"%.2f" % elaspsed}, #{events_count}, #{"%.0f" % (events_count / elaspsed)},#{p.last}, #{"%.0f" % (p.reduce(:+) / p.size)}"
first = false
end
reporter.kill
puts lines.join("\n")