2010-03-11 19:00:32 +00:00
|
|
|
=begin
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Stop the Vitro application, delete all MySQL tables from the Vitro database, and
|
|
|
|
start the application again.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
tomcat_stop_command
|
|
|
|
A "shell" command that will stop the Tomcat server.
|
|
|
|
tomcat_stop_delay
|
|
|
|
Number of seconds to wait after the tomcat_stop_command returns before
|
|
|
|
proceeding.
|
|
|
|
tomcat_start_command
|
|
|
|
A "shell" command that will start the Tomcat server.
|
|
|
|
tomcat_start_delay
|
|
|
|
Number of seconds to wait after the tomcat_start_command returns before
|
|
|
|
proceeding.
|
|
|
|
mysql_username
|
|
|
|
A user account that has authority to drop the Vitro database in MySQL.
|
|
|
|
mysql_password
|
|
|
|
The password for mysql_username.
|
|
|
|
database_name
|
|
|
|
The name of the Vitro database in MySQL.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
=end
|
2010-03-12 20:28:47 +00:00
|
|
|
require 'date'
|
|
|
|
require 'fileutils'
|
|
|
|
require File.expand_path('output_suite_parser', File.dirname(File.expand_path(__FILE__)))
|
|
|
|
require File.expand_path('output_summary_formatter', File.dirname(File.expand_path(__FILE__)))
|
|
|
|
|
|
|
|
class TestInfo
|
|
|
|
attr :test_name, true
|
|
|
|
attr :suite_name, true
|
|
|
|
attr :output_link, true
|
|
|
|
attr :status, true
|
|
|
|
end
|
|
|
|
|
|
|
|
class SuiteInfo
|
|
|
|
attr :name, true
|
|
|
|
attr :output_link, true
|
|
|
|
attr :status, true
|
|
|
|
end
|
|
|
|
|
|
|
|
class Status
|
|
|
|
GOOD = 0
|
|
|
|
BAD = 1
|
|
|
|
FAIR = 2
|
|
|
|
def self.html_class(status)
|
|
|
|
return %w{good bad fair}[status]
|
|
|
|
end
|
|
|
|
end
|
2010-03-11 19:00:32 +00:00
|
|
|
|
|
|
|
class OutputManager
|
|
|
|
# ------------------------------------------------------------------------------------
|
|
|
|
private
|
|
|
|
# ------------------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Confirm that the output directory parameter is reasonable.
|
|
|
|
#
|
|
|
|
def sanity_checks_on_parameters()
|
|
|
|
if @output_directory == nil
|
|
|
|
raise("Properties file must contain a value for 'output_directory'")
|
|
|
|
end
|
|
|
|
|
|
|
|
if !File.exist?(@output_directory)
|
|
|
|
raise "Output directory '#{@output_directory}' does not exist."
|
|
|
|
end
|
|
|
|
|
|
|
|
if !File.readable?(@output_directory)
|
|
|
|
raise "Output directory '#{@output_directory}' is not readable."
|
|
|
|
end
|
|
|
|
|
|
|
|
if !File.directory?(@output_directory)
|
|
|
|
raise "Output directory '#{@output_directory}' is not a directory."
|
|
|
|
end
|
|
|
|
|
|
|
|
if !File.writable?(@output_directory)
|
|
|
|
raise "Output directory '#{@output_directory}' is not writable."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-03-12 20:28:47 +00:00
|
|
|
# The CSS file for the output summary exists in the script directory.
|
|
|
|
# Copy it to the output directory.
|
|
|
|
#
|
|
|
|
def copy_css_file()
|
|
|
|
source = File.expand_path('output_summary.css', File.dirname(File.expand_path(__FILE__)))
|
|
|
|
dest = File.expand_path('summary.css', @output_directory)
|
|
|
|
FileUtils::copy_file(source, dest)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write the beginning of the summary file.
|
|
|
|
# This includes the HTML header, and the banner.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_header(f)
|
|
|
|
if @osp.overall_status == Status::BAD
|
|
|
|
overall_status = "FAILURE"
|
|
|
|
else
|
|
|
|
overall_status = "SUCCESS"
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print <<END_HEADER
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Summary of Acceptance Tests #{@osp.start_time}</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="summary.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div class="heading">
|
|
|
|
Acceptance test results: 3:45 p.m. March 10, 2010
|
|
|
|
<div class="#{Status::html_class(@osp.overall_status)} one-word">#{overall_status}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
END_HEADER
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write the first section of the summary file. This section contains
|
|
|
|
# nested tables with fixed formats, containing overall stats.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_stats_section(f)
|
|
|
|
how_many_tests = @osp.tests.length
|
|
|
|
how_many_pass = 0
|
|
|
|
how_many_fail = 0
|
|
|
|
how_many_ignore = 0
|
|
|
|
@osp.tests.each do |t|
|
|
|
|
how_many_pass += 1 if t.status == Status::GOOD
|
|
|
|
how_many_ignore += 1 if t.status == Status::FAIR
|
|
|
|
how_many_fail += 1 if t.status == Status::BAD
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print <<END_STATS
|
|
|
|
<div class="section">Summary</div>
|
|
|
|
|
|
|
|
<table class="summary" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<table cellspacing="0">
|
|
|
|
<tr><td>Start time:</td><td>#{@osp.start_time}</td></tr>
|
|
|
|
<tr><td>End time</td><td>#{@osp.end_time}</td></tr>
|
|
|
|
<tr><td>Elapsed time</td><td>#{@osp.elapsed_time}</td></tr>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<table cellspacing="0">
|
|
|
|
<tr><td>Suites</td><td>#{@osp.suites.length}</td></tr>
|
|
|
|
<tr><td>Total tests</td><td>#{@osp.tests.length}</td></tr>
|
|
|
|
<tr class="good"><td>Passing tests</td><td>#{how_many_pass}</td></tr>
|
|
|
|
<tr class="bad"><td>Failing tests</td><td>#{how_many_fail}</td></tr>
|
|
|
|
<tr class="fair"><td>Ignored tests</td><td>#{how_many_ignore}</td></tr>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
END_STATS
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write a table of failed tests to the summary file, with links
|
|
|
|
# to the detailed output for each test.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_failure_section(f)
|
|
|
|
fails = []
|
|
|
|
@osp.tests.each do |t|
|
|
|
|
fails << t if t.status == Status::BAD
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print " <div class=section>Failing tests</div>\n\n <table cellspacing=\"0\">\n"
|
|
|
|
f.print " <tr><th>Suite name</th><th>Test name</th></tr>\n"
|
|
|
|
|
|
|
|
if fails.empty?
|
|
|
|
f.print " <tr>\n"
|
|
|
|
f.print " <td colspan=\"2\">No tests failed.</td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
else
|
|
|
|
fails.each do |t|
|
|
|
|
f.print " <tr class=\"#{Status::html_class(t.status)}\">\n"
|
|
|
|
f.print " <td>#{t.suite_name}</td>\n"
|
|
|
|
f.print " <td><a href=\"#{t.output_link}\">#{t.test_name}</a></td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print " </table>\n\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write a table of ignored tests to the summary file, with links
|
|
|
|
# to the detailed output for each test.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_ignore_section(f)
|
|
|
|
ignores = []
|
|
|
|
@osp.tests.each do |t|
|
|
|
|
ignores << t if t.status == Status::FAIR
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print " <div class=section>Ignored tests</div>\n\n <table cellspacing=\"0\">\n"
|
|
|
|
f.print " <tr><th>Suite name</th><th>Test name</th></tr>\n"
|
|
|
|
|
|
|
|
if ignores.empty?
|
|
|
|
f.print " <tr>\n"
|
|
|
|
f.print " <td colspan=\"2\">No tests ignored.</td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
else
|
|
|
|
ignores.each do |t|
|
|
|
|
f.print " <tr class=\"#{Status::html_class(t.status)}\">\n"
|
|
|
|
f.print " <td>#{t.suite_name}</td>\n"
|
|
|
|
f.print " <td><a href=\"#{t.output_link}\">#{t.test_name}</a></td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print " </table>\n\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write a table of any error messages or warnings found in the log file.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_error_messages_section(f)
|
|
|
|
f.print " <div class=section>Errors and warnings</div>\n"
|
|
|
|
f.print " <table cellspacing=\"0\">"
|
|
|
|
|
|
|
|
if @osp.errors.empty? && @osp.warnings.empty?
|
|
|
|
f.print " <tr><td colspan=\"2\">No errors or warnings</td></tr>"
|
|
|
|
else
|
|
|
|
@osp.errors.each() do |e|
|
|
|
|
f.print " <tr class=\"bad\"><td>ERROR</td><td>#{e}</td></tr>"
|
|
|
|
end
|
|
|
|
@osp.warnings.each() do |w|
|
|
|
|
f.print " <tr class=\"fair\"><td>WARN</td><td>#{w}</td></tr>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
f.print " </table>\n\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write a table of the suites to the summary file, with links
|
|
|
|
# to the detailed output for each suite.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_suites_section(f)
|
|
|
|
f.print " <div class=section>Suites</div>\n"
|
|
|
|
f.print " <table cellspacing=\"0\">\n"
|
|
|
|
|
|
|
|
@osp.suites.each() do |s|
|
|
|
|
f.print " <tr class=\"#{Status::html_class(s.status)}\">\n"
|
|
|
|
f.print " <td><a href=\"#{s.output_link}\">#{s.name}</a></td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
end
|
|
|
|
f.print " </table>\n\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write a table of all tests to the summary file, with links
|
|
|
|
# to the detailed output for each test.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_all_tests_section(f)
|
|
|
|
f.print " <div class=section>All tests</div>\n\n <table cellspacing=\"0\">\n"
|
|
|
|
f.print " <tr><th>Suite name</th><th>Test name</th></tr>\n"
|
|
|
|
|
|
|
|
if @osp.tests.empty?
|
|
|
|
f.print " <tr>\n"
|
|
|
|
f.print " <td colspan=\"2\">No tests.</td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
else
|
|
|
|
@osp.tests.each do |t|
|
|
|
|
f.print " <tr class=\"#{Status::html_class(t.status)}\">\n"
|
|
|
|
f.print " <td>#{t.suite_name}</td>\n"
|
|
|
|
f.print " <td><a href=\"#{t.output_link}\">#{t.test_name}</a></td>\n"
|
|
|
|
f.print " </tr>\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
f.print " </table>\n\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Copy the log to the summary file, and close the HTML tags.
|
|
|
|
#
|
|
|
|
# f -- a file, already open for output.
|
|
|
|
#
|
|
|
|
def write_summary_footer(f)
|
|
|
|
f.print " <div class=section>Log</div>\n <pre>\n"
|
|
|
|
File.open(@log_file) do |log|
|
|
|
|
FileUtils::copy_stream(log, f)
|
|
|
|
end
|
|
|
|
f.print " </pre>\n</body>\n</html>\n\n"
|
|
|
|
end
|
|
|
|
|
2010-03-11 19:00:32 +00:00
|
|
|
# ------------------------------------------------------------------------------------
|
|
|
|
public
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------
|
|
|
|
# Set up and get ready to process.
|
|
|
|
#
|
|
|
|
def initialize(properties)
|
|
|
|
@output_directory = properties['output_directory']
|
|
|
|
|
|
|
|
sanity_checks_on_parameters()
|
|
|
|
|
|
|
|
@log_file = File.expand_path("log_file.txt", @output_directory)
|
2010-03-12 20:28:47 +00:00
|
|
|
FileUtils::remove_file(@log_file) if File.exist?(@log_file)
|
|
|
|
|
2010-03-11 19:00:32 +00:00
|
|
|
@output_summary_file = File.expand_path("summary.html", @output_directory)
|
2010-03-12 20:28:47 +00:00
|
|
|
FileUtils::remove_file(@output_summary_file) if File.exist?(@output_summary_file)
|
2010-03-11 19:00:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Write a message to the log file
|
|
|
|
#
|
|
|
|
def log(level, message)
|
|
|
|
File.open(@log_file, File::CREAT | File::APPEND | File::WRONLY) do |f|
|
|
|
|
f.print("#{level} #{message}\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def output_filename(suite_name)
|
|
|
|
File.expand_path("#{suite_name}_output.html", @output_directory)
|
|
|
|
end
|
|
|
|
|
2010-03-12 20:28:47 +00:00
|
|
|
def ignore_test?(suite_name, test_name)
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2010-03-11 19:00:32 +00:00
|
|
|
def summarize()
|
2010-03-12 20:28:47 +00:00
|
|
|
@osp = OutputSuiteParser.new(self, @log_file)
|
|
|
|
@osp.parse()
|
|
|
|
|
|
|
|
copy_css_file()
|
|
|
|
File.open(@output_summary_file, File::CREAT | File::WRONLY) do |f|
|
|
|
|
osf = OutputSummaryFormatter.new(@osp, @log_file)
|
|
|
|
osf.format(f)
|
|
|
|
|
|
|
|
write_summary_header(f)
|
|
|
|
write_summary_stats_section(f)
|
|
|
|
write_error_messages_section(f)
|
|
|
|
write_summary_failure_section(f)
|
|
|
|
write_summary_ignore_section(f)
|
|
|
|
write_summary_suites_section(f)
|
|
|
|
write_summary_all_tests_section(f)
|
|
|
|
write_summary_footer(f)
|
|
|
|
end
|
2010-03-11 19:00:32 +00:00
|
|
|
end
|
|
|
|
end
|