[hg] galaxy 3018: Add a "maxseconds" attribute to the "test" tag...
details: http://www.bx.psu.edu/hg/galaxy/rev/24f0d1e7f39f changeset: 3018:24f0d1e7f39f user: Nate Coraor <nate@bx.psu.edu> date: Thu Nov 12 11:07:05 2009 -0500 description: 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. diffstat: 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(-) diffs (85 lines): diff -r 18586d1194f9 -r 24f0d1e7f39f lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Wed Nov 11 17:55:08 2009 -0500 +++ b/lib/galaxy/tools/__init__.py Thu Nov 12 11:07:05 2009 -0500 @@ -547,7 +547,8 @@ 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 -r 18586d1194f9 -r 24f0d1e7f39f lib/galaxy/tools/test.py --- a/lib/galaxy/tools/test.py Wed Nov 11 17:55:08 2009 -0500 +++ b/lib/galaxy/tools/test.py Thu Nov 12 11:07:05 2009 -0500 @@ -11,9 +11,10 @@ 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 -r 18586d1194f9 -r 24f0d1e7f39f test/base/twilltestcase.py --- a/test/base/twilltestcase.py Wed Nov 11 17:55:08 2009 -0500 +++ b/test/base/twilltestcase.py Thu Nov 12 11:07:05 2009 -0500 @@ -513,10 +513,10 @@ 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 @@ 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: <RadioControl(fbQual=[whole, upstreamAll, endAll])> - 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( '<!-- running: do not change this comment, used by TwillTestCase.wait -->' ) > -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 -r 18586d1194f9 -r 24f0d1e7f39f test/functional/test_toolbox.py --- a/test/functional/test_toolbox.py Wed Nov 11 17:55:08 2009 -0500 +++ b/test/functional/test_toolbox.py Thu Nov 12 11:07:05 2009 -0500 @@ -63,7 +63,7 @@ # 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='' ):
participants (1)
-
Greg Von Kuster