Skip to content

Commit

Permalink
Allow running Galaxy tests on an existing external instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Mar 29, 2016
1 parent 915b7ed commit eac6c10
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
24 changes: 24 additions & 0 deletions run_tests.sh
Expand Up @@ -35,6 +35,14 @@ Run a specific API test:
./run_tests.sh -api test/api/test_tools.py:ToolsTestCase.test_map_over_with_output_format_actions
External Tests:
A small subset of tests can be run against an existing Galxy
instance. The external Galaxy instance URL can be configured with
--external_url. If this is set eithre --external_master_key or
--external_user_key must be set as well - more tests can be executed
with --external_master_key than with a user key.
Extra options:
--verbose_errors Force some tests produce more verbose error reporting.
--no_cleanup Do not delete temp files for Python functional tests (-toolshed, -framework, etc...)
Expand All @@ -45,6 +53,10 @@ Extra options:
--dockerize Run tests in a pre-configured Docker container (must be first argument if present).
--db <type> For use with --dockerize, run tests using partially migrated 'postgres', 'mysql',
or 'sqlite' databases.
--external_url External URL to use for Galaxy testing (only certain tests).
--external_master_key Master API key used to configure external tests.
--external_user_key User API used for external tests - not required if
external_master_key is specified.
Environment Variables:
Expand Down Expand Up @@ -200,6 +212,18 @@ do
with_framework_test_tools_arg="-with_framework_test_tools"
shift
;;
--external_url)
GALAXY_TEST_EXTERNAL=$2
shift 2
;;
--external_master_key)
GALAXY_CONFIG_MASTER_KEY=$2
shift 2
;;
--external_user_key)
GALAXY_TEST_USER_API_KEY=$2
shift 2
;;
-w|-workflow|--workflow)
if [ $# -gt 1 ]; then
workflow_file=$2
Expand Down
33 changes: 18 additions & 15 deletions scripts/functional_tests.py
Expand Up @@ -38,14 +38,14 @@ def main():
default_tool_conf = driver_util.FRAMEWORK_SAMPLE_TOOLS_CONF
datatypes_conf_override = driver_util.FRAMEWORK_DATATYPES_CONF

start_server = 'GALAXY_TEST_EXTERNAL' not in os.environ
external_galaxy = os.environ.get('GALAXY_TEST_EXTERNAL', None)

galaxy_test_tmp_dir = driver_util.get_galaxy_test_tmp_dir()

app = None
server_wrapper = None

if start_server:
if external_galaxy is None:
tempdir = tempfile.mkdtemp( dir=galaxy_test_tmp_dir )
# Configure the database path.
galaxy_db_path = driver_util.database_files_path(tempdir)
Expand All @@ -65,6 +65,8 @@ def main():
galaxy_config,
)
log.info("Functional tests will be run against %s:%s" % (server_wrapper.host, server_wrapper.port))
else:
log.info("Functional tests will be run against %s" % external_galaxy)

# ---- Find tests ---------------------------------------------------------
success = False
Expand All @@ -90,19 +92,20 @@ def main():
user_api_key=get_user_api_key(),
)

# We must make sure that functional.test_toolbox is always imported after
# database_contexts.galaxy_content is set (which occurs in this method above).
# If functional.test_toolbox is imported before database_contexts.galaxy_content
# is set, sa_session will be None in all methods that use it.
import functional.test_toolbox
functional.test_toolbox.toolbox = app.toolbox
# When testing data managers, do not test toolbox.
functional.test_toolbox.build_tests(
app=app,
testing_shed_tools=testing_shed_tools,
master_api_key=get_master_api_key(),
user_api_key=get_user_api_key(),
)
if app is not None:
# We must make sure that functional.test_toolbox is always imported after
# database_contexts.galaxy_content is set (which occurs in this method above).
# If functional.test_toolbox is imported before database_contexts.galaxy_content
# is set, sa_session will be None in all methods that use it.
import functional.test_toolbox
functional.test_toolbox.toolbox = app.toolbox
# When testing data managers, do not test toolbox.
functional.test_toolbox.build_tests(
app=app,
testing_shed_tools=testing_shed_tools,
master_api_key=get_master_api_key(),
user_api_key=get_user_api_key(),
)
success = driver_util.nose_config_and_run()
except:
log.exception( "Failure running tests" )
Expand Down
3 changes: 2 additions & 1 deletion test/base/twilltestcase.py
Expand Up @@ -48,7 +48,8 @@ def setUp( self ):
self.history_id = os.environ.get( 'GALAXY_TEST_HISTORY_ID', None )
self.host = os.environ.get( 'GALAXY_TEST_HOST' )
self.port = os.environ.get( 'GALAXY_TEST_PORT' )
self.url = "http://%s:%s" % ( self.host, self.port )
default_url = "http://%s:%s" % (self.host, self.port)
self.url = os.environ.get('GALAXY_TEST_EXTERNAL', default_url)
self.test_data_resolver = TestDataResolver( )
self.tool_shed_test_file = os.environ.get( 'GALAXY_TOOL_SHED_TEST_FILE', None )
if self.tool_shed_test_file:
Expand Down

0 comments on commit eac6c10

Please sign in to comment.