Loading lib/galaxy_test/driver/driver_util.py +10 −31 Original line number Diff line number Diff line Loading @@ -50,8 +50,6 @@ from galaxy_test.base.env import ( DEFAULT_WEB_HOST, target_url_parts, ) from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app from .test_logging import logging_config_file galaxy_root = galaxy_directory() Loading @@ -71,9 +69,8 @@ DEFAULT_LOCALES = "en" log = logging.getLogger("test_driver") # Global variables to pass database contexts around - only needed for older # Global variable to pass database contexts around - only needed for older # Tool Shed twill tests that didn't utilize the API for such interactions. tool_shed_context = None install_context = None Loading Loading @@ -583,26 +580,6 @@ def build_galaxy_app(simple_kwargs) -> GalaxyUniverseApplication: return app def build_shed_app(simple_kwargs): """Build a Galaxy app object from a simple keyword arguments. Construct paste style complex dictionary. Also setup "global" reference to sqlalchemy database context for tool shed database. """ log.info("Tool shed database connection: %s", simple_kwargs["database_connection"]) # TODO: Simplify global_conf to match Galaxy above... simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample" simple_kwargs["global_conf"] = get_webapp_global_conf() app = ToolshedUniverseApplication(**simple_kwargs) log.info("Embedded Toolshed application started") global tool_shed_context tool_shed_context = app.model.context return app def explicitly_configured_host_and_port(prefix, config_object): host_env_key = f"{prefix}_TEST_HOST" port_env_key = f"{prefix}_TEST_PORT" Loading Loading @@ -758,7 +735,14 @@ def launch_gravity(port, gxit_port=None, galaxy_config=None): ) def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, galaxy_config=None, config_object=None): def launch_server( app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, galaxy_config=None, config_object=None, init_fast_app=init_galaxy_fast_app, ): name = prefix.lower() host, port = explicitly_configured_host_and_port(prefix, config_object) port = attempt_ports(port) Loading Loading @@ -792,12 +776,7 @@ def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, gal static_enabled=True, register_shutdown_at_exit=False, ) if name == "galaxy": asgi_app = init_galaxy_fast_app(wsgi_webapp, app) elif name == "tool_shed": asgi_app = init_tool_shed_fast_app(wsgi_webapp, app) else: raise NotImplementedError(f"Launching {name} not implemented") asgi_app = init_fast_app(wsgi_webapp, app) server, port, thread = uvicorn_serve(asgi_app, host=host, port=port) set_and_wait_for_http_target(prefix, host, port, url_prefix=url_prefix) Loading lib/tool_shed/test/base/driver.py +27 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ from galaxy.webapps.galaxy.buildapp import app_factory as galaxy_app_factory from galaxy_test.driver import driver_util from tool_shed.test.base.api_util import get_admin_api_key from tool_shed.webapp import buildapp as toolshedbuildapp from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app log = driver_util.build_logger() Loading @@ -36,6 +38,29 @@ shed_data_manager_conf_xml_template = """<?xml version="1.0"?> <data_managers> </data_managers> """ # Global variable to pass database contexts around - only needed for older # Tool Shed twill tests that didn't utilize the API for such interactions. tool_shed_context = None def build_shed_app(simple_kwargs): """Build a Galaxy app object from a simple keyword arguments. Construct paste style complex dictionary. Also setup "global" reference to sqlalchemy database context for tool shed database. """ log.info("Tool shed database connection: %s", simple_kwargs["database_connection"]) # TODO: Simplify global_conf to match Galaxy above... simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample" simple_kwargs["global_conf"] = driver_util.get_webapp_global_conf() app = ToolshedUniverseApplication(**simple_kwargs) log.info("Embedded Toolshed application started") global tool_shed_context tool_shed_context = app.model.context return app class ToolShedTestDriver(driver_util.TestDriver): Loading Loading @@ -117,10 +142,11 @@ class ToolShedTestDriver(driver_util.TestDriver): # ---- Run tool shed webserver ------------------------------------------------------ # TODO: Needed for hg middleware ('lib/galaxy/webapps/tool_shed/framework/middleware/hg.py') tool_shed_server_wrapper = driver_util.launch_server( app_factory=lambda: driver_util.build_shed_app(kwargs), app_factory=lambda: build_shed_app(kwargs), webapp_factory=toolshedbuildapp.app_factory, galaxy_config=kwargs, prefix="TOOL_SHED", init_fast_app=init_tool_shed_fast_app, ) self.server_wrappers.append(tool_shed_server_wrapper) tool_shed_test_host = tool_shed_server_wrapper.host Loading lib/tool_shed/test/base/test_db_util.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ log = logging.getLogger("test.tool_shed.test_db_util") def sa_session(): from galaxy_test.driver.driver_util import tool_shed_context as sa_session from .driver import tool_shed_context as sa_session return sa_session Loading Loading
lib/galaxy_test/driver/driver_util.py +10 −31 Original line number Diff line number Diff line Loading @@ -50,8 +50,6 @@ from galaxy_test.base.env import ( DEFAULT_WEB_HOST, target_url_parts, ) from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app from .test_logging import logging_config_file galaxy_root = galaxy_directory() Loading @@ -71,9 +69,8 @@ DEFAULT_LOCALES = "en" log = logging.getLogger("test_driver") # Global variables to pass database contexts around - only needed for older # Global variable to pass database contexts around - only needed for older # Tool Shed twill tests that didn't utilize the API for such interactions. tool_shed_context = None install_context = None Loading Loading @@ -583,26 +580,6 @@ def build_galaxy_app(simple_kwargs) -> GalaxyUniverseApplication: return app def build_shed_app(simple_kwargs): """Build a Galaxy app object from a simple keyword arguments. Construct paste style complex dictionary. Also setup "global" reference to sqlalchemy database context for tool shed database. """ log.info("Tool shed database connection: %s", simple_kwargs["database_connection"]) # TODO: Simplify global_conf to match Galaxy above... simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample" simple_kwargs["global_conf"] = get_webapp_global_conf() app = ToolshedUniverseApplication(**simple_kwargs) log.info("Embedded Toolshed application started") global tool_shed_context tool_shed_context = app.model.context return app def explicitly_configured_host_and_port(prefix, config_object): host_env_key = f"{prefix}_TEST_HOST" port_env_key = f"{prefix}_TEST_PORT" Loading Loading @@ -758,7 +735,14 @@ def launch_gravity(port, gxit_port=None, galaxy_config=None): ) def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, galaxy_config=None, config_object=None): def launch_server( app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, galaxy_config=None, config_object=None, init_fast_app=init_galaxy_fast_app, ): name = prefix.lower() host, port = explicitly_configured_host_and_port(prefix, config_object) port = attempt_ports(port) Loading Loading @@ -792,12 +776,7 @@ def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, gal static_enabled=True, register_shutdown_at_exit=False, ) if name == "galaxy": asgi_app = init_galaxy_fast_app(wsgi_webapp, app) elif name == "tool_shed": asgi_app = init_tool_shed_fast_app(wsgi_webapp, app) else: raise NotImplementedError(f"Launching {name} not implemented") asgi_app = init_fast_app(wsgi_webapp, app) server, port, thread = uvicorn_serve(asgi_app, host=host, port=port) set_and_wait_for_http_target(prefix, host, port, url_prefix=url_prefix) Loading
lib/tool_shed/test/base/driver.py +27 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ from galaxy.webapps.galaxy.buildapp import app_factory as galaxy_app_factory from galaxy_test.driver import driver_util from tool_shed.test.base.api_util import get_admin_api_key from tool_shed.webapp import buildapp as toolshedbuildapp from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app log = driver_util.build_logger() Loading @@ -36,6 +38,29 @@ shed_data_manager_conf_xml_template = """<?xml version="1.0"?> <data_managers> </data_managers> """ # Global variable to pass database contexts around - only needed for older # Tool Shed twill tests that didn't utilize the API for such interactions. tool_shed_context = None def build_shed_app(simple_kwargs): """Build a Galaxy app object from a simple keyword arguments. Construct paste style complex dictionary. Also setup "global" reference to sqlalchemy database context for tool shed database. """ log.info("Tool shed database connection: %s", simple_kwargs["database_connection"]) # TODO: Simplify global_conf to match Galaxy above... simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample" simple_kwargs["global_conf"] = driver_util.get_webapp_global_conf() app = ToolshedUniverseApplication(**simple_kwargs) log.info("Embedded Toolshed application started") global tool_shed_context tool_shed_context = app.model.context return app class ToolShedTestDriver(driver_util.TestDriver): Loading Loading @@ -117,10 +142,11 @@ class ToolShedTestDriver(driver_util.TestDriver): # ---- Run tool shed webserver ------------------------------------------------------ # TODO: Needed for hg middleware ('lib/galaxy/webapps/tool_shed/framework/middleware/hg.py') tool_shed_server_wrapper = driver_util.launch_server( app_factory=lambda: driver_util.build_shed_app(kwargs), app_factory=lambda: build_shed_app(kwargs), webapp_factory=toolshedbuildapp.app_factory, galaxy_config=kwargs, prefix="TOOL_SHED", init_fast_app=init_tool_shed_fast_app, ) self.server_wrappers.append(tool_shed_server_wrapper) tool_shed_test_host = tool_shed_server_wrapper.host Loading
lib/tool_shed/test/base/test_db_util.py +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ log = logging.getLogger("test.tool_shed.test_db_util") def sa_session(): from galaxy_test.driver.driver_util import tool_shed_context as sa_session from .driver import tool_shed_context as sa_session return sa_session Loading