From d2102123d9526cdf10a351f489aeece88d60f39d Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Thu, 12 Nov 2009 11:07:05 -0500 Subject: [PATCH] Add a "maxseconds" attribute to the "test" tag in tool configs. Allows the tool writer to decide how long Galaxy should wait for tool execution to complete. Resolves issue #219. --- lib/galaxy/tools/__init__.py | 3 ++- lib/galaxy/tools/test.py | 3 ++- test/base/twilltestcase.py | 16 +++++++++------- test/functional/test_toolbox.py | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 2650ea642aa..fff66f9d627 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -547,7 +547,8 @@ class Tool: self.tests = [] for i, test_elem in enumerate( tests_elem.findall( 'test' ) ): name = test_elem.get( 'name', 'Test-%d' % (i+1) ) - test = ToolTestBuilder( self, name ) + maxseconds = int( test_elem.get( 'maxseconds', '120' ) ) + test = ToolTestBuilder( self, name, maxseconds ) try: for param_elem in test_elem.findall( "param" ): attrib = dict( param_elem.attrib ) diff --git a/lib/galaxy/tools/test.py b/lib/galaxy/tools/test.py index 77bf8613fe2..52e142bd301 100644 --- a/lib/galaxy/tools/test.py +++ b/lib/galaxy/tools/test.py @@ -11,9 +11,10 @@ class ToolTestBuilder( object ): dynamic TestCase class (the unittest framework is very class oriented, doing dynamic tests in this was allows better integration) """ - def __init__( self, tool, name ): + def __init__( self, tool, name, maxseconds ): self.tool = tool self.name = name + self.maxseconds = maxseconds self.required_files = [] self.inputs = [] self.outputs = [] diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index fa85e85b985..98bd8d6fc73 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -513,10 +513,10 @@ class TwillTestCase( unittest.TestCase ): hid = elem.get('hid') hids.append(hid) return hids - def verify_dataset_correctness( self, filename, hid=None, wait=True ): + def verify_dataset_correctness( self, filename, hid=None, wait=True, maxseconds=120 ): """Verifies that the attributes and contents of a history item meet expectations""" if wait: - self.wait() #wait for job to finish + self.wait( maxseconds=maxseconds ) #wait for job to finish data_list = self.get_history_as_data_list() self.assertTrue( data_list ) if hid is None: # take last hid @@ -906,21 +906,23 @@ class TwillTestCase( unittest.TestCase ): tc.fv( "1","hgta_doGalaxyQuery", "Send query to Galaxy" ) self.submit_form( button="Send query to Galaxy" )#, **output_params ) #AssertionError: Attempting to set field 'fbQual' to value '['whole']' in form 'None' threw exception: no matching forms! control: - def wait( self, maxiter=20 ): + def wait( self, maxseconds=120 ): """Waits for the tools to finish""" - count = 0 sleep_amount = 0.1 + slept = 0 self.home() - while count < maxiter: - count += 1 + while slept <= maxseconds: self.visit_page( "history" ) page = tc.browser.get_html() if page.find( '' ) > -1: time.sleep( sleep_amount ) + slept += sleep_amount sleep_amount *= 2 + if slept + sleep_amount > maxseconds: + sleep_amount = maxseconds - slept # don't overshoot maxseconds else: break - self.assertNotEqual(count, maxiter) + assert slept < maxseconds # Dataset Security stuff # Tests associated with users diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py index 131399cc00b..1d9688beb47 100644 --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -63,7 +63,7 @@ class ToolTestCase( TwillTestCase ): # Check the result assert len( testdef.outputs ) == 1, "ToolTestCase does not deal with multiple outputs properly yet." for name, file in testdef.outputs: - self.verify_dataset_correctness( file ) + self.verify_dataset_correctness( file, maxseconds=testdef.maxseconds ) self.delete_history( id=self.security.encode_id( latest_history.id ) ) def __expand_grouping( self, tool_inputs, declared_inputs, prefix='' ):