NIHVIVO-76 Getting closer. Force tomcat to restart, waiting as long as necessary. Add "setup" test to each suite, in lieu of getting a "test model" in place.

This commit is contained in:
jeb228 2010-03-08 22:21:13 +00:00
parent a9e77b0c66
commit 7bcfc0e9dd
5 changed files with 420 additions and 395 deletions

View file

@ -27,7 +27,7 @@ Parameters:
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
=end =end
require 'open-uri' require 'open-uri'
require 'property_file_reader' require File.expand_path('property_file_reader', File.dirname(File.expand_path(__FILE__)))
class DatabaseCleanser class DatabaseCleanser
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
@ -51,7 +51,7 @@ class DatabaseCleanser
args << "--user=#{@mysql_username}" args << "--user=#{@mysql_username}"
args << "--password=#{@mysql_password}" args << "--password=#{@mysql_password}"
args << "--database=#{@database_name}" args << "--database=#{@database_name}"
args << "--version" args << "--execute=show databases;"
result = system("mysql", *args) result = system("mysql", *args)
raise("Can't find the 'mysql' command!") if result == nil raise("Can't find the 'mysql' command!") if result == nil
raise("Can't connect to MySQL database.") if !result raise("Can't connect to MySQL database.") if !result
@ -125,16 +125,22 @@ end
# #
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# Standalone calling. # Standalone calling.
#
# Do this if this program was called from the command line. That is, if the command
# expands to the path of this file.
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# #
if ARGV.length == 0
raise("No arguments - usage is: database_cleanser.rb <properties_file>")
end
if !File.file?(ARGV[0])
raise "File does not exist: '#{ARGV[0]}'."
end
properties = PropertyFileReader.read(ARGV[0]) if File.expand_path($0) == File.expand_path(__FILE__)
if ARGV.length == 0
raise("No arguments - usage is: ruby database_cleanser.rb <properties_file>")
end
if !File.file?(ARGV[0])
raise "File does not exist: '#{ARGV[0]}'."
end
dc = DatabaseCleanser.new(properties) properties = PropertyFileReader.read(ARGV[0])
dc.cleanse()
dc = DatabaseCleanser.new(properties)
dc.cleanse()
end

View file

@ -1,6 +1,19 @@
webapp_url = http://localhost:8080/vivo/ #
tomcat_username = tomcat # These properties tell how to set up Selenium to run a test suite.
tomcat_password = tomcat #
mysql_username = vitrodbUsername website_url = http://localhost:8080/vivo/
mysql_password = vitrodbPassword test_root_directory = C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\suites
database_name = vivo output_directory = C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\script\\output
user_extensions_path = C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\selenium\\user-extensions.js
firefox_profile_template_path = C:\\Vitro_stuff\\Selenium\\experiments\\profiles\\selenium
#
# These properties are needed to cleanse the data model between test suites.
#
tomcat_stop_command = java -Dcatalina.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0" -jar "c:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\bootstrap.jar" stop
tomcat_stop_delay = 3
tomcat_start_command = start java -Dcatalina.home="C:\Program Files\Apache Software Foundation\Tomcat 6.0" -jar "C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\bootstrap.jar"
tomcat_start_delay = 180
mysql_username = vitrodbUsername
mysql_password = vitrodbPassword
database_name = vivo

View file

@ -38,7 +38,8 @@ What are we doing?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
=end =end
require 'open-uri' require 'open-uri'
require 'database_cleanser' require File.expand_path('database_cleanser', File.dirname(File.expand_path(__FILE__)))
require File.expand_path('property_file_reader', File.dirname(File.expand_path(__FILE__)))
=begin =begin
<h1>Test suite results </h1> <h1>Test suite results </h1>
@ -76,6 +77,14 @@ class AcceptanceRunner
# and URL. # and URL.
# #
def sanity_checks_on_parameters() def sanity_checks_on_parameters()
raise("Properties file must contain a value for 'website_url'") if @website_url == nil
raise("Properties file must contain a value for 'test_root_directory'") if @test_root_directory == nil
raise("Properties file must contain a value for 'output_directory'") if @output_directory == nil
raise("Properties file must contain a value for 'user_extensions_path'") if @user_extensions_path == nil
raise("Properties file must contain a value for 'firefox_profile_template_path'") if @firefox_profile_template_path == nil
raise("Properties file must contain a value for 'suite_timeout_limit'") if @suite_timeout_limit == nil
raise("Properties file must contain a value for 'selenium_jar_path'") if @selenium_jar_path == nil
confirm_is_readable_directory(@test_root_directory, "Test root directory") confirm_is_readable_directory(@test_root_directory, "Test root directory")
if get_sub_directories(@test_root_directory).empty? if get_sub_directories(@test_root_directory).empty?
raise "Test root directory '#{@test_root_directory}' has no sub-directories." raise "Test root directory '#{@test_root_directory}' has no sub-directories."
@ -147,36 +156,77 @@ class AcceptanceRunner
# #
def run_all_suites() def run_all_suites()
get_sub_directories(@test_root_directory).each do |suite_path| get_sub_directories(@test_root_directory).each do |suite_path|
cleanse_data_model() suite_file_path = File.expand_path("Suite.html", suite_path)
run_test_suite(suite_path) if File.exist?(suite_file_path)
cleanse_data_model()
run_test_suite(suite_file_path)
end
end end
end end
# Before each suite, call the cleanser.
def cleanse_data_model() def cleanse_data_model()
puts "BOGUS cleanse_data_model()" # puts "BOGUS cleanse_data_model()"
@database_cleanser.cleanse()
end end
def run_test_suite(suite_path) def run_test_suite(suite_file_path)
puts "BOGUS run_test_suite()" puts "BOGUS run_test_suite(#{suite_file_path})"
suite_name = File.basename(File.dirname(suite_file_path))
output_file = File.expand_path("#{suite_name}_output.html", @output_directory)
args = []
args << "-jar" << @selenium_jar_path
args << "-singleWindow"
args << "-timeout" << @suite_timeout_limit.to_s
args << "-userExtensions" << @user_extensions_path
args << "-firefoxProfileTemplate" << @firefox_profile_template_path
args << "-htmlSuite" << "*firefox" << @website_url << suite_file_path << output_file
result = system("java", *args)
raise("Can't find the 'java' command!") if result == nil
if !result
puts ">>>> result: #{result}"
puts ">>>> $?: #{$?}"
log_error("Can't run the suite at '#{suite_file_path}: command was 'java' #{args}") if !result
elsif $?.exitstatus != 0
log_error("Suite failed at '#{suite_file_path}: return code was #{$?.exitstatus}, command was 'java' #{args}")
end
end end
def create_summary_html() def create_summary_html()
puts "BOGUS create_summary_html()" puts "BOGUS create_summary_html()"
end end
def log_error(message)
File.open(@log_file, File::CREAT | File::APPEND | File::WRONLY) do |f|
f.print(message + "\n")
end
puts "LOG LOG: '#{message}'"
end
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
public public
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# Set up and get ready to process. # Set up and get ready to process.
# #
def initialize(website_url, test_root_directory, output_directory, user_extensions_path, firefox_profile_template_path) def initialize(properties)
@website_url = website_url @website_url = properties['website_url']
@test_root_directory = test_root_directory @test_root_directory = properties['test_root_directory']
@output_directory = output_directory @output_directory = properties['output_directory']
@user_extensions_path = user_extensions_path @user_extensions_path = properties['user_extensions_path']
@firefox_profile_template_path = firefox_profile_template_path @firefox_profile_template_path = properties['firefox_profile_template_path']
@suite_timeout_limit = properties['suite_timeout_limit'].to_i
@selenium_jar_path = properties['selenium_jar_path']
sanity_checks_on_parameters() sanity_checks_on_parameters()
@database_cleanser = DatabaseCleanser.new(properties)
@log_file = File.expand_path("log_file.txt", @output_directory)
end end
# Run all of the test suites and produce an output summary page. # Run all of the test suites and produce an output summary page.
@ -186,16 +236,20 @@ class AcceptanceRunner
end end
end end
# ------------------------------------------------------------------------ #
# Main routine #
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# Standalone calling.
# ------------------------------------------------------------------------------------
#
if ARGV.length == 0
raise("No arguments - usage is: ruby run_acceptance_test.rb <properties_file>")
end
if !File.file?(ARGV[0])
raise "File does not exist: '#{ARGV[0]}'."
end
# BOGUS test harness properties = PropertyFileReader.read(ARGV[0])
website_url = "http://localhost:8080/vivo/"
test_root_directory = "C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\suites"
output_directory = "C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\script\\output"
user_extensions_path = "C:\\eclipseVitroWorkspace\\vivoweb\\utilities\\acceptance-tests\\selenium\\user-extensions.js"
firefox_profile_template_path = "C:\\Vitro_stuff\\Selenium\\experiments\\profiles\\selenium"
ar = AcceptanceRunner.new(website_url, test_root_directory, output_directory, user_extensions_path, firefox_profile_template_path) ar = AcceptanceRunner.new(properties)
ar.run() ar.run()

View file

@ -10,5 +10,5 @@ SET SEL_OPTS=%SEL_OPTS% -htmlSuite "*firefox" "http://localhost:8080/vivo/" "..
SET Path=%Path%;C:\Program Files (x86)\Mozilla Firefox SET Path=%Path%;C:\Program Files (x86)\Mozilla Firefox
@echo on @echo on
java -jar selenium-server.jar %SEL_OPTS% java -jar ..\selenium\selenium-server.jar %SEL_OPTS%

File diff suppressed because it is too large Load diff