NIHVIVO-76 Add a step that empties the upload area as well as the database.
This commit is contained in:
parent
e8f5f0ffc0
commit
e81d304489
4 changed files with 101 additions and 4 deletions
|
@ -42,6 +42,7 @@ class DatabaseCleanser
|
|||
raise("Properties file must contain a value for 'tomcat_stop_delay'") if @tomcat_stop_delay == nil
|
||||
raise("Properties file must contain a value for 'tomcat_start_command'") if @tomcat_start_command == nil
|
||||
raise("Properties file must contain a value for 'tomcat_start_delay'") if @tomcat_start_delay == nil
|
||||
raise("Properties file must contain a value for 'website_url'") if @website_url == nil
|
||||
raise("Properties file must contain a value for 'mysql_username'") if @mysql_username == nil
|
||||
raise("Properties file must contain a value for 'mysql_password'") if @mysql_password == nil
|
||||
raise("Properties file must contain a value for 'database_name'") if @database_name == nil
|
||||
|
@ -76,7 +77,12 @@ class DatabaseCleanser
|
|||
system(@tomcat_start_command)
|
||||
puts " Waiting #{@tomcat_start_delay} seconds..."
|
||||
sleep(@tomcat_start_delay)
|
||||
open("http://localhost:8080"){|f|}
|
||||
begin
|
||||
open(@website_url){|f|}
|
||||
rescue Timeout::Error
|
||||
puts ">>> HTTP request timed out!"
|
||||
raise
|
||||
end
|
||||
puts " ... started."
|
||||
end
|
||||
|
||||
|
@ -105,6 +111,7 @@ class DatabaseCleanser
|
|||
@tomcat_stop_delay = properties['tomcat_stop_delay'].to_i
|
||||
@tomcat_start_command = properties['tomcat_start_command']
|
||||
@tomcat_start_delay = properties['tomcat_start_delay'].to_i
|
||||
@website_url = properties['website_url']
|
||||
@mysql_username = properties['mysql_username']
|
||||
@mysql_password = properties['mysql_password']
|
||||
@database_name = properties['database_name']
|
||||
|
|
|
@ -19,3 +19,4 @@ tomcat_start_delay = 180
|
|||
mysql_username = vitrodbUsername
|
||||
mysql_password = vitrodbPassword
|
||||
database_name = vivo
|
||||
upload_directory = /usr/local/vivo/data/uploads
|
|
@ -40,6 +40,7 @@ What are we doing?
|
|||
require 'open-uri'
|
||||
require 'date'
|
||||
require File.expand_path('database_cleanser', File.dirname(File.expand_path(__FILE__)))
|
||||
require File.expand_path('upload_area_cleanser', File.dirname(File.expand_path(__FILE__)))
|
||||
require File.expand_path('property_file_reader', File.dirname(File.expand_path(__FILE__)))
|
||||
require File.expand_path('output_manager', File.dirname(File.expand_path(__FILE__)))
|
||||
|
||||
|
@ -155,7 +156,7 @@ class AcceptanceRunner
|
|||
get_sub_directories(@test_root_directory).each do |suite_path|
|
||||
suite_file_path = File.expand_path("Suite.html", suite_path)
|
||||
if File.exist?(suite_file_path)
|
||||
cleanse_data_model()
|
||||
cleanse_the_model()
|
||||
run_test_suite(suite_file_path)
|
||||
else
|
||||
log_warn("No suite file found in #{suite_path}")
|
||||
|
@ -164,9 +165,10 @@ class AcceptanceRunner
|
|||
time_stamp("End time")
|
||||
end
|
||||
|
||||
# Before each suite, call the cleanser.
|
||||
def cleanse_data_model()
|
||||
# Before each suite, call the cleansers.
|
||||
def cleanse_the_model()
|
||||
@database_cleanser.cleanse()
|
||||
@upload_area_cleanser.cleanse()
|
||||
end
|
||||
|
||||
def run_test_suite(suite_file_path)
|
||||
|
@ -222,6 +224,7 @@ class AcceptanceRunner
|
|||
sanity_checks_on_parameters()
|
||||
|
||||
@database_cleanser = DatabaseCleanser.new(properties)
|
||||
@upload_area_cleanser = UploadAreaCleanser.new(properties)
|
||||
|
||||
@output_manager = OutputManager.new(properties)
|
||||
@output_manager.empty_log()
|
||||
|
|
86
utilities/acceptance-tests/script/upload_area_cleanser.rb
Normal file
86
utilities/acceptance-tests/script/upload_area_cleanser.rb
Normal file
|
@ -0,0 +1,86 @@
|
|||
=begin
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Remove any files from the VIVO upload area, so we have a clean area for the next
|
||||
suite of tests.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Parameters:
|
||||
upload_directory
|
||||
The path to the upload area.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
=end
|
||||
require 'fileutils'
|
||||
require File.expand_path('property_file_reader', File.dirname(File.expand_path(__FILE__)))
|
||||
|
||||
class UploadAreaCleanser
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
#
|
||||
# Confirm that the parameters are reasonable.
|
||||
#
|
||||
def sanity_checks_on_parameters()
|
||||
# Check that all necessary properties are here.
|
||||
raise("Properties file must contain a value for 'upload_directory'") if @upload_directory == nil
|
||||
|
||||
if !File.exist?(@upload_directory)
|
||||
raise "Upload directory '#{@upload_directory}' does not exist."
|
||||
end
|
||||
|
||||
if !File.readable?(@upload_directory)
|
||||
raise "Upload directory '#{@upload_directory}' is not readable."
|
||||
end
|
||||
|
||||
if !File.directory?(@upload_directory)
|
||||
raise "Upload directory '#{@upload_directory}' is not a directory."
|
||||
end
|
||||
|
||||
if !File.writable?(@upload_directory)
|
||||
raise "Upload directory '#{@upload_directory}' is not writable."
|
||||
end
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
# Get the parameters and check them
|
||||
#
|
||||
def initialize(properties)
|
||||
@upload_directory = properties['upload_directory']
|
||||
sanity_checks_on_parameters()
|
||||
end
|
||||
|
||||
# Cleanse the directory
|
||||
#
|
||||
def cleanse()
|
||||
FileUtils::rm_r(Dir.glob(File.expand_path('*', @upload_directory)), :verbose=>true)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
# ------------------------------------------------------------------------------------
|
||||
# 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 File.expand_path($0) == File.expand_path(__FILE__)
|
||||
if ARGV.length == 0
|
||||
raise("No arguments - usage is: ruby upload_area_cleanser.rb <properties_file>")
|
||||
end
|
||||
if !File.file?(ARGV[0])
|
||||
raise "File does not exist: '#{ARGV[0]}'."
|
||||
end
|
||||
|
||||
properties = PropertyFileReader.read(ARGV[0])
|
||||
|
||||
uac = UploadAreaCleanser.new(properties)
|
||||
uac.cleanse()
|
||||
end
|
Loading…
Add table
Reference in a new issue