From ec0a12384994774522380165302934531ca12901 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 28 Mar 2016 13:54:08 -0400 Subject: [PATCH] Unify and simplify how Galaxy is launched across test drivers. --- scripts/functional_tests.py | 49 ++---------------------------- test/tool_shed/functional_tests.py | 15 +++++---- 2 files changed, 11 insertions(+), 53 deletions(-) diff --git a/scripts/functional_tests.py b/scripts/functional_tests.py index c04fc9d4201..25808a65901 100644 --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -9,7 +9,6 @@ import os import os.path import sys import tempfile -from ConfigParser import SafeConfigParser galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) sys.path[1:1] = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ] @@ -28,40 +27,6 @@ from galaxy.web import buildapp default_galaxy_test_host = "localhost" -def generate_config_file( input_filename, output_filename, config_items ): - """Generate a config file with the configuration that has been defined for the embedded web application. - - This is mostly relevant when setting metadata externally, since the script for doing that does not - have access to app.config. - """ - cp = SafeConfigParser() - cp.read( input_filename ) - config_items_by_section = [] - for label, value in config_items: - found = False - # Attempt to determine the correct section for this configuration option. - for section in cp.sections(): - if cp.has_option( section, label ): - config_tuple = section, label, value - config_items_by_section.append( config_tuple ) - found = True - continue - # Default to app:main if no section was found. - if not found: - config_tuple = 'app:main', label, value - config_items_by_section.append( config_tuple ) - print( config_items_by_section ) - - # Replace the default values with the provided configuration. - for section, label, value in config_items_by_section: - if cp.has_option( section, label ): - cp.remove_option( section, label ) - cp.set( section, label, str( value ) ) - fh = open( output_filename, 'w' ) - cp.write( fh ) - fh.close() - - def main(): """Entry point for test driver script.""" # ---- Configuration ------------------------------------------------------ @@ -143,20 +108,10 @@ def main(): kwargs.update(galaxy_config) if datatypes_conf_override: kwargs[ 'datatypes_config_file' ] = datatypes_conf_override - # If the user has passed in a path for the .ini file, do not overwrite it. - galaxy_config_file = os.environ.get( 'GALAXY_TEST_INI_FILE', None ) - if not galaxy_config_file: - galaxy_config_file = os.path.join( galaxy_test_tmp_dir, 'functional_tests_wsgi.ini' ) - config_items = [] - for label in kwargs: - config_tuple = label, kwargs[ label ] - config_items.append( config_tuple ) - # Write a temporary file, based on config/galaxy.ini.sample, using the configuration options defined above. - generate_config_file( 'config/galaxy.ini.sample', galaxy_config_file, config_items ) + # Set the global_conf[ '__file__' ] option to the location of the temporary .ini file, which gets passed to set_metadata.sh. kwargs[ 'global_conf' ] = driver_util.get_webapp_global_conf() - kwargs[ 'global_conf' ][ '__file__' ] = galaxy_config_file - kwargs[ 'config_file' ] = galaxy_config_file + kwargs[ 'global_conf' ][ '__file__' ] = "config/galaxy.ini.sample" kwargs = load_app_properties( kwds=kwargs ) diff --git a/test/tool_shed/functional_tests.py b/test/tool_shed/functional_tests.py index d57d13a513d..db25e0b8379 100644 --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -25,6 +25,7 @@ from galaxy.webapps.tool_shed.app import UniverseApplication as ToolshedUniverse # This is for the galaxy application. from galaxy.app import UniverseApplication as GalaxyUniverseApplication from galaxy.web import buildapp as galaxybuildapp +from galaxy.util.properties import load_app_properties from functional import database_contexts @@ -157,11 +158,7 @@ def main(): # Generate shed_data_manager_conf.xml if not os.environ.get( 'GALAXY_SHED_DATA_MANAGER_CONF' ): open( galaxy_shed_data_manager_conf_file, 'wb' ).write( shed_data_manager_conf_xml_template ) - galaxy_global_conf = driver_util.get_webapp_global_conf() - galaxy_global_conf[ '__file__' ] = 'config/galaxy.ini.sample' - kwargs = dict( enable_tool_shed_check=True, - global_conf=galaxy_global_conf, hours_between_check=0.001, migrated_tools_config=galaxy_migrated_tool_conf_file, shed_data_manager_config_file=galaxy_shed_data_manager_conf_file, @@ -173,14 +170,20 @@ def main(): tool_data_table_config_path=galaxy_tool_data_table_conf_file ) kwargs.update(driver_util.setup_galaxy_config(galaxy_db_path, use_test_file_dir=False, default_install_db_merged=False)) print "Galaxy database connection:", kwargs["database_connection"] - # ---- Build Galaxy Application -------------------------------------------------- + # Set the global_conf[ '__file__' ] option to the location of the temporary .ini file, which gets passed to set_metadata.sh. + kwargs[ 'global_conf' ] = driver_util.get_webapp_global_conf() + kwargs[ 'global_conf' ][ '__file__' ] = "config/galaxy.ini.sample" + kwargs = load_app_properties( + kwds=kwargs + ) + # Build the Universe Application galaxyapp = GalaxyUniverseApplication( **kwargs ) log.info( "Embedded Galaxy application started" ) # ---- Run galaxy webserver ------------------------------------------------------ galaxy_server = None - galaxywebapp = galaxybuildapp.app_factory( galaxy_global_conf, + galaxywebapp = galaxybuildapp.app_factory( kwargs['global_conf'], use_translogger=False, static_enabled=True, app=galaxyapp )