From 3cb2bb1c359a7dd9f66e07e04490262b753e83e6 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 25 Mar 2016 13:22:09 -0400 Subject: [PATCH] Start work on synchronizing functional test drivers. - Tweak paths in same way. - Don't write tool shed temp files to GALAXY_ROOT - respect /tmp. - Build identical loggers. --- scripts/functional_tests.py | 8 +++++--- test/base/driver_util.py | 32 ++++++++++++++++++++++++++++++ test/tool_shed/functional_tests.py | 15 +++++--------- 3 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 test/base/driver_util.py diff --git a/scripts/functional_tests.py b/scripts/functional_tests.py index 192dfc17206..065ab538a28 100644 --- a/scripts/functional_tests.py +++ b/scripts/functional_tests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python + import httplib -import logging import os import os.path import random @@ -24,6 +24,10 @@ from paste import httpserver 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" ) ] +from base import driver_util +driver_util.configure_environment() +log = driver_util.build_logger() + from base.api_util import get_master_api_key, get_user_api_key from base.nose_util import run from base.instrument import StructuredTestDataPlugin @@ -35,8 +39,6 @@ from galaxy.app import UniverseApplication from galaxy.util.properties import load_app_properties from galaxy.web import buildapp -log = logging.getLogger( "functional_tests.py" ) - default_galaxy_test_host = "localhost" default_galaxy_test_port_min = 8000 default_galaxy_test_port_max = 9999 diff --git a/test/base/driver_util.py b/test/base/driver_util.py new file mode 100644 index 00000000000..a0f3a90adfd --- /dev/null +++ b/test/base/driver_util.py @@ -0,0 +1,32 @@ +"""Scripts for drivers of Galaxy functional tests.""" + +import tempfile +import os +import logging + + +def setup_tool_shed_tmp_dir(): + tool_shed_test_tmp_dir = os.environ.get('TOOL_SHED_TEST_TMP_DIR', None) + if tool_shed_test_tmp_dir is None: + tool_shed_test_tmp_dir = tempfile.mkdtemp() + # Here's the directory where everything happens. Temporary directories are created within this directory to contain + # the hgweb.config file, the database, new repositories, etc. Since the tool shed browses repository contents via HTTP, + # the full path to the temporary directroy wher eht repositories are located cannot contain invalid url characters. + os.environ[ 'TOOL_SHED_TEST_TMP_DIR' ] = tool_shed_test_tmp_dir + return tool_shed_test_tmp_dir + + +def configure_environment(): + """Hack up environment for test cases.""" + # no op remove if unused + + +def build_logger(): + """Build a logger for test driver script.""" + return logging.getLogger("test_driver") + + +__all__ = [ + "configure_environment", + "build_logger" +] diff --git a/test/tool_shed/functional_tests.py b/test/tool_shed/functional_tests.py index 6d3da018b51..c631207a838 100644 --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -2,7 +2,6 @@ from __future__ import absolute_import import httplib -import logging import os import random import shutil @@ -15,13 +14,6 @@ import time import urllib galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)) -tool_shed_home_directory = os.path.join( galaxy_root, 'test', 'tool_shed' ) -default_tool_shed_test_file_dir = os.path.join( tool_shed_home_directory, 'test_data' ) -# Here's the directory where everything happens. Temporary directories are created within this directory to contain -# the hgweb.config file, the database, new repositories, etc. Since the tool shed browses repository contents via HTTP, -# the full path to the temporary directroy wher eht repositories are located cannot contain invalid url characters. -tool_shed_test_tmp_dir = os.path.join( tool_shed_home_directory, 'tmp' ) -os.environ[ 'TOOL_SHED_TEST_TMP_DIR' ] = tool_shed_test_tmp_dir # Need to remove this directory from sys.path sys.path[0:1] = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ] @@ -31,6 +23,11 @@ import nose.core import nose.loader import nose.plugins.manager +from base import driver_util +driver_util.configure_environment() +log = driver_util.build_logger() +tool_shed_test_tmp_dir = driver_util.setup_tool_shed_tmp_dir() + # This is for the tool shed application. from galaxy.webapps.tool_shed import buildapp as toolshedbuildapp from galaxy.webapps.tool_shed.app import UniverseApplication as ToolshedUniverseApplication @@ -42,8 +39,6 @@ from galaxy.web import buildapp as galaxybuildapp from base import nose_util from functional import database_contexts -log = logging.getLogger( "tool_shed_functional_tests.py" ) - default_tool_shed_test_host = "localhost" default_tool_shed_test_port_min = 8000 default_tool_shed_test_port_max = 8999