From 3f0082515af630bd095ee5fc57bac044369c8f0e Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Thu, 31 Aug 2017 14:30:46 -0400 Subject: [PATCH] Improvements for mule job handler testing. Ensure that the server running the job is a mule. Added a test tool that will write Galaxy app.config attributes to the output dataset. --- test/base/driver_util.py | 5 ++++ test/functional/tools/config_vars.xml | 25 +++++++++++++++++++ test/functional/tools/samples_tool_conf.xml | 1 + .../integration/test_mules_as_job_handlers.py | 18 +++++++++++-- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 test/functional/tools/config_vars.xml diff --git a/test/base/driver_util.py b/test/base/driver_util.py index 7a5a203bdc2..27aabba40fe 100644 --- a/test/base/driver_util.py +++ b/test/base/driver_util.py @@ -21,6 +21,7 @@ import nose.core import nose.loader import nose.plugins.manager from paste import httpserver +from six.moves import shlex_quote from functional import database_contexts from galaxy.app import UniverseApplication as GalaxyUniverseApplication @@ -657,6 +658,8 @@ def launch_uwsgi(kwargs, tempdir, prefix=DEFAULT_CONFIG_PREFIX, config_object=No yaml_config_path, "--module", "galaxy.webapps.galaxy.buildapp:uwsgi_app_factory()", + "--enable-threads", + "--die-on-term", ] handle_uwsgi_cli_command = getattr( @@ -665,6 +668,8 @@ def launch_uwsgi(kwargs, tempdir, prefix=DEFAULT_CONFIG_PREFIX, config_object=No if handle_uwsgi_cli_command is not None: handle_uwsgi_cli_command(uwsgi_command) + # we don't want to quote every argument but we don't want to print unquoted ones either, so do this + log.info("Starting uwsgi with command line: %s", ' '.join([shlex_quote(x) for x in uwsgi_command])) p = subprocess.Popen( uwsgi_command, cwd=galaxy_root, diff --git a/test/functional/tools/config_vars.xml b/test/functional/tools/config_vars.xml new file mode 100644 index 00000000000..4af58f28a1e --- /dev/null +++ b/test/functional/tools/config_vars.xml @@ -0,0 +1,25 @@ + + + #if str($var) != "__test_key": + echo "#echo getattr($__app__.config, str($var))#" > $out_file1 + #else: + echo "__test_value" > $out_file1 + #end if + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index 18e55f282f1..c3cc816c79b 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -118,6 +118,7 @@ + diff --git a/test/integration/test_mules_as_job_handlers.py b/test/integration/test_mules_as_job_handlers.py index 85ec4104569..ceba137526e 100644 --- a/test/integration/test_mules_as_job_handlers.py +++ b/test/integration/test_mules_as_job_handlers.py @@ -17,13 +17,27 @@ class MulesAsJobHandlersIntegrationTestCase(integration_util.IntegrationTestCase @classmethod def handle_uwsgi_cli_command(cls, command): command.extend([ + "--py-call-osafterfork", "--mule=lib/galaxy/main.py", "--farm=job-handlers:1", ]) def test_tool_simple_constructs(self): + tool_id = 'config_vars' + expect_server_name = 'main.mule' dataset_populator = DatasetPopulator(self.galaxy_interactor) history_id = dataset_populator.new_history() - dataset_populator.new_dataset( - history_id, contents="test 1 2 3", file_type="txt", wait=True + payload = dataset_populator.run_tool( + tool_id=tool_id, + inputs={'var': 'server_name'}, + history_id=history_id, + ) + dataset_id = payload['outputs'][0]['id'] + dataset_populator.wait_for_dataset(history_id, dataset_id, assert_ok=True) + output = dataset_populator.get_history_dataset_content(history_id, dataset_id=dataset_id).strip() + assert output.startswith(expect_server_name), ( + "Job handler's server name '{output}' does not start with expected string '{expected}'".format( + output=output, + expected=expect_server_name, + ) )