vivo/utilities/LoadTesting/scripts/_runTest

97 lines
3.3 KiB
Text
Raw Normal View History

#! /usr/bin/ruby
=begin
--------------------------------------------------------------------------------
Try to connect to the webapp. If we can't connect, then give up.
Run the JMeter test with appropriate parameters.
Use XSL to create an HTML version of the results.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
=end
require File.expand_path('subscripts/common', File.dirname(__FILE__))
def locate_files()
test_full_name = "#{@test_name}#{@test_suffix}"
test_source_dir = test_file("tests/#{@test_name}")
@test_jmx_file = "#{test_source_dir}/#{test_full_name}.jmx"
raise "Test file doesn't exist: '#{@test_jmx_file}'." unless File.file?(@test_jmx_file)
result_dir = test_file("results/#{@site_name}")
Dir.mkdir(result_dir) unless File.directory?(result_dir)
@test_jtl_file = "#{result_dir}/#{test_full_name}.jtl"
File.delete(@test_jtl_file) if File.file?(@test_jtl_file)
@test_log_file = "#{result_dir}/#{test_full_name}.log"
File.delete(@test_log_file) if File.file?(@test_log_file)
@test_html_file = "#{result_dir}/#{test_full_name}.html"
File.delete(@test_html_file) if File.file?(@test_html_file)
data_dir = "#{@home}/modelData/#{@site_name}"
@person_uris_file = "#{data_dir}/personUris.csv"
raise "Person URIs file doesn't exist: '#{@person_uris_file}'" unless File.file?(@person_uris_file)
@infoResource_uris_file = "#{data_dir}/infoResourceUris.csv"
raise "InfoResource URIs file doesn't exist: '#{@infoResource_uris_file}'" unless File.file?(@infoResource_uris_file)
@author_uris_file = "#{data_dir}/authorUris.csv"
raise "Author URIs file doesn't exist: '#{@author_uris_file}'" unless File.file?(@author_uris_file)
@xsl_stylesheet_file = "/home/jeb228/LoadTesting/jmeter/jakarta-jmeter-2.4/extras/jmeter-results-report_21.xsl"
end
def prepare_jmeter_properties()
props = {}
# set parameters for the tests
props["webapp.host"] = "localhost"
props["webapp.port"] = "6080"
props["webapp.name"] = "vivo"
props["iterations"] = @test_iterations
props["threads"] = @test_threads
props["file.person.uris"] = @person_uris_file
props["file.infoResource.uris"] = @infoResource_uris_file
props["file.author.uris"] = @author_uris_file
props["default.namespace"] = @default_namespace
# set parameters for the output
props["jmeter.save.saveservice.output_format"] = "xml"
props["jmeter.save.saveservice.response_data.on_error"] = "true"
props["jmeter.save.saveservice.url"] = "true"
props["jmeter.save.saveservice.bytes"] = "true"
# show a summary line periodically, so we know it's running. -->
props["summariser.name"] = "summary"
props["summariser.out"] = "true"
props["summariser.log"] = "true"
props["summariser.interval"] = "10"
@jmeter_properties = ""
props.each() do |key, value|
@jmeter_properties << "-J#{key}=#{value} "
end
end
def test_the_webapp()
puts "BOGUS test_the_webapp()"
end
locate_files()
prepare_jmeter_properties()
test_the_webapp()
Dir.chdir("/home/jeb228/LoadTesting/jmeter/jakarta-jmeter-2.4/bin") do |path|
puts "RUNNING TESTS"
system "./jmeter -n -t #{@test_jmx_file} -l #{@test_jtl_file} -j #{@test_log_file} #{@jmeter_properties}"
puts "CONVERTING TO HTML"
system "xsltproc -o #{@test_html_file} #{@xsl_stylesheet_file} #{@test_jtl_file}"
end